Commit Graph

1256 Commits

Author SHA1 Message Date
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
matt 93feeb1203 Fix lossage from boolean_t -> bool and updated x86 bus_dma. 2007-02-22 04:38:02 +00:00
thorpej dd962f8680 Pick up some additional files that were missed before due to conflicts
with newlock2 merge:

Replace the Mach-derived boolean_t type with the C99 bool type.  A
future commit will replace use of TRUE and FALSE with true and false.
2007-02-21 23:48:10 +00:00
thorpej 712239e366 Replace the Mach-derived boolean_t type with the C99 bool type. A
future commit will replace use of TRUE and FALSE with true and false.
2007-02-21 22:59:35 +00:00
ad 7df3c36a6c uvm_kick_scheduler(): do nothing until the swap subsystem is initialized. 2007-02-19 01:35:19 +00:00
pavel 934634a18c Change the process/lwp flags seen by userland via sysctl back to the
P_*/L_* naming convention, and rename the in-kernel flags to avoid
conflict. (P_ -> PK_, L_ -> LW_ ). Add back the (now unused) LSDEAD
constant.

Restores source compatibility with pre-newlock2 tools like ps or top.

Reviewed by Andrew Doran.
2007-02-17 22:31:36 +00:00
rmind 27c80c165c Mention rmind@ as an author in the license. No functional change. 2007-02-17 20:45:36 +00:00
ad 2a34d8467a Fix load average calculation:
- Don't consider kernel threads when calculating the load average. Their
  priorities are no longer adjusted by the scheduler, and their level of
  activity is dependent upon running user processes.
- Change the (l->l_priority > PZERO) check in uvm_meter() to (l->l_flag &
  L_SINTR). I think this check was originally intended to weed out
  processes sleeping interruptably.
2007-02-15 20:22:43 +00:00
ad d91014721f Add uvm_kick_scheduler() (MP safe) to replace wakeup(&proc0). 2007-02-15 20:21:13 +00:00
ad b07ec3fc38 Merge newlock2 to head. 2007-02-09 21:55:00 +00:00
elad d60f1f435f If Veriexec prevents indirect execution of the binary, in addition to just
blocking the mmap() if exec bit is requested, also strip exec bit from
maxprot for further mprotect() calls.

Okay joerg@.
2007-02-03 01:11:50 +00:00
hubertf 142c2a33ba Remove duplicate #includes, patch contributed in private mail
by Slava Semushin <slava.semushin@gmail.com>.

To verify that no nasty side effects of duplicate includes (or their
removal) have an effect here, I've compiled an i386/ALL kernel with
and without the patch, and the only difference in the resulting .o
files was in shifted line numbers in some assert() calls.
The comparison of the .o files was based on the output of "objdump -D".

Thanks to martin@ for the input on testing.
2007-01-24 13:08:11 +00:00
skrll 4b3e98dc1b Remove useless double assignment.
PR 35442
2007-01-19 15:52:24 +00:00
elad fa26351488 Cosmetic nit in the 'filename' passed to veriexec_verify(). 2007-01-11 14:26:07 +00:00
alc 2fc133de08 CID-4192: ensure we have 'uobj != NULL` here
ok christos@ and yamt@
2006-12-27 17:59:08 +00:00
yamt 8bf7662829 merge yamt-splraiseipl branch.
- finish implementing splraiseipl (and makeiplcookie).
	  http://mail-index.NetBSD.org/tech-kern/2006/07/01/0000.html
	- complete workqueue(9) and fix its ipl problem, which is reported
	  to cause audio skipping.
	- fix netbt (at least compilation problems) for some ports.
	- fix PR/33218.
