Commit Graph

1191 Commits

Author SHA1 Message Date
ad
185d25c158 Minor corrections to comments. 2008-02-27 14:23:33 +00:00
yamt
0a2b10db61 uao_put: fix a race with pageout. 2008-02-27 13:46:20 +00:00
chris
855792073c Add some more missing pmap_update()s following pmap_kremove()s. 2008-02-23 17:27:58 +00:00
yamt
f7048cc403 uvm_uarea_init: fix compilation where PAGE_SIZE is not a constant. (sparc)
reported by Tom Spindler.
2008-02-08 11:49:40 +00:00
yamt
79c62b78b6 nonresident_rotate: avoid too long loops which can happen on some workloads. 2008-02-07 12:27:38 +00:00
yamt
7608362b58 swapcluster_flush: handle nused==0, which can happen if swapcluster_add failed.
PR/37669 from Andrew Doran.
2008-02-07 12:24:16 +00:00
yamt
cb964fe917 uvm_uarea_init: make #if about PR_NOALIGN clearer and add a comment
to explain it.
2008-02-07 12:21:24 +00:00
hannken
ee150e014e Lock swapdev_vp for VOP_OPEN.
From: YAMAMOTO Takashi <yamt@netbsd.org>
2008-01-30 14:25:21 +00:00
yamt
52838e34f5 remove a special allocator for uareas, which is no longer necessary.
use pool_cache instead.
2008-01-28 12:22:46 +00:00
hannken
ce34b417f9 uvm_swap_init(): Call VOP_OPEN() on swapdev_vp to make I/O through the
swap device work with specnodes.

Ok: Andrew Doran <ad@netbsd.org>
2008-01-27 17:18:09 +00:00
reinoud
6383f534f7 Remove extra '(' that prevented kernel with UVMHIST to be compiled 2008-01-22 21:36:23 +00:00
yamt
2b40f35040 push pmap_clear_reference calls into pdpolicy code, where reference bits
actually matter.
2008-01-18 10:48:23 +00:00
yamt
729c3a185b unwrap short lines. 2008-01-13 16:46:47 +00:00
yamt
b0fbe32ddf nonresident_rotate: micro optimization 2008-01-13 16:28:41 +00:00
yamt
74e0872eca simplify locking and remove vm_map_upgrade/downgrade.
this fixes a deadlock due to read-lock recursion of map->lock.
2008-01-08 13:09:55 +00:00
matt
2414d5854f Make sys_swapctl match syscallargs.h 2008-01-08 06:25:55 +00:00
ad
0664a0459b Start detangling lock.h from intr.h. This is likely to cause short term
breakage, but the mess of dependencies has been regularly breaking the
build recently anyhow.
2008-01-04 21:17:40 +00:00
ad
4a780c9ae2 Merge vmlocking2 to head. 2008-01-02 11:48:20 +00:00
christos
65c680cad7 Add PaX ASLR (Address Space Layout Randomization) [from elad and myself]
For regular (non PIE) executables randomization is enabled for:
    1. The data segment
    2. The stack

For PIE executables(*) randomization is enabled for:
    1. The program itself
    2. All shared libraries
    3. The data segment
    4. The stack

(*) To generate a PIE executable:
    - compile everything with -fPIC
    - link with -shared-libgcc -Wl,-pie

This feature is experimental, and might change. To use selectively add
    options PAX_ASLR=0
in your kernel.

Currently we are using 12 bits for the stack, program, and data segment and
16 or 24 bits for mmap, depending on __LP64__.
2007-12-26 22:11:47 +00:00
perry
970ad9314d Remove __attribute__((__noreturn__)) from things already marked __dead
Found by the department of redundancy department.
2007-12-24 15:46:45 +00:00
ad
9aef0fdbce Specify PR_LARGECACHE for anon_cache (which is insanely busy). 2007-12-20 23:50:00 +00:00
dsl
7e2790cf6f Convert all the system call entry points from:
int foo(struct lwp *l, void *v, register_t *retval)
to:
    int foo(struct lwp *l, const struct foo_args *uap, register_t *retval)
Fixup compat code to not write into 'uap' and (in some cases) to actually
pass a correctly formatted 'uap' structure with the right name to the
next routine.
A few 'compat' routines that just call standard ones have been deleted.
All the 'compat' code compiles (along with the kernels required to test
build it).
98% done by automated scripts.
2007-12-20 23:02:38 +00:00
yamt
0c38201391 add ddb "whatis" command. inspired from solaris ::whatis dcmd. 2007-12-13 02:45:09 +00:00
pooka
db06a930e6 Remove cn_lwp from struct componentname. curlwp should be used
from on.  The NDINIT() macro no longer takes the lwp parameter and
associates the credentials of the calling thread with the namei
structure.
2007-12-08 19:29:36 +00:00
ad
371ba00b4a Allocate amaps from a pool_cache. 2007-12-08 15:46:31 +00:00
ad
de874f619c Merge from vmlocking2 (use cdev_mmap()). 2007-12-08 15:33:09 +00:00
yamt
bdc83d4098 g/c uvm_vnp_sync 2007-12-05 09:37:34 +00:00
yamt
83e62acd43 fix UBC_WANT_UNMAP.
- check PMAP_CACHE_VIVT after pulling pmap.h.
	- VTEXT -> VI_TEXT.
2007-12-05 09:35:46 +00:00
yamt
e8abff70f2 constify pagerops. 2007-12-01 10:40:27 +00:00
yamt
7355a3c4f8 remove a duplicated decl. of aobj_pager. 2007-12-01 10:40:03 +00:00
yamt
062f8e82a2 use designated initiaizers for uvm_pagerops. 2007-12-01 10:18:21 +00:00
yamt
4450b52eeb uvm_pager_init: use __arraycount. 2007-12-01 10:08:21 +00:00
ad
e81b22bdcb Make {anon,file,exec}pages unsigned. 2007-11-30 22:43:17 +00:00
ad
e9e11b98df Use atomics to maintain uvmexp.{anon,exec,file}pages. 2007-11-29 18:07:11 +00:00
pooka
61e8303e9d Remove the "struct lwp *" argument from all VFS and VOP interfaces.
The general trend is to remove it from all kernel interfaces and
this is a start.  In case the calling lwp is desired, curlwp should
be used.

quick consensus on tech-kern
2007-11-26 19:01:26 +00:00
xtraeme
f444fd7856 Make this build without LOCKDEBUG (the if statement that uses
LOCKDEBUG_MEM_CHECK).
2007-11-26 08:22:32 +00:00
yamt
1a95aafc2b uvm_map_extract: for UVM_EXTRACT_QREF, mark entries UVM_MAP_NOMERGE. 2007-11-26 08:20:46 +00:00
yamt
89169ed40b uvm_unmap1: LOCKDEBUG_MEM_CHECK for kernel_map. 2007-11-26 08:15:19 +00:00
yamt
f638ba54b7 call debug_init earlier. ie. before malloc is used. 2007-11-14 11:04:07 +00:00
yamt
7bc2fdc746 g/c unused uvm_anon_pool. 2007-11-13 08:48:28 +00:00
ad
d18c6ca4de Merge from vmlocking:
- pool_cache changes.
- Debugger/procfs locking fixes.
- Other minor changes.
2007-11-07 00:23:13 +00:00
ad
d831186d55 Merge scheduler changes from the vmlocking branch. All discussed on
tech-kern:

- Invert priority space so that zero is the lowest priority. Rearrange
  number and type of priority levels into bands. Add new bands like
  'kernel real time'.
- Ignore the priority level passed to tsleep. Compute priority for
  sleep dynamically.
- For SCHED_4BSD, make priority adjustment per-LWP, not per-process.
2007-11-06 00:42:39 +00:00
yamt
23005df1e0 defparam PAGER_MAP_SIZE. 2007-10-25 13:03:03 +00:00
yamt
c3ee5a2d35 uvm_mremap: fix alignment check for the easy cases. 2007-10-15 11:26:13 +00:00
yamt
0de985a71c uvm_map_reserve: don't ignore alignment. fixes mremap. 2007-10-15 11:24:30 +00:00
hannken
988890176c When swapping to a regular file use a workqueue to signal I/O completion.
VOP_STRATEGY() no longer gets called from interrupt context via
biodone() -> sw_reg_iodone() -> sw_reg_start().

Removes a deadlock condition reported in PR 37109.

Ok: YAMAMOTO Takashi <yamt@netbsd.org>
2007-10-15 08:12:13 +00:00
skrll
0d58a1f020 Don't restrict the offset when allocating a map entry for in-kernel map -
use UVM_UNKNOWN_OFFSET in the call to uvm_map_prepare.

This fixes a '"panic: malloc: out of space in kmem_map" when it's not
really' testcase of mine, and one reported to me by chuq. This is likely
to fix PR/35587 as well.