2006-12-21 15:55:21 +00:00
skrll 03c2b891e6 Update uvm_grow to support stacks that grow upwards.
Use on hppa and fix a bug in the hppa trap handler.
2006-12-18 09:39:14 +00:00
yamt fc88d88996 put ->K loaned pages on the page queue, so that page loaning doesn't
disturb pagedaemon/pdpolicy.
2006-12-15 13:51:30 +00:00
chs c398ae9734 a smorgasbord of improvements to vnode locking and path lookup:
- LOCKPARENT is no longer relevant for lookup(), relookup() or VOP_LOOKUP().
   these now always return the parent vnode locked.  namei() works as before.
   lookup() and various other paths no longer acquire vnode locks in the
   wrong order via vrele().  fixes PR 32535.
   as a nice side effect, path lookup is also up to 25% faster.
 - the above allows us to get rid of PDIRUNLOCK.
 - also get rid of WANTPARENT (just use LOCKPARENT and unlock it).
 - remove an assumption in layer_node_find() that all file systems implement
   a recursive VOP_LOCK() (unionfs doesn't).
 - require that all file systems supply vfs_vptofh and vfs_fhtovp routines.
   fill in eopnotsupp() for file systems that don't support being exported
   and remove the checks for NULL.  (layerfs calls these without checking.)
 - in union_lookup1(), don't change refcounts in the ISDOTDOT case, just
   adjust which vnode is locked.  fixes PR 33374.
 - apply fixes for ufs_rename() from ufs_vnops.c rev. 1.61 to ext2fs_rename().
2006-12-09 16:11:50 +00:00
elad b8e4702fb2 Back out uvm_is_swap_device(). 2006-12-07 14:06:51 +00:00
elad cbcd623862 We are required to hold uvm.swap_data_lock here too. 2006-12-02 03:23:38 +00:00
yamt 10cd898fb8 uvm_fault: fix an assertion. PR/35134 from Christos Zoulas.
it can be triggered by minherit as well.
2006-12-01 19:15:22 +00:00
elad a6c2dfb16d Introduce uvm_is_swap_device(), to check if the passed struct vnode * is
used as a swap device or not.

Okay mrg@.
2006-12-01 16:06:09 +00:00
yamt c6970b82a3 uvm_fault: unwrap a short line. 2006-11-28 13:16:37 +00:00
yamt ec1dd90a2a uvmpdpol_pagedequeue: clear PQ_INITIALREF.
otherwise, dequeue/enqueue cycles (eg. page loaning) can cause
an assertion failure in clockpro_pageenqueue.
2006-11-28 13:14:53 +00:00
christos df031f1edc PR/34837: Mindaguas: Add SysV SHM dynamic reallocation and locking to the
physical memory
2006-11-25 21:40:04 +00:00
christos 168cd830d2 __unused removal on arguments; approved by core. 2006-11-16 01:32:37 +00:00
yamt 1a7bc55dcc remove some __unused from function parameters. 2006-11-01 10:17:58 +00:00
yamt b89279d039 revert malloc -> kmem_alloc part of uvm_swap.c rev.1.110 because
the current implementation of kmem_free can sleep.
2006-10-27 15:06:04 +00:00
uwe 5704a46a71 uvm_page_printall: With new PQ_* flags pg->pqflags no longer fits and
makes the output of "show all pages" ragged.  Widen the field to 4 chars.
2006-10-26 20:00:52 +00:00
yamt e95cf416a6 extent/malloc -> vmem_alloc/kmem_alloc. 2006-10-22 09:44:21 +00:00
mrg 648bbec934 in cpu_dumpconf(), don't panic() if we can't bdevsw_lookup() the
dumpdev.  this occurs when we try to set the dumpdev to a device
with no driver loaded.  this fixes PR#34872.

in sys_swapctl, if bdevsw_lookup() fails, set dumpdev = NODEV
before calling cpu_dumpconf().  (this also fixes PR#34872.)

XXX: cpu_dumpconf() should probably be changed to take a dumpdev
XXX: and return an error in such cases, but that is a much more
XXX: intrusive change.

XXX2: this is only run-tested on sparc64 and compile tested on a
XXX2: couple of platforms.
2006-10-21 05:54:31 +00:00
yamt 4ba42a7148 add an assertion. 2006-10-19 09:34:00 +00:00
yamt a7dbf2d5e5 uvm_loanbreak: transfer dirtiness of the old page to the new page,
rather than blindly mark it dirty.  fix a part of PR/33513.
2006-10-14 09:23:56 +00:00
yamt 61934cf2b4 uvm_vnp_setsize: put back v_size assignment after uvn_put.
PR/34147 from Juergen Hannken-Illjes.
2006-10-14 09:20:35 +00:00
uwe bb003f9487 More __unused (in cpp conditionals not touched by i386). 2006-10-12 21:35:00 +00:00
dogcow e0909532c0 even more __unused. 2006-10-12 20:18:19 +00:00
yamt 0a8c1584c7 remove unnecessary #include of vnode.h. 2006-10-12 10:14:43 +00:00
yamt 9de1cdc8fe move some knowledge about vnode into uvm_vnode.c. 2006-10-12 10:14:20 +00:00
yamt b290489c81 whitespace. 2006-10-12 10:13:35 +00:00
yamt 0b30e1501c uobj_wirepages and uobj_unwirepages from Mindaugas. PR/34771.
(commented out in files.uvm for now because there is no user in tree.)

http://mail-index.netbsd.org/tech-kern/2006/09/24/0000.html
http://mail-index.netbsd.org/tech-kern/2006/10/10/0000.html
2006-10-12 10:11:57 +00:00
thorpej 401a3924d5 uvm_swap_stats_locked(): Consume the cmd argument even if COMPAT_13 is
not defined.
2006-10-12 04:35:40 +00:00
christos 4d595fd7b1 - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
2006-10-12 01:30:41 +00:00
yamt 86004aaed3 fix some warnings in the case of PDSIM. 2006-10-09 12:50:39 +00:00
yamt dbdfc1f677 move src/sys/uvm/pdsim to src/regress/sys/uvm/pdsim.
no objection on tech-kern@.
2006-10-09 12:32:21 +00:00
chs 33c1fd1917 add support for O_DIRECT (I/O directly to application memory,
bypassing any kernel caching for file data).
2006-10-05 14:48:32 +00:00
christos b01cc3ff0a Coverity CID 3170,3171: Add KASSERT. 2006-10-03 18:26:03 +00:00
yamt 7e4975c5e3 don't use japanese for an identifier. 2006-09-30 16:14:00 +00:00
yamt 606f2d8add wrap a long line. 2006-09-30 16:01:19 +00:00
yamt 883278d33e whitespace. 2006-09-30 15:52:39 +00:00
yamt 04a8266e88 add ubc window hit/miss evcnts. 2006-09-30 15:38:06 +00:00
yamt 7e1b20a4cf ubc_fault: check UVM_OBJ_NEEDS_WRITEFAULT.
fix an assertion failure in genfs_putpages when using msdosfs.
(http://mail-index.NetBSD.org/tech-kern/2006/09/27/0002.html)
reported and tested by Darrin B.Jewell.
2006-09-30 15:37:22 +00:00
elad 53ca07b4d7 If Veriexec enforces access type, don't allow mmap() to use PROT_EXEC on
files that don't have the "indirect" flag. Also change the "library" alias
in veriexecctl(8) to mean "file, indirect".

okay blymn@
2006-09-30 10:56:31 +00:00
yamt 3545644943 more todo. 2006-09-30 09:07:45 +00:00
yamt 1da8d3a36e note what's this. 2006-09-30 09:03:19 +00:00
yamt a5c3459e65 implementations of some replacement algorithms for comparison. 2006-09-30 09:00:00 +00:00
yamt 2ebf73755e a script to modify a list so that it uses small numbers as far as possible.
useful when feeding real world examples into a hackish code like lirs.c
which can't handle large numbers.
2006-09-30 08:57:17 +00:00
yamt adf92c530f implementations of some replacement algorithms for comparison. 2006-09-30 08:50:32 +00:00
yamt 538ff1a080 an artificial access pattern generator. 2006-09-30 08:48:17 +00:00
yamt 94330f3fe8 a simple program to test uvm_pdpolicy_*.c in userland. 2006-09-30 08:47:39 +00:00
thorpej ec1894a78a Don't inline uvm_pagealloc_pgfl(). 2006-09-27 17:18:50 +00:00
yamt 8e991698b9 revert a change which was unintentionally slipped in via yamt-pdpolicy branch. 2006-09-16 07:14:38 +00:00
yamt 9d3e3eab23 merge yamt-pdpolicy branch.
- separate page replacement policy from the rest of kernel
	- implement an alternative replacement policy
2006-09-15 15:51:12 +00:00
elad 5f7169ccb1 First take at security model abstraction.
- Add a few scopes to the kernel: system, network, and machdep.

- Add a few more actions/sub-actions (requests), and start using them as
  opposed to the KAUTH_GENERIC_ISSUSER place-holders.

- Introduce a basic set of listeners that implement our "traditional"
  security model, called "bsd44". This is the default (and only) model we
  have at the moment.

- Update all relevant documentation.

- Add some code and docs to help folks who want to actually use this stuff:

  * There's a sample overlay model, sitting on-top of "bsd44", for
    fast experimenting with tweaking just a subset of an existing model.

    This is pretty cool because it's *really* straightforward to do stuff
    you had to use ugly hacks for until now...

  * And of course, documentation describing how to do the above for quick
    reference, including code samples.

All of these changes were tested for regressions using a Python-based
testsuite that will be (I hope) available soon via pkgsrc. Information
about the tests, and how to write new ones, can be found on:

	http://kauth.linbsd.org/kauthwiki

NOTE FOR DEVELOPERS: *PLEASE* don't add any code that does any of the
following:

  - Uses a KAUTH_GENERIC_ISSUSER kauth(9) request,
  - Checks 'securelevel' directly,
  - Checks a uid/gid directly.

(or if you feel you have to, contact me first)

This is still work in progress; It's far from being done, but now it'll
be a lot easier.

Relevant mailing list threads:

http://mail-index.netbsd.org/tech-security/2006/01/25/0011.html
http://mail-index.netbsd.org/tech-security/2006/03/24/0001.html
http://mail-index.netbsd.org/tech-security/2006/04/18/0000.html
http://mail-index.netbsd.org/tech-security/2006/05/15/0000.html
http://mail-index.netbsd.org/tech-security/2006/08/01/0000.html
http://mail-index.netbsd.org/tech-security/2006/08/25/0000.html

Many thanks to YAMAMOTO Takashi, Matt Thomas, and Christos Zoulas for help
stablizing kauth(9).

Full credit for the regression tests, making sure these changes didn't break
anything, goes to Matt Fleming and Jaime Fournier.

Happy birthday Randi! :)
2006-09-08 20:58:56 +00:00
christos 37ba677a84 use c99 initializers 2006-09-03 21:37:22 +00:00
christos 5dc39be6da add missing initializers 2006-09-03 21:37:06 +00:00
christos aa6004da57 use c99 initializer. 2006-09-03 21:33:33 +00:00
cherry 8a4036de78 bumps kernel aobj to 64 bit. \
See: http://mail-index.netbsd.org/tech-kern/2006/03/07/0007.html
2006-09-01 20:39:05 +00:00
matt 9e0ec4816e Make PTRACE and COREDUMP optional. Make the default (status quo) by putting
them in conf/std.
2006-08-29 23:34:48 +00:00
martin c8872be34c Add a new swapctl(2) command to unset the dump device. 2006-08-22 14:07:07 +00:00
yamt 36b78db59e ubc_fault: fix a deadlock in the case of uvm_loanbreak() failure. 2006-08-18 15:03:21 +00:00
he 5ea0e70c68 Rearrange included headers and/or add include of <sys/types.h> and
<sys/lock.h>, so that the mipsco port can build again, ref.
  http://mail-index.netbsd.org/port-mips/2006/08/04/0000.html
Reviewed by thorpej
2006-08-04 22:42:36 +00:00
yamt f9458a6ba1 - in genfs_getpages, take g_glock earlier so that it can't be
intervened by truncation.
  it also fixes a deadlock.  (g_glock vs pages locking order)
- uvm_vnp_setsize: modify v_size while holding v_interlock.

reviewed by Chuck Silvers.
2006-07-22 08:47:56 +00:00
ad 3029ac48c7 - Use the LWP cached credentials where sane.
- Minor cosmetic changes.
2006-07-21 16:48:45 +00:00
drochner ef8848c74a Introduce a UVM_KMF_EXEC flag for uvm_km_alloc() which enforces an
executable mapping. Up to now, only R+W was requested from pmap_kenter_pa.
On most CPUs, we get an executable mapping anyway, due to lack of
hardware support or due to lazyness in the pmap implementation. Only
alpha does obey VM_PROT_EXECUTE, afaics.
2006-07-05 14:26:42 +00:00
yamt d447115889 make amap use kmem_alloc, rather than malloc.
(ie. make it use kernel_map, rather than kmem_map.)
kmem_map is more restricted than kernel_map,
and there's no point for amap to use it.
2006-06-25 08:03:46 +00:00
yamt 9606b0accf uvm_swapin: process -> lwp in a comment. 2006-06-13 13:22:06 +00:00
christos 199372b21f prevent uninitialized variable. 2006-06-13 01:59:59 +00:00
christos 28bd7a84c0 Don't allocate > 1K on the stack. 2006-06-12 21:05:47 +00:00
kardel de4337ab21 merge FreeBSD timecounters from branch simonb-timecounters
- struct timeval time is gone
  time.tv_sec -> time_second
- struct timeval mono_time is gone
  mono_time.tv_sec -> time_uptime
- access to time via
	{get,}{micro,nano,bin}time()
	get* versions are fast but less precise
- support NTP nanokernel implementation (NTP API 4)
- further reading:
  Timecounter Paper: http://phk.freebsd.dk/pubs/timecounter.pdf
  NTP Nanokernel: http://www.eecis.udel.edu/~mills/ntp/html/kern.html
2006-06-07 22:33:33 +00:00
yamt c24f70bcad move wait points for kva from upper layers to vm_map. PR/33185 #1.
XXX there is a concern about interaction with kva fragmentation.
see: http://mail-index.NetBSD.org/tech-kern/2006/05/11/0000.html
2006-05-25 14:27:28 +00:00
yamt 1075c99d89 introduce macros, UAREA_TO_USER and USER_TO_UAREA,
to convert uarea VA into a pointer to struct user and vice versa,
so that MD code can change the layout in uarea.
2006-05-22 13:43:54 +00:00
elad b3e7e1b010 Better implementation of PaX MPROTECT, after looking some more into the
code and not trying to use temporary solutions.

Lots of comments and help from YAMAMOTO Takashi, also thanks to the PaX
author for being quick to recognize that something fishy's going on. :)

Hook up in mmap/vmcmd rather than (ugh!) uvm_map_protect().

Next time I suggest to commit a temporary solution just revoke my
commit bit.
2006-05-20 15:45:37 +00:00
yamt c876210968 UVM_MAPFLAG: add missing parens. 2006-05-19 15:08:14 +00:00
elad 04d63f90b5 Introduce PaX MPROTECT -- mprotect(2) restrictions used to strengthen
W^X mappings.

Disabled by default.

First proposed in:

	http://mail-index.netbsd.org/tech-security/2005/12/18/0000.html

More information in:

	http://pax.grsecurity.net/docs/mprotect.txt

Read relevant parts of options(4) and sysctl(3) before using!

Lots of thanks to the PaX author and Matt Thomas.
2006-05-16 00:08:24 +00:00
elad fc9422c9d9 integrate kauth. 2006-05-14 21:31:52 +00:00
yamt de6ea5711e - rename uvm_tree_sanity to uvm_map_check and add some
(non tree related) checks.
- remove treesanity_label.  instead, just panic if any corruption is detected.
2006-05-14 08:22:50 +00:00
yamt 37f3579cf8 - uvm_mapent_trymerge: don't forget to update hints.
- clear_hints: new function.
- uvm_map_replace: use clear_hints.  no functional change.
- add some assertions.
2006-05-14 08:21:36 +00:00
yamt be55e1f38a update first_free correctly. 2006-05-14 08:20:35 +00:00
christos 103d2f520c XXX: GCC uninitialized. 2006-05-14 05:30:31 +00:00
yamt 6957cc2e13 ubc_fault: use PMAP_CANFAIL. pointed by Jed Davis on tech-kern@. 2006-05-03 15:57:35 +00:00
yamt 38ae305f09 uvm_km_suballoc: consider kva overhead of "kmapent".
fixes PR/31275 (me) and PR/32287 (Christian Biere).
2006-05-03 14:12:01 +00:00
yamt 93127a7b4c amap_splitref: assert that origref->ar_amap is initialized
by caller beforehand.
2006-04-21 14:04:45 +00:00
yamt 0f4aad0236 - share some code between uvm_map_clip_end and uvm_map_clip_start.
- add a map entry sanity-check function, uvm_mapent_check().

discussed on source-changes@.
2006-04-21 14:03:01 +00:00
yamt c8d2679980 from Christian Ehrhardt:
* uvm_loanzero may call uvm_analloc which will return with anon->an_lock
  locked. This lock is never dropped by uvm_loanzero and AFAICS the caller
  doesn't drop it either.
2006-04-18 09:56:16 +00:00
yamt 4dec4ffdcb uvm_page_own: more assertions. 2006-04-13 08:33:18 +00:00
christos 14ac201ca2 Change previous to KASSERT per yamt's request. 2006-04-13 02:32:14 +00:00
yamt 047ff68ce8 ubc_fault: don't forget to clear PG_WANTED.
reported by Michael Lorenz on tech-kern@.
2006-04-13 02:17:42 +00:00
christos 7778288678 Coverity CID 762: Protect against NULL dereferencing entry->object.uvm_obj
like we do a few lines before. Maybe all the tests should be changed
to UVM_ET_ISOBJ(), or the macro should do it internally?
2006-04-13 01:11:08 +00:00
christos 3e31f5d682 Coverity CID 835: Check before dereferencing pg->uanon. 2006-04-13 01:05:17 +00:00
yamt 52a31ea140 uvm_pagermapin: nowait allocation for pagedaemon. 2006-04-11 09:29:40 +00:00
yamt c03e4d19d3 add assertions. 2006-04-11 09:28:14 +00:00
uebayasi c515049d02 Update comment to match reality (vm_physmemseg -> vm_physseg). 2006-04-06 07:18:23 +00:00
yamt 9f6a649d14 uvm_km_pgremove/uvm_km_pgremove_intrsafe: fix assertions. 2006-04-05 21:56:24 +00:00
christos 435a7d0d03 Coverity CID 2721: Avoid bitching for impossible cases, by adding KASSERT. 2006-04-05 19:49:28 +00:00
yamt 4038c2995b uvm_km_check_empty: fix an assertion. 2006-03-17 09:37:55 +00:00
drochner e10923fd37 -clean up the interface to uvm_fault: the "fault type" didn't serve
any purpose (done by a macro, so we don't save any cycles for now)
-kill vm_fault_t; it is not needed for real faults, and for simulated
 faults (wiring) it can be replaced by UVM internal flags
-remove <uvm/uvm_fault.h> from uvm_extern.h again
2006-03-15 18:09:25 +00:00
yamt ec5a93183a merge yamt-uio_vmspace branch.
- use vmspace rather than proc or lwp where appropriate.
  the latter is more natural to specify an address space.
  (and less likely to be abused for random purposes.)
- fix a swdmover race.
2006-03-01 12:38:10 +00:00
drochner 2d1a0b57b6 kill the "fault_type" argument to pager's pgo_fault() methods
it is never used
(and using it would comprise an abstraction violation imho)
2006-02-22 22:28:18 +00:00
bjh21 0638b201c9 Include page ownership information in the output of the DDB "show all pages"
command if UVM_PAGE_TRKOWN is enabled.
2006-02-22 22:20:56 +00:00
bjh21 ed2f09f139 Add a "show all pages" command to DDB which prints one line per physical
page in the system.  Useful for getting some idea where all your memory's
gone, at least on a sufficiently small system.
2006-02-19 18:52:29 +00:00
perry fbae48b901 Change "inline" back to "__inline" in .h files -- C99 is still too
new, and some apps compile things in C89 mode. C89 keywords stay.

As per core@.
2006-02-16 20:17:12 +00:00
yamt 9040ed946b - amap_copy: take a "flags" argument instead of booleans.
- add AMAP_COPY_NOMERGE flag, and use it for uvm_map_extract.
  PR/32806 from Julio M. Merino Vidal.
2006-02-15 14:06:45 +00:00
yamt f382834c1a share some code between uvmpd_scan_inactive and uvmpd_scan. 2006-02-14 15:06:27 +00:00
yamt 16f42c29a4 fix a compilation problem where PAGE_SHIFT is not a constant.
pointed by Chuck Silvers.
2006-02-14 02:28:21 +00:00
yamt e6e15660e2 remove an outdated comment. 2006-02-13 14:41:22 +00:00
yamt 62eb3a15e1 factor out swap clustering code. 2006-02-12 09:19:59 +00:00
yamt 2a89e06daa uvm_pageunwire: use uvm_pageactivate rather than a copy. 2006-02-12 09:19:27 +00:00
yamt a3af4c1530 remove the following options. no objections on tech-kern@.
UVM_PAGER_INLINE
	UVM_AMAP_INLINE
	UVM_PAGE_INLINE
	UVM_MAP_INLINE
2006-02-11 12:45:07 +00:00
simonb 8b00a8c689 Make a note that some counters should be 64-bit as they wrap far to
quickly.
2006-02-10 00:53:04 +00:00
yamt acb669a7cf handle "strange" filesystems like layered filesystems and tmpfs,
where pgo_get returns pages which don't belong to the uobj.
also fix an XXX in uvm_loananon and lock-unlock mismatch in uvm_loanuobj.

PR/28372, PR/32665 (Alan Barrett).
2006-01-31 14:11:25 +00:00
yamt 43ed84382c re-apply uvm_fault.c 1.104. fixes will follow. 2006-01-31 14:05:47 +00:00
yamt f03efb066e uvm_mremap: whitespace. 2006-01-31 14:03:53 +00:00
yamt 7fcddedf0b revert uvm_fault.c 1.104 for now. see PR/28372, PR/32665. 2006-01-30 11:50:17 +00:00
yamt f67f4b05f1 uvm_mremap: fix "easy cases". 2006-01-23 07:53:01 +00:00
matt 7db3afd210 Fix u_int64_t -> uint64_t stragglers. 2006-01-21 18:57:45 +00:00
yamt e8e7ab8637 implement compat_linux mremap. 2006-01-21 13:34:15 +00:00
yamt 651bed2a01 - uvm_fault: move a common code of 1B and 2B to a new function.
don't attempt to allocate anons with kernel_map locked.  PR/32543.
- amap_copy: add an assertion.
2006-01-21 13:13:07 +00:00
yamt 5865f6ed1d uvm_map_replace: remove a wrong comment. 2006-01-21 13:10:41 +00:00
chs 5570661cd8 in amap_alloc(), only put the amap on the list of amaps if we succeeded
in allocating it.
2006-01-18 17:03:36 +00:00
yamt b88fc0e1b7 make some debug statistics evcnt. 2006-01-15 08:31:31 +00:00
yamt 37dd42949a clean up uvm_map evcnt code. no functional changes. 2006-01-08 09:18:27 +00:00
yamt dc9b2af242 uvmpd_scan_inactive: when reactivating a page,
use pmap_is_referenced rather than pmap_clear_reference.
we don't need to clear the bit here as we'll do so when
moving pages back to inactive queue again.  pointed by Chuck Silvers.
2006-01-05 10:47:33 +00:00
yamt 690d424f28 - add simple functions to allocate/free a buffer for i/o.
- make bufpool static.
2006-01-04 10:13:05 +00:00
perry 3d4ed1fbc7 __inline__ -> inline 2005-12-24 23:41:33 +00:00
perry 0f0296d88a Remove leading __ from __(const|inline|signed|volatile) -- it is obsolete. 2005-12-24 20:45:08 +00:00