Looks/seems fine to me from chuq and yamt. Thanks.
2007-10-12 06:45:17 +00:00
ad
4c92a21547 Remove LOCK_ASSERT(!simple_lock_held(&foo)); 2007-10-11 19:53:37 +00:00
ad
7dad9f7391 Merge from vmlocking:
- Split vnode::v_flag into three fields, depending on field locking.
- simple_lock -> kmutex in a few places.
- Fix some simple locking problems.
2007-10-10 20:42:20 +00:00
ad
451aacda90 Merge file descriptor locking, cwdi locking and cross-call changes
from the vmlocking branch.
2007-10-08 15:12:05 +00:00
ad
82f39f6568 Fix merge error. 2007-10-08 14:14:55 +00:00
ad
4de14a3313 Pad the hashlocks to 32-byte boundaries. 2007-10-08 14:06:15 +00:00
yamt
d71c563a36 make RANGE_TEST a function. 2007-09-23 16:05:40 +00:00
ad
f5096e38d8 uvm_swapin: disable the swaplock assertion. uvm_lwp_hold() can't take
the lock yet.
2007-09-21 00:18:35 +00:00
pooka
3f3cac88a3 Make bioops a pointer and point it to the softdeps struct in softdep
init.  Decouples "options SOFTDEP" from the main kernel and ffs code.
2007-09-01 23:40:21 +00:00
ad
a412ed5978 Also initialize map->lock for INTRSAFE maps. 2007-08-20 13:34:52 +00:00
ad
f6481c29d3 uvmspace_free: destroy locks. 2007-08-20 13:33:47 +00:00
ad
09e7c477d8 Include sys/cpu.h for CPU_INFO_FOREACH. 2007-08-18 10:07:55 +00:00
ad
ee1c78315b Fix error in previous. 2007-08-18 00:31:32 +00:00
ad
b5866eb299 Make the uarea cache per-CPU and drain in batches of 4. 2007-08-18 00:21:10 +00:00
drochner
a6b978e197 Round up size arguments as mmap() does.
This is for consistency, and to have semantics similar to Linux --
a Python selftest secceeds now.
2007-08-08 11:08:18 +00:00
pooka
4d42eff4e1 In uao_get(), drop object lock only after dropswap to avoid KASSERT panic.
Should fix tmpfs problem reported by riz on current-users.  yamt ok.
2007-08-05 10:19:23 +00:00
pooka
38ed0b2878 Use VSIZENOTSET only in KASSERTs 2007-08-04 09:42:58 +00:00
yamt
603d434b1b use separate nreslookup evcnt for obj and anon pages. 2007-08-01 14:49:55 +00:00
ad
a0d1fd8d0c It's not a good idea for device drivers to modify b_flags, as they don't
need to understand the locking around that field. Instead of setting
B_ERROR, set b_error instead. b_error is 'owned' by whoever completes
the I/O request.
2007-07-29 13:31:07 +00:00
yamt
3822af7031 ubc_uiomove: add an "advice" argument rather than using UVM_ADV_RANDOM blindly. 2007-07-27 09:50:36 +00:00
yamt
828aae6ba6 remove a debug printf. 2007-07-27 09:33:58 +00:00
pooka
1ce406a846 Change unused fflags parameter in VOP_MMAP to prot and pass in
desired vm protection.
2007-07-27 08:26:38 +00:00
ad
615eff98fc In order to pacify assertions, make uao_list_lock + uvm_swap_data_lock
spinlocks for the time being.
2007-07-24 19:59:35 +00:00
he
e7a46bb8e3 When _KERNEL is defined, we have now grown a dependency on
<sys/proc.h>, since one of the inline functions now refer to curlwp.
Fix this by including <sys/proc.h> when _KERNEL is defined.
2007-07-22 21:07:47 +00:00
pooka
05ce20f4a0 Retire uvn_attach() - it abuses VXLOCK and its functionality,
setting vnode sizes, is handled elsewhere: file system vnode creation
or spec_open() for regular files or block special files, respectively.

Add a call to VOP_MMAP() to the pagedvn exec path, since the vnode
is being memory mapped.

reviewed by tech-kern & wrstuden
2007-07-22 19:16:04 +00:00
ad
e7e35c1d1d Temporarily work around an assertion from mutex_enter. 2007-07-21 22:14:42 +00:00
ad
6e948e8304 Fix DEBUG build. 2007-07-21 20:52:59 +00:00
ad
4688843d2b Merge unobtrusive locking changes from the vmlocking branch. 2007-07-21 19:21:53 +00:00
joerg
e4fc1154a4 Add native mremap system call based on the UVM implementation for
Linux compat. Add code to enforce alignment of the new location.
Special thanks to wizd for helping with the man page.
2007-07-17 17:42:07 +00:00
macallan
a1457f5905 change pmap_phys_address()s parameter to paddr_t since that's what it gets
fed from mmap*() anyway
approved by gimpy
2007-07-16 23:48:03 +00:00
ad
63873b9b21 Revert unintentially committed change. 2007-07-14 22:27:15 +00:00
rmind
20bbb87e34 Implementation of per-CPU work-queues support for workqueue(9) interface.
WQ_PERCPU flag for workqueue and additional argument for workqueue_enqueue()
to assign a CPU might be used. Notes:
 - For now, the list is used for workqueue_queue, which is non-optimal,
   and will be changed with array, where index would be CPU ID.
 - The data structures should be changed to be cache-friendly.

Reviewed by: <yamt>, <tech-kern>
2007-07-12 20:39:56 +00:00
ad
88ab7da936 Merge some of the less invasive changes from the vmlocking branch:
- kthread, callout, devsw API changes
- select()/poll() improvements
- miscellaneous MT safety improvements
2007-07-09 20:51:58 +00:00
christos
751a3d3a74 handle UVM_UNKNOWN_OFFSET. 2007-06-24 22:56:58 +00:00
yamt
670c065b9a ubc_alloc: break loans on UBC_FAULTBUSY.
it's necessary after recent file overwrite changes.
(http://mail-index.NetBSD.org/source-changes/2007/06/05/0014.html)
it should fix the problem reported by Sarton O'Brien on
current-users@/port-xen@.
(http://mail-index.NetBSD.org/current-users/2007/06/22/0001.html)
2007-06-22 15:15:48 +00:00
ad
6820f4664f Add a sysctl to disable swapout of kernel stacks. Discussed on tech-kern@. 2007-06-15 18:28:39 +00:00
yamt
da51d139a4 improve post-ubc file overwrite performance in common cases.
ie. when it's safe, actually overwrite blocks rather than doing
read-modify-write.

also fixes PR/33152 and PR/36303.
2007-06-05 12:31:30 +00:00
yamt
f03010953f merge yamt-idlelwp branch. asked by core@. some ports still needs work.
from doc/BRANCHES:

	idle lwp, and some changes depending on it.

	1. separate context switching and thread scheduling.
	   (cf. gmcgarry_ctxsw)
	2. implement idle lwp.
	3. clean up related MD/MI interfaces.
	4. make scheduler(s) modular.
2007-05-17 14:51:11 +00:00
elad
6700cfccd6 Some Veriexec stuff that's been rotting in my tree for months.
Bug fixes:
  - Fix crash reported by Scott Ellis on current-users@.

  - Fix race conditions in enforcing the Veriexec rename and remove
    policies. These are NOT security issues.

  - Fix memory leak in rename handling when overwriting a monitored
    file.

  - Fix table deletion logic.

  - Don't prevent query requests if not in learning mode.


KPI updates:
  - fileassoc_table_run() now takes a cookie to pass to the callback.

  - veriexec_table_add() was removed, it is now done internally. As a
    result, there's no longer a need for VERIEXEC_TABLESIZE.

  - veriexec_report() was removed, it is now internal.

  - Perform sanity checks on the entry type, and enforce default type
    in veriexec_file_add() rather than in veriexecctl.

  - Add veriexec_flush(), used to delete all Veriexec tables, and
    veriexec_dump(), used to fill an array with all Veriexec entries.


New features:
  - Add a '-k' flag to veriexecctl, to keep the filenames in the kernel
    database. This allows Veriexec to produce slightly more accurate
    logs under certain circumstances. In the future, this can be either
    replaced by vnode->pathname translation, or combined with it.

  - Add a VERIEXEC_DUMP ioctl, to dump the entire Veriexec database.
    This can be used to recover a database if the file was lost.
    Example usage:

        # veriexecctl dump > /etc/signatures

    Note that only entries with the filename kept (that is, were loaded
    with the '-k' flag) will be dumped.

    Idea from Brett Lymn.

  - Add a VERIEXEC_FLUSH ioctl, to delete all Veriexec entries. Sample
    usage:

        # veriexecctl flush

  - Add a 'veriexec_flags' rc(8) variable, and make its default have
    the '-k' flag. On systems using the default signatures file
    (generaetd from running 'veriexecgen' with no arguments), this will
    use additional 32kb of kernel memory on average.

  - Add a '-e' flag to veriexecctl, to evaluate the fingerprint during
    load. This is done automatically for files marked as 'untrusted'.


Misc. stuff:
  - The code for veriexecctl was massively simplified as a result of
    eliminating the need for VERIEXEC_TABLESIZE, and now uses a single
    pass of the signatures file, making the loading somewhat faster.

  - Lots of minor fixes found using the (still under development)
    Veriexec regression testsuite.

  - Some of the messages Veriexec prints were improved.

  - Various documentation fixes.


All relevant man-pages were updated to reflect the above changes.

Binary compatibility with existing veriexecctl binaries is maintained.
2007-05-15 19:47:43 +00:00
christos
67695a4835 Make us standards compliant again. Return EINVAL in all cases (except for
mmap) so we cannot tell what went wrong.
2007-05-11 21:30:23 +00:00
christos
5e0b06ff45 Improve on previous and write a RANGE_TEST macro and do it on all the
system calls instead of doing a half-assed job on some of them and none
on others.
2007-05-11 20:41:14 +00:00
christos
c5a89b37a0 fix bogus wrap tests; ssize_t != int... 2007-05-11 20:05:50 +00:00
tsutsui
31c6ef6761 Add temporary workaround for PR kern/36019 (panic on sun2 and sun3).
Ok'ed by yamt.
2007-05-11 12:11:09 +00:00
yamt
e332a34211 add an evcnt and some assertions. 2007-05-07 12:39:45 +00:00
pooka
c65d708ad2 adjust misleading comment: PGO_SYNCIO does not depend on PGO_CLEANIT 2007-04-23 20:10:50 +00:00
dsl
b8fbaf8c4b Change the way that emulations locate files within the emulation root to
avoid having to allocate space in the 'stackgap'
  - which is very LWP unfriendly.
The additional code for non-emulation namei() is trivial, the reduction for
  the emulations is massive.
The vnode for a processes emulation root is saved in the cwdi structure
  during process exec.
If the emulation root the TRYEMULROOT flag are set, namei() will do an initial
  search for absolute pathnames in the emulation root, if that fails it will
  retry from the normal root.
".." at the emulation root will always go to the real root, even in the middle
  of paths and when expanding symlinks.
Absolute symlinks found using absolute paths in the emulation root will be
  relative to the emulation root (so /usr/lib/xxx.so -> /lib/xxx.so links
  inside the emulation root don't need changing).
If the root of the emulation would be returned (for an emulation lookup), then
  the real root is returned instead (matching the behaviour of emul_lookup,
  but being a cheap comparison here) so that programs that scan "../.."
  looking for the root dircetory don't loop forever.
The target for symbolic links is no longer mangled (it used to get the
  CHECK_ALT_xxx() treatment, so could get /emul/xxx prepended).
CHECK_ALT_xxx() are no more. Most of the change is deleting them, and adding
  TRYEMULROOT to the flags to NDINIT().
A lot of the emulation system call stubs could now be deleted.
2007-04-22 08:29:55 +00:00
chs
aba740b225 define a pager flag PGO_RECLAIM, similar to FSYNC_RECLAIM, and use it
to skip unnecessary flushing when layered file system vnodes are recycled.
this also prevents a deadlock with the dodgy LFS putpages routine.
fixes the non-LFS part of PR 36150.
2007-04-16 05:14:54 +00:00
perseant
9bab95b2ae Track lwp as well as proc owner with UVM_PAGE_TRKOWN 2007-04-14 07:01:33 +00:00
rmind
60e35a7f80 Export uvm_uarea_free() to the rest.
Make things compile again.
2007-03-24 21:15:39 +00:00
ad
59d979c5f1 Pass an ipl argument to pool_init/POOL_INIT to be used when initializing
the pool's lock.
2007-03-12 18:18:22 +00:00
christos
53524e44ef Kill caddr_t; there will be some MI fallout, but it will be fixed shortly. 2007-03-04 05:59:00 +00:00
yamt
e781af39bd implement priority inheritance. 2007-02-26 09:20:52 +00:00
skrll
e7f4fd07df -#include <sys/sa.h> 2007-02-23 08:18:35 +00:00
thorpej
b3667ada6d TRUE -> true, FALSE -> false 2007-02-22 06:05:00 +00:00