OpenBSD CVS

CVS log for src/sys/uvm/uvm_map.c


[BACK] Up to [local] / src / sys / uvm

Request diff between arbitrary revisions


Default branch: MAIN


Revision 1.328 / (download) - annotate - [select for diffs], Tue Apr 2 08:39:17 2024 UTC (2 months ago) by deraadt
Branch: MAIN
CVS Tags: HEAD
Changes since 1.327: +4 -85 lines
Diff to previous 1.327 (colored)

Delete the msyscall mechanism entirely, since mimmutable+pinsyscalls has
replaced it with a more strict mechanism, which happens to be lockless O(1)
rather than micro-lock O(1)+O(log N).  Also nop-out the sys_msyscall(2) guts,
but leave the syscall around for a bit longer so that people can build through
it, since ld.so(1) still wants to call it.

Revision 1.327 / (download) - annotate - [select for diffs], Wed Feb 21 03:28:29 2024 UTC (3 months, 1 week ago) by deraadt
Branch: MAIN
CVS Tags: OPENBSD_7_5_BASE, OPENBSD_7_5
Changes since 1.326: +9 -6 lines
Diff to previous 1.326 (colored)

Only return EPERM for immutable regions for the nasty operations
of madvise() and msync() which damaged the region.  The sync ones
are allowed to proceed (even if most of them are nops...)
based on issues noted by anton and semarie

Revision 1.326 / (download) - annotate - [select for diffs], Sun Jan 21 17:21:55 2024 UTC (4 months, 1 week ago) by deraadt
Branch: MAIN
Changes since 1.325: +3 -12 lines
Diff to previous 1.325 (colored)

workaround for the static non-PIE instbin "instbin" program on the install
media is no longer needed, due to fix in libc/dlfcn/init.c
thanks kettenis and gkoehler

Revision 1.325 / (download) - annotate - [select for diffs], Sun Jan 21 16:59:15 2024 UTC (4 months, 1 week ago) by deraadt
Branch: MAIN
Changes since 1.324: +3 -0 lines
Diff to previous 1.324 (colored)

For minherit(MAP_INHERIT_ZERO) upon readonly memory return EPERM.
ok kettenis

Revision 1.324 / (download) - annotate - [select for diffs], Sun Jan 21 16:57:06 2024 UTC (4 months, 1 week ago) by deraadt
Branch: MAIN
Changes since 1.323: +31 -5 lines
Diff to previous 1.323 (colored)

madvise(2) and msync(2) have some memory/mapping destructive ops which should
not be allowed upon immutable memory, instead return EPERM.
Some of these ops are not destructive in OpenBSD, but they are destructive
on other systems, so we take the "all ops" are illegal approach.

Related to this, it should not be allowed to minherit(MAP_INHERIT_ZERO)
immutable regions, or vice versa, calling mimmutable() upon MAP_INHERIT_ZERO
regions, because such a range will be zero'd post-fork in the child.
These now also return EPERM.

Adjusting the madvise / msync behaviour upon immutable memory brings us
closer to the behaviour of the mimmutable clone "mseal" being proposed by
google for inclusion in Linux.
ok kettenis

Revision 1.323 / (download) - annotate - [select for diffs], Sun Jan 21 00:26:14 2024 UTC (4 months, 1 week ago) by deraadt
Branch: MAIN
Changes since 1.322: +2 -2 lines
Diff to previous 1.322 (colored)

oops, brain scrambled trying to squeeze the ifdef into bad place

Revision 1.322 / (download) - annotate - [select for diffs], Sun Jan 21 00:23:29 2024 UTC (4 months, 1 week ago) by deraadt
Branch: MAIN
Changes since 1.321: +11 -2 lines
Diff to previous 1.321 (colored)

some bizzare glitch related to ramdisk instbin static binaries, their
mutable mapping is not working right, so temporarily bring back the
RW -> R *only* for ramdisk kernels

Revision 1.321 / (download) - annotate - [select for diffs], Sat Jan 20 13:19:39 2024 UTC (4 months, 1 week ago) by deraadt
Branch: MAIN
Changes since 1.320: +4 -11 lines
Diff to previous 1.320 (colored)

Early during mimmutable(2) development, we had a big problem with the
chrome v8_flags variable's placement in bss, and as a workaround made
it possible to demote a mimmutable mapping's permissions from RW to R.
Further mimmutable-related work in libc's malloc created the same
problem, which led to a better design: objects could be placed into
.openbsd.mutable region, and then at runtime their permission and
immutability could be manipulated better.  So the RW to R demotion
logic is no longer being used, and now this semantic is being deleted.
ok kettenis

Revision 1.320 / (download) - annotate - [select for diffs], Tue Jan 16 19:05:01 2024 UTC (4 months, 2 weeks ago) by deraadt
Branch: MAIN
Changes since 1.319: +5 -3 lines
Diff to previous 1.319 (colored)

The kernel will now read pinsyscall tables out of PT_OPENBSD_SYSCALLS in
the main program or ld.so, and accept a submission of that information
for libc.so from ld.so via pinsyscalls(2).  At system call invocation,
the syscall number is matched to the specific address it must come from.
ok kettenis, gnezdo, testing of variations by many people

Revision 1.319 / (download) - annotate - [select for diffs], Wed Aug 2 09:19:47 2023 UTC (10 months ago) by mpi
Branch: MAIN
CVS Tags: OPENBSD_7_4_BASE, OPENBSD_7_4
Changes since 1.318: +1 -28 lines
Diff to previous 1.318 (colored)

Remove unused vm_map_upgrade() & vm_map_downgrade().

Upgrade/downgrade operations on a `vmmaplk' are no longer necessary since
vm_map_busy() completely unlocks it (r1.318 of uvm/uvm_map.c).

ok kettenis@

Revision 1.318 / (download) - annotate - [select for diffs], Sat May 20 12:48:36 2023 UTC (12 months, 2 weeks ago) by mpi
Branch: MAIN
Changes since 1.317: +25 -27 lines
Diff to previous 1.317 (colored)

Do not grab the `vmmaplk' recursively, prevent a self-deadlock.

Change the semantic of vm_map_busy() to be able to completely unlock the
`vmmaplk' instead of downgrading it to a read lock in mlock(2).  This is
necessary because uvm_fault_wire() tries to re-grab the same lock.

We now keep track of the thread currently holding the vmmap busy to ensure
it can relock & unbusy the vmmap.  The new pattern becomes:

....vm_map_lock(map);
....vm_map_busy(map); /* prevent other threads to grab an exclusive lock */
....vm_map_unlock(map);
....
..../*
.... * Do some stuff generally requiring a tsleep(9).
.... */
....
....vm_map_lock(map);
....vm_map_unbusy(map); /* allow other threads to make progress after unlock */
....vm_map_unlock(map);

Fix adapted from NetBSD's r1.249 of uvm/uvm_map.c.  Issue reported by
Jacqueline Jolicoeur exposed by a "wallet refresh" of the Monero App.
Panic hand-copied below:

sleep_finish()
rw_enter()
uvmfault_lookup()
uvm_fault_check()
uvm_fault()
uvm_fault_wire()
uvm_map_pageable_wire()
sys_mlock()

This version skips bumping the map's timestamp if the lock is acquired by the
thread marked the VM map busy.  This prevents a KASSERT() reported by bluhm@
triggered by regress/misc/posixtestsuite conformance/interfaces/mmap/18-1

ok kettenis@

Revision 1.317 / (download) - annotate - [select for diffs], Wed Apr 26 12:25:12 2023 UTC (13 months, 1 week ago) by bluhm
Branch: MAIN
Changes since 1.316: +26 -23 lines
Diff to previous 1.316 (colored)

Backout previous commit:
Do not grab the `vmmaplk' recursively, prevent a self-deadlock.
It causes panic: uvm_map_pageable_wire: stale map
Found by regress/misc/posixtestsuite conformance/interfaces/mmap/18-1
requested by deraadt@

Revision 1.316 / (download) - annotate - [select for diffs], Tue Apr 25 12:36:30 2023 UTC (13 months, 1 week ago) by mpi
Branch: MAIN
Changes since 1.315: +23 -26 lines
Diff to previous 1.315 (colored)

Do not grab the `vmmaplk' recursively, prevent a self-deadlock.

Change the semantic of vm_map_busy() to be able to completely unlock the
`vmmaplk' instead of downgrading it to a read lock in mlock(2).  This is
necessary because uvm_fault_wire() tries to re-grab the same lock.

We now keep track of the thread currently holding the vmmap busy to ensure
it can relock & unbusy the vmmap.  The new pattern becomes:

....vm_map_lock(map);
....vm_map_busy(map); /* prevent other threads to grab an exclusive lock */
....vm_map_unlock(map);
....
..../*
.... * Do some stuff generally requiring a tsleep(9).
.... */
....
....vm_map_lock(map);
....vm_map_unbusy(map); /* allow other threads to make progress after unlock */
....vm_map_unlock(map);

Fix adapted from NetBSD's r1.249 of uvm/uvm_map.c.  Issue reported by
Jacqueline Jolicoeur exposed by a "wallet refresh" of the Monero App.
Panic hand-copied below:

sleep_finish()
rw_enter()
uvmfault_lookup()
uvm_fault_check()
uvm_fault()
uvm_fault_wire()
uvm_map_pageable_wire()
sys_mlock()

ok kettenis@

Revision 1.315 / (download) - annotate - [select for diffs], Thu Apr 13 15:23:23 2023 UTC (13 months, 2 weeks ago) by miod
Branch: MAIN
Changes since 1.314: +2 -34 lines
Diff to previous 1.314 (colored)

pmap_copy() has never, ever, been implemented in any of the platforms OpenBSD
ever ran on, and it's unlikely to ever be implemented, so remove it.
ok jsg@

Revision 1.314 / (download) - annotate - [select for diffs], Mon Apr 10 04:21:20 2023 UTC (13 months, 3 weeks ago) by jsg
Branch: MAIN
Changes since 1.313: +4 -4 lines
Diff to previous 1.313 (colored)

spelling

Revision 1.313 / (download) - annotate - [select for diffs], Fri Feb 24 15:17:48 2023 UTC (15 months, 1 week ago) by mpi
Branch: MAIN
CVS Tags: OPENBSD_7_3_BASE, OPENBSD_7_3
Changes since 1.312: +8 -7 lines
Diff to previous 1.312 (colored)

Do not held the vm_map lock while flushing pages in msync(2) and madvise(2).

Mark the VM map as busy instead to prevent any sibling thread to request an
exclusive version of the vm_map.  This is necessary to let any PG_BUSY page,
found in the UVM vnode object, to be released by a sibling in the middle of
a page-fault.

Note: the page-fault handler releases & re-grab a shared version of the
vm_map lock and expect it to be available to make progress.

Prevent a 3-Threads deadlock between msync(2), page-fault and mmap(2).  The
deadlock reported on bugs@ by many occured as follow:

..ThreadA faults & grabs the shared `vmmaplk' then release it before calling
..uvn_get() which might sleep to allocate pages and mark them as PG_BUSY.

..Once the lock is released, threadB calls uvn_flush().  It sees at least a
..PG_BUSY page and sleeps on the `vmmaplk' waiting for threadA to un-busy
..the page.

..At the same time threadC asked for an exclusive version of the lock and
..sleeps until all reader are done with it.  This prevents threadA to
..acquire a shared-version of the lock and finish the page fault.

This issue is similar to NetBSD's PR #56952 and the fix is from Chuck Silvers.

Tested by many on bugs@, thanks!

ok kettenis@

Revision 1.312 / (download) - annotate - [select for diffs], Mon Feb 13 14:52:55 2023 UTC (15 months, 2 weeks ago) by deraadt
Branch: MAIN
Changes since 1.311: +4 -1 lines
Diff to previous 1.311 (colored)

Also lock the map in the execve-driven calls to uvm_map_check_copyin_add()
ok kettenis

Revision 1.311 / (download) - annotate - [select for diffs], Mon Feb 13 14:51:49 2023 UTC (15 months, 2 weeks ago) by deraadt
Branch: MAIN
Changes since 1.310: +9 -1 lines
Diff to previous 1.310 (colored)

Upon fork, copy the copyin_check structure to the new map, otherwise
the xonly rules are not applied a child.  This was due to the same
misunderstanding as with msyscall a few days ago.
ok guenther kettenis

Revision 1.310 / (download) - annotate - [select for diffs], Sat Feb 11 21:11:37 2023 UTC (15 months, 2 weeks ago) by deraadt
Branch: MAIN
Changes since 1.309: +2 -1 lines
Diff to previous 1.309 (colored)

I forgot to copy the msyscall interlock flag to forked processes, so
only freshly executed processes were actually locked.  (This happened
because I didn't realize how the uvm_map's contents are copied entry
by entry, and other parts are not)
ok kettenis

Revision 1.309 / (download) - annotate - [select for diffs], Tue Jan 31 15:18:55 2023 UTC (16 months ago) by deraadt
Branch: MAIN
Changes since 1.308: +40 -1 lines
Diff to previous 1.308 (colored)

On systems without xonly mmu hardware-enforcement, we can still mitigate
against classic BROP with a range-checking wrapper in front of copyin() and
copyinstr() which ensures the userland source doesn't overlap the main program
text, ld.so text, signal tramp text (it's mapping is hard to distinguish
so it comes along for the ride), or libc.so text.  ld.so tells the kernel
libc.so text range with msyscall(2).  The range checking for 2-4 elements is
done without locking (because all 4 ranges are immutable!) and is inexpensive.

write(sock, &open, 400) now fails with EFAULT.  No programs have been
discovered which require reading their own text segments with a system call.

On a machine without mmu enforcement, a test program reports the following:
                  userland   kernel
ld.so             readable   unreadable
mmap xz           unreadable unreadable
mmap x            readable   readable
mmap nrx          readable   readable
mmap nwx          readable   readable
mmap xnwx         readable   readable
main              readable   unreadable
libc unmapped?    readable   unreadable
libc mapped       readable   unreadable

ok kettenis, additional help from miod

Revision 1.308 / (download) - annotate - [select for diffs], Wed Jan 25 23:42:03 2023 UTC (16 months ago) by deraadt
Branch: MAIN
Changes since 1.307: +6 -3 lines
Diff to previous 1.307 (colored)

In the previous commit, FIXPROT would upgrade a PROT_NONE mapping too far.
Correct the logic, still blocking PROT_EXEC
ok anton kettenis

Revision 1.307 / (download) - annotate - [select for diffs], Tue Jan 24 00:16:08 2023 UTC (16 months, 1 week ago) by deraadt
Branch: MAIN
Changes since 1.306: +2 -2 lines
Diff to previous 1.306 (colored)

oops, a silly typo

Revision 1.306 / (download) - annotate - [select for diffs], Tue Jan 24 00:14:30 2023 UTC (16 months, 1 week ago) by deraadt
Branch: MAIN
Changes since 1.305: +3 -2 lines
Diff to previous 1.305 (colored)

uvm_map_extract() UVM_EXTRACT_FIXPROT alias mappings are only used for
read/write operations, so mask out PROT_EXEC to avoid creating an pointless
exec mapping in the kernel.
We probably need this masking upon minprot (for the non-UVM_EXTRACT_FIXPROT
case) also, but I haven't done a test yet.
ok kettenis

Revision 1.305 / (download) - annotate - [select for diffs], Sun Dec 18 23:41:17 2022 UTC (17 months, 2 weeks ago) by deraadt
Branch: MAIN
Changes since 1.304: +2 -2 lines
Diff to previous 1.304 (colored)

spelling

Revision 1.304 / (download) - annotate - [select for diffs], Thu Nov 17 18:53:05 2022 UTC (18 months, 2 weeks ago) by deraadt
Branch: MAIN
Changes since 1.303: +11 -2 lines
Diff to previous 1.303 (colored)

stack growth from setrlimit was never updated to set UVM_ET_STACK on
the entries, so the check-sp-at-system-call check failed.  Quite strange
it took this long to find this.
ok kettenis

Revision 1.303 / (download) - annotate - [select for diffs], Fri Nov 4 09:36:44 2022 UTC (18 months, 4 weeks ago) by mpi
Branch: MAIN
Changes since 1.302: +46 -5 lines
Diff to previous 1.302 (colored)

Assert the VM map lock is held in function used by mmap/mprotect/munmap.

Also grab the lock in uvm_map_teardown() and uvm_map_deallocate() to
satisfy the assertions.  Grabbing the lock there shouldn't be strictly
necessary, because no other reference to the map should exist when the
reaper is holding it, but it doesn't hurt and makes our life easier.

Inputs & tests from Ivo van der Sangen, tb@, gnezdo@, kn@

kettenis@ and tb@ agree with the direction, ok kn@

Revision 1.302 / (download) - annotate - [select for diffs], Mon Oct 31 10:46:24 2022 UTC (19 months ago) by mpi
Branch: MAIN
Changes since 1.301: +3 -3 lines
Diff to previous 1.301 (colored)

Fix VMMAP_DEBUG code to compile with not-so-recent changes.

If enabled the debug code currently panic the kernel.  To investigate.

Revision 1.301 / (download) - annotate - [select for diffs], Mon Oct 24 15:11:56 2022 UTC (19 months, 1 week ago) by deraadt
Branch: MAIN
Changes since 1.300: +7 -6 lines
Diff to previous 1.300 (colored)

uvm_unmap_remove() traverses the entries in the start,end range scanning
for IMMUTABLE, before traversing for unmap.  I didn't copy enough traversal
code for the scan, and thus MAP_FIXED was subtly broken.
test help from tb, ok kettenis miod

Revision 1.300 / (download) - annotate - [select for diffs], Fri Oct 21 20:45:51 2022 UTC (19 months, 1 week ago) by deraadt
Branch: MAIN
Changes since 1.299: +13 -3 lines
Diff to previous 1.299 (colored)

Recent chrome renderers try to change some immutable RW region to R.
I really want immutable to not allow such transitions either, because it will
help bring code up to the highest standard.
For now, allow this for all processes, until we find out the underlying
reason.

Revision 1.299 / (download) - annotate - [select for diffs], Fri Oct 21 19:13:32 2022 UTC (19 months, 1 week ago) by deraadt
Branch: MAIN
Changes since 1.298: +2 -2 lines
Diff to previous 1.298 (colored)

the debug "name" parameter to uvm_map_immutable() is no longer needed

Revision 1.298 / (download) - annotate - [select for diffs], Sun Oct 16 16:16:37 2022 UTC (19 months, 2 weeks ago) by deraadt
Branch: MAIN
Changes since 1.297: +76 -55 lines
Diff to previous 1.297 (colored)

Rather than marking MAP_STACK on entries for sigaltstack() [2 days ago],
go back to the old approach: using a new anon mapping because it removes
any potential gadgetry pre-placed in the region (by making it zero).  But
also bring in a few more validation checks beyond contigious mapping -- it
must not be a syscall region, and the protection must be precisely RW.
This does allow sigaltstack() to shoot zero'd MAP_STACK non-immutable regions
into the main stack area (which will soon be immutable).  I am not sure we
can keep reinforce immutable on the region after we do stack (like maybe
determine this while doing the validation entry walk?)
Sadly, continued support for sigaltstack() does require selecting the guessed
best compromise.
ok kettenis

Revision 1.297 / (download) - annotate - [select for diffs], Sat Oct 15 05:56:01 2022 UTC (19 months, 2 weeks ago) by deraadt
Branch: MAIN
Changes since 1.296: +1 -3 lines
Diff to previous 1.296 (colored)

remove one of the debug messages

Revision 1.296 / (download) - annotate - [select for diffs], Sat Oct 15 03:23:50 2022 UTC (19 months, 2 weeks ago) by deraadt
Branch: MAIN
Changes since 1.295: +58 -61 lines
Diff to previous 1.295 (colored)

During the MAP_STACK introduction in 2018, sigaltstack() became a
problem because haphazard use could shoot holes in the address space
(changing permissions, providing opportunities for pivoting, etc). I
tried to write a diff to convert the address space correctly but did
not understand enough about map entries, so instead we mapped new
memory over top of the existing object.  Placing a new mapping becomes
unfeasible with the upcoming mimmutable model, so here is code that
adds MAP_STACK to the region.  It will only do so for a contigiously
mapped region that is non-syscall with permission RW, otherwise it
returns an error.
Food for thought: If we know the object isn't service by an object,
we should consider zero'ing the region, to block pre-pivot placement?
ok kettenis

Revision 1.295 / (download) - annotate - [select for diffs], Fri Oct 7 14:59:39 2022 UTC (19 months, 3 weeks ago) by deraadt
Branch: MAIN
Changes since 1.294: +80 -13 lines
Diff to previous 1.294 (colored)

Add mimmutable(2) system call which locks the permissions (PROT_*) of
memory mappings so they cannot be changed by a later mmap(), mprotect(),
or munmap(), which will error with EPERM instead.
ok kettenis

Revision 1.294 / (download) - annotate - [select for diffs], Mon Aug 15 15:53:45 2022 UTC (21 months, 2 weeks ago) by jsg
Branch: MAIN
CVS Tags: OPENBSD_7_2_BASE, OPENBSD_7_2
Changes since 1.293: +1 -33 lines
Diff to previous 1.293 (colored)

remove FSPACE macros, unused after uvm_map_sel_limits() removal

Revision 1.293 / (download) - annotate - [select for diffs], Mon Aug 15 03:12:12 2022 UTC (21 months, 2 weeks ago) by jsg
Branch: MAIN
Changes since 1.292: +1 -208 lines
Diff to previous 1.292 (colored)

remove unused uvm_map_sel_limits()
ok miod@ millert@

Revision 1.292 / (download) - annotate - [select for diffs], Sun Aug 7 19:39:25 2022 UTC (21 months, 3 weeks ago) by miod
Branch: MAIN
Changes since 1.291: +1 -10 lines
Diff to previous 1.291 (colored)

Move fallback PMAP_PREFER definitions from uvm_map.c to uvm_pmap.h for them
to be available to other files. NFC

ok kettenis@ mpi@

Revision 1.291 / (download) - annotate - [select for diffs], Wed May 4 14:58:26 2022 UTC (2 years ago) by mpi
Branch: MAIN
Changes since 1.290: +2 -3 lines
Diff to previous 1.290 (colored)

Merge swap-backed and object-backed inactive page lists.

ok millert@, kettenis@

Revision 1.290 / (download) - annotate - [select for diffs], Sat Mar 12 08:11:07 2022 UTC (2 years, 2 months ago) by mpi
Branch: MAIN
CVS Tags: OPENBSD_7_1_BASE, OPENBSD_7_1
Changes since 1.289: +4 -14 lines
Diff to previous 1.289 (colored)

Revert holding a read lock on the map while copying out data during sysctl(2).

This introduced a lock ordering issue reported by naddy@, anton@ and syzkaller.

Reported-by: syzbot+739bb901045d9b193bde@syzkaller.appspotmail.com

Revision 1.289 / (download) - annotate - [select for diffs], Fri Mar 11 19:24:19 2022 UTC (2 years, 2 months ago) by kettenis
Branch: MAIN
Changes since 1.288: +15 -5 lines
Diff to previous 1.288 (colored)

Hold a read lock on the map while copying out data during a sysctl(2) call
to prevent another thread from unmapping the memory and triggering
an assertion or even corrupting random physical memory pages.

This fix is similar to the change in uvm_glue.c rev. 1.74.  However in this
case we need to be careful since some sysctl(2) calls look at the map of
the current process.  In those cases we must not attempt to lock the map
again.

ok mpi@

Should fix:
Reported-by: syzbot+be89fe83d6c004fcb412@syzkaller.appspotmail.com

Revision 1.288 / (download) - annotate - [select for diffs], Tue Feb 15 11:54:19 2022 UTC (2 years, 3 months ago) by kn
Branch: MAIN
Changes since 1.287: +0 -2 lines
Diff to previous 1.287 (colored)

Backout previous "Unwire with map lock held" (commitid: SsVz7dLGFgR21kFe)

The (known) lock order reversals which now occur more reliably and much
earlier on WITNESS boots with this diff knock out syzcaller reports since
syzcaller stops at the first "crash report":
https://syzkaller.appspot.com/bug?id=81b39e970cd2eb21b97d1b31746c693e300fd2dd

Revision 1.287 / (download) - annotate - [select for diffs], Mon Feb 14 21:11:02 2022 UTC (2 years, 3 months ago) by kn
Branch: MAIN
Changes since 1.286: +3 -1 lines
Diff to previous 1.286 (colored)

Unwire with map lock held

This is an updated version of uvm_map.c r1.283 "Unwire with map lock held".

The previous version introduced a use-after-free by not unlocking vm_map
locks in uvm_map_teardown(), resulting in dangling references on the
reaper's lock list (thanks visa!).

Lock and unlock the map in around uvm_map_teardown() instead.
This code path holds the last reference, hence the lock isn't strictly
needed except for satisfying upcoming locking assertions.

Tested on amd64, arm64, i386, macppc, octeon, sparc64.
This time also with WITNESS enabled (except on sparc64 which builds but does
not boot with WITNESS;  this is a known issue).

OK mpi visa

Revision 1.286 / (download) - annotate - [select for diffs], Fri Feb 11 12:06:48 2022 UTC (2 years, 3 months ago) by kn
Branch: MAIN
Changes since 1.285: +1 -2 lines
Diff to previous 1.285 (colored)

Backout previous "Unwire with map lock held" (commitid: eQBvWUwShD91dN9Z)

WITNESS builds broke^W^Wkernels panic on boot as reported by anton and bluhm.
Booting bsd.mp in single-user mode inside VMM shows:

root on sd0a (5f9e458ed30b39ab.a) swap on sd0b dump on sd0b
Enter pathname of shell or RETURN for sh:
witness: lock order reversal:
 1st 0xfffffd801f8ce468 vmmaplk (&map->lock)
 2nd 0xfffffd801b8162c0 inode (&ip->i_lock)
lock order "&ip->i_lock"(rrwlock) -> "&map->lock"(rwlock) first seen at:
#0  rw_enter_read+0x38
#1  uvmfault_lookup+0x8a
#2  uvm_fault_check+0x32
#3  uvm_fault+0xfb
#4  kpageflttrap+0x12c
#5  kerntrap+0x91
#6  alltraps_kern_meltdown+0x7b
#7  copyout+0x53
#8  ffs_read+0x1f6
#9  VOP_READ+0x41
#10 vn_rdwr+0xa1
#11 vmcmd_map_readvn+0xa0
#12 exec_process_vmcmds+0x88
#13 sys_execve+0x732
#14 start_init+0x26f
#15 proc_trampoline+0x1c
lock order data w1 -> w2 missing
# exit
kernel: protection fault trap, code=0
Stopped at      witness_checkorder+0x312:       movl    0x10(%r14),%ecx

gkoehler reported faults on poisened addresses on macppc dual G5.

Revision 1.285 / (download) - annotate - [select for diffs], Fri Feb 11 09:25:04 2022 UTC (2 years, 3 months ago) by kn
Branch: MAIN
Changes since 1.284: +7 -82 lines
Diff to previous 1.284 (colored)

Backout previous "Assert vm map locks" (commitid: sRNBfzX2dJrxFDmb)

WITNESS builds broke as reported by anton and bluhm:

	root on sd0a (5ec49b3ad23eb2d4.a) swap on sd0b dump on sd0b
	kernel: protection fault trap, code=0
	Stopped at      witness_checkorder+0x4ec:       movl    0x10(%r12),%ecx

https://syzkaller.appspot.com/bug?id=be02b290a93c648986c35370a271aad4135a5044
https://syzkaller.appspot.com/text?tag=CrashLog&x=136e9aa4700000

Revision 1.284 / (download) - annotate - [select for diffs], Thu Feb 10 10:15:35 2022 UTC (2 years, 3 months ago) by kn
Branch: MAIN
Changes since 1.283: +83 -8 lines
Diff to previous 1.283 (colored)

Assert vm map locks

Introduce vm_map_assert_{wrlock,rdlock,anylock,unlocked}() in rwlock(9)
fashion and back up function comments about locking assumptions with proper
assertions.

Also add new comments/assertions based on code analysis and sync with
NetBSD as much as possible.

vm_map_lock() and vm_map_lock_read() are used for exclusive and shared
access respectively;  currently no code path is purely protected by
vm_map_lock_read() alone, i.e. functions called with a read lock held by the
callee are also called with a write lock elsewhere.

Thus only vm_map_assert_{wrlock,anylock}() are used as of now.

This should help with unlocking UVM related syscalls

Tested as part of a larger diff through
- amd64 package bulk build by naddy
- amd64, arm64, powerpc64 base builds and regress by bluhm
- amd64 and sparc64 base builds and regress by me

Input mpi
Feedback OK kettenis

Revision 1.283 / (download) - annotate - [select for diffs], Thu Feb 10 10:14:02 2022 UTC (2 years, 3 months ago) by kn
Branch: MAIN
Changes since 1.282: +2 -1 lines
Diff to previous 1.282 (colored)

Unwire with map lock held

uvm_unmap_remove() effectively requires its caller to lock the vm map.

Even though uvm_map_teardown() is only called after a map's last reference
is dropped and is thus safe from other threads accessing the map, grab the
map's lock in uvm_map_teardown() to satify upcoming lock assertions in
uvm_unmap_remove().

Tested as part of a larger diff through
- amd64 package bulk builds by naddy
- amd64, arm64, powerpc64 base builds and regress by bluhm
- amd64 and sparc64 base builds and regress by me

Feedback mpi
OK kettenis

Revision 1.282 / (download) - annotate - [select for diffs], Tue Dec 21 22:21:32 2021 UTC (2 years, 5 months ago) by mpi
Branch: MAIN
Changes since 1.281: +2 -2 lines
Diff to previous 1.281 (colored)

Fix a typo in mlock(2) error path triggering a double-free.

Pass the correct entry to uvm_fault_unwire_locked().

Reported-by: syzbot+bb2f63f076618e9ed0d3@syzkaller.appspotmail.com

ok kettenis@, deraadt@

Revision 1.281 / (download) - annotate - [select for diffs], Wed Dec 15 12:53:53 2021 UTC (2 years, 5 months ago) by mpi
Branch: MAIN
Changes since 1.280: +46 -10 lines
Diff to previous 1.280 (colored)

Use a per-UVM object lock to serialize the lower part of the fault handler.

Like the per-amap lock the `vmobjlock' is principally used to serialized
access to objects in the fault handler to allow faults occurring on
different CPUs and different objects to be processed in parallel.

The fault handler now acquires the `vmobjlock' of a given UVM object as
soon as it finds one.  For now a write-lock is always acquired even if
some operations could use a read-lock.

Every pager, corresponding to a different kind of UVM object, now expect
the UVM object to be locked and some operations, like *_get() return it
unlocked.  This is enforced by assertions checking for rw_write_held().

The KERNEL_LOCK() is now pushed to the VFS boundary in the vnode pager.

To ensure the correct amap or object lock is held when modifying a page
many uvm_page* operations are now asserting for the "owner" lock.
However, fields of the "struct vm_page" are still being protected by the
global `pageqlock'.  To prevent lock ordering issues with the new
`vmobjlock' and to reduce differences with NetBSD this lock is now taken
and released for each page instead of around the whole loop.

This commit does not remove the KERNEL_LOCK/UNLOCK() dance.  Unlocking
will follow if there is no fallout.

Ported from NetBSD, tested by many, thanks!

ok kettenis@, kn@

Revision 1.280 / (download) - annotate - [select for diffs], Tue Dec 7 18:30:26 2021 UTC (2 years, 5 months ago) by deraadt
Branch: MAIN
Changes since 1.279: +2 -2 lines
Diff to previous 1.279 (colored)

uvm_map_inentry() is provided a format string that says "inside", but then
prints the end which is in the next page.  Subtract 1 to avoid confusion.

Revision 1.279 / (download) - annotate - [select for diffs], Sun Oct 24 15:23:52 2021 UTC (2 years, 7 months ago) by mpi
Branch: MAIN
Changes since 1.278: +4 -6 lines
Diff to previous 1.278 (colored)

Move pmap_{,k}remove() inside uvm_km_pgremove{,_intrsafe}().

Reduce differences with NetBSD, tested by many as part of a larger diff.

ok kettenis@

Revision 1.278 / (download) - annotate - [select for diffs], Tue Oct 5 15:37:21 2021 UTC (2 years, 7 months ago) by mpi
Branch: MAIN
Changes since 1.277: +9 -10 lines
Diff to previous 1.277 (colored)

Unref/free amaps before grabbing the KERNEL_LOCK().

This is possible now that amaps & anons are protected by a per-map rwlock.

Tested by many as part of a bigger diff.

ok kettenis@

Revision 1.277 / (download) - annotate - [select for diffs], Thu Jun 17 16:10:39 2021 UTC (2 years, 11 months ago) by mpi
Branch: MAIN
CVS Tags: OPENBSD_7_0_BASE, OPENBSD_7_0
Changes since 1.276: +9 -9 lines
Diff to previous 1.276 (colored)

Revert previous: unref of amap outside of the KERNEL_LOCK().

This change introduced or exposed a leak of anons which result in system
freezes.

anton@ observed a high number of INUSE for anonpl and semarie@ saw multiple
processes waiting in the fault handler on "flt_noramX" probably the one
related to allocating an anon.

Revision 1.276 / (download) - annotate - [select for diffs], Tue Jun 15 16:35:21 2021 UTC (2 years, 11 months ago) by mpi
Branch: MAIN
Changes since 1.275: +9 -9 lines
Diff to previous 1.275 (colored)

Unref/free amaps before grabbing the KERNEL_LOCK().

This is possible now that amaps & anons are protected by a per-map rwlock.

ok kettenis@, jmatthew@

Revision 1.275 / (download) - annotate - [select for diffs], Sat May 22 08:38:29 2021 UTC (3 years ago) by mpi
Branch: MAIN
Changes since 1.274: +8 -7 lines
Diff to previous 1.274 (colored)

Use atomic operations for reference counting VM maps.

This is necessary to do this accounting without the KERNEL_LOCK().

ok mvs@, kettenis@

Revision 1.274 / (download) - annotate - [select for diffs], Fri Mar 26 13:40:05 2021 UTC (3 years, 2 months ago) by mpi
Branch: MAIN
CVS Tags: OPENBSD_6_9_BASE, OPENBSD_6_9
Changes since 1.273: +5 -5 lines
Diff to previous 1.273 (colored)

Remove parenthesis around return value to reduce the diff with NetBSD.

No functional change.

ok mlarkin@

Revision 1.273 / (download) - annotate - [select for diffs], Fri Mar 12 14:15:49 2021 UTC (3 years, 2 months ago) by jsg
Branch: MAIN
Changes since 1.272: +4 -4 lines
Diff to previous 1.272 (colored)

spelling

ok mpi@

Revision 1.272 / (download) - annotate - [select for diffs], Fri Mar 5 05:30:44 2021 UTC (3 years, 2 months ago) by jsg
Branch: MAIN
Changes since 1.271: +5 -9 lines
Diff to previous 1.271 (colored)

ansi

Revision 1.271 / (download) - annotate - [select for diffs], Tue Feb 23 11:22:20 2021 UTC (3 years, 3 months ago) by jsg
Branch: MAIN
Changes since 1.270: +1 -35 lines
Diff to previous 1.270 (colored)

remove unused uvm_mapent_bias()

ok mpi@

Revision 1.270 / (download) - annotate - [select for diffs], Tue Jan 19 13:21:36 2021 UTC (3 years, 4 months ago) by mpi
Branch: MAIN
Changes since 1.269: +4 -5 lines
Diff to previous 1.269 (colored)

(re)Introduce locking for amaps & anons.

A rwlock is attached to every amap and is shared with all its anon.  The
same lock will be used by multiple amaps if they have anons in common.

This should be enough to get the upper part of the fault handler out of the
KERNEL_LOCK() which seems to bring up to 20% improvements in builds.

This is based/copied/adapted from the most recent work done in NetBSD which
is an evolution of the precendent simple_lock scheme.

Tested by many, thanks!

ok kettenis@, mvs@

Revision 1.269 / (download) - annotate - [select for diffs], Mon Oct 19 08:19:46 2020 UTC (3 years, 7 months ago) by mpi
Branch: MAIN
Changes since 1.268: +16 -5 lines
Diff to previous 1.268 (colored)

Serialize accesses to "struct vmspace" and document its refcounting.

The underlying vm_space lock is used as a substitute to the KERNEL_LOCK()
in uvm_grow() to make sure `vm_ssize' is not corrupted.

ok anton@, kettenis@

Revision 1.268 / (download) - annotate - [select for diffs], Tue Sep 22 14:31:08 2020 UTC (3 years, 8 months ago) by mpi
Branch: MAIN
CVS Tags: OPENBSD_6_8_BASE, OPENBSD_6_8
Changes since 1.267: +6 -6 lines
Diff to previous 1.267 (colored)

Spell inline correctly.

Reduce differences with NetBSD.

ok mvs@, kettenis@

Revision 1.267 / (download) - annotate - [select for diffs], Mon Sep 14 20:31:09 2020 UTC (3 years, 8 months ago) by kettenis
Branch: MAIN
Changes since 1.266: +3 -3 lines
Diff to previous 1.266 (colored)

Since the issues with calling uvm_map_inentry_fix() without holding the
kernel lock are fixed now, push the kernel lock down again.

ok deraadt@

Revision 1.266 / (download) - annotate - [select for diffs], Sat Sep 12 17:08:50 2020 UTC (3 years, 8 months ago) by mpi
Branch: MAIN
Changes since 1.265: +8 -1 lines
Diff to previous 1.265 (colored)

Add tracepoints in the page fault handler and when entries are added to maps.

ok kettenis@

Revision 1.265 / (download) - annotate - [select for diffs], Mon Jul 6 19:22:40 2020 UTC (3 years, 10 months ago) by deraadt
Branch: MAIN
Changes since 1.264: +2 -2 lines
Diff to previous 1.264 (colored)

fix spelling

Revision 1.264 / (download) - annotate - [select for diffs], Wed Mar 25 14:55:14 2020 UTC (4 years, 2 months ago) by mpi
Branch: MAIN
CVS Tags: OPENBSD_6_7_BASE, OPENBSD_6_7
Changes since 1.263: +2 -5 lines
Diff to previous 1.263 (colored)

Do not test against NULL a variable which is dereference before that.

CID 1453116

ok kettenis@

Revision 1.263 / (download) - annotate - [select for diffs], Wed Mar 4 21:15:38 2020 UTC (4 years, 2 months ago) by kettenis
Branch: MAIN
Changes since 1.262: +44 -5 lines
Diff to previous 1.262 (colored)

Do not count pages mapped as PROT_NONE against the RLIMIT_DATA limit.
Instead count (and check the limit) when their protection gets flipped
from PROT_NONE to something that permits access.  This means that
mprotect(2) may now fail if changing the protection would exceed RLIMIT_DATA.

This helps code (such as Chromium's JavaScript interpreter that reserves
large chunks of address space but populates it sparsely.

ok deraadt@, otto@, kurt@, millert@, robert@

Revision 1.262 / (download) - annotate - [select for diffs], Mon Dec 30 23:58:38 2019 UTC (4 years, 5 months ago) by jsg
Branch: MAIN
Changes since 1.261: +3 -3 lines
Diff to previous 1.261 (colored)

convert infinite msleep(9) to msleep_nsec(9)

ok mpi@

Revision 1.261 / (download) - annotate - [select for diffs], Wed Dec 18 13:33:29 2019 UTC (4 years, 5 months ago) by visa
Branch: MAIN
Changes since 1.260: +6 -6 lines
Diff to previous 1.260 (colored)

Set vm_map's pmap in uvm_map_setup().

OK guenther@, kettenis@, mpi@

Revision 1.260 / (download) - annotate - [select for diffs], Wed Dec 18 08:53:29 2019 UTC (4 years, 5 months ago) by kettenis
Branch: MAIN
Changes since 1.259: +5 -2 lines
Diff to previous 1.259 (colored)

Use separate rwlock initializations for userland ("vmspace") and kernel
maps.  This lets witness know that these really are different classes
avoiding false positives when detecting lock order reversals.

ok guenther@, visa@, mpi@

Revision 1.259 / (download) - annotate - [select for diffs], Thu Dec 12 11:12:36 2019 UTC (4 years, 5 months ago) by mpi
Branch: MAIN
Changes since 1.258: +9 -2 lines
Diff to previous 1.258 (colored)

Header cleanup.

- reduces gratuitous differences with NetBSD,
- merges multiple '#ifdef _KERNEL' blocks,
- kills unused 'struct vm_map_intrsafe'
- turns 'union vm_map_object' into a anonymous union (following to NetBSD)
- move questionable vm_map_modflags() into uvm/uvm_map.c
- remove guards around MAX_KMAPENT, it is defined&used only once
- document lock differences
- fix tab vs space

ok mlarkin@, visa@

Revision 1.258 / (download) - annotate - [select for diffs], Mon Dec 9 17:37:59 2019 UTC (4 years, 5 months ago) by deraadt
Branch: MAIN
Changes since 1.257: +3 -3 lines
Diff to previous 1.257 (colored)

Many people have crossed the ABI, so re-enable "syscall call-from" checking.

Revision 1.257 / (download) - annotate - [select for diffs], Mon Dec 9 16:13:07 2019 UTC (4 years, 5 months ago) by deraadt
Branch: MAIN
Changes since 1.256: +5 -3 lines
Diff to previous 1.256 (colored)

improve comment for uvm_map_inentry_pc(), the underlying
non-writeable / syscall checker.

Revision 1.256 / (download) - annotate - [select for diffs], Wed Dec 4 08:28:29 2019 UTC (4 years, 5 months ago) by mlarkin
Branch: MAIN
Changes since 1.255: +22 -12 lines
Diff to previous 1.255 (colored)

Fix a bad offset calculation in uvm_share.

Syzkaller found a bug in uvm_share when using a vmd(8) mmap region with
an offset that ended up making an overlap with a previous vmm(4) uvm_map
range.

This diff reworks the range and offset calculation in uvm_share. Only
vmm(4) uses this, so there should be no visible effects outside vmm(4)
environments.

Syzkaller also went sorta crazy on this one, finding multiple reproducers
for the same bug with just slightly different parameters, thus the
multiple "Reported-by" lines below.

ok stefan@, anton@

Reported-by: syzbot+2c625ab1b8e964da644a@syzkaller.appspotmail.com
Reported-by: syzbot+1300829862412751462d@syzkaller.appspotmail.com
Reported-by: syzbot+27cfad3394f34528cbec@syzkaller.appspotmail.com
Reported-by: syzbot+3e700c5698177f91cce1@syzkaller.appspotmail.com

Revision 1.255 / (download) - annotate - [select for diffs], Mon Dec 2 14:01:26 2019 UTC (4 years, 6 months ago) by mpi
Branch: MAIN
Changes since 1.254: +4 -11 lines
Diff to previous 1.254 (colored)

Stop supporting UVM_FLAG_TRYLOCK in uvm_mapanon(), it is not used.

ok tedu@, visa@

Revision 1.254 / (download) - annotate - [select for diffs], Sat Nov 30 23:15:54 2019 UTC (4 years, 6 months ago) by deraadt
Branch: MAIN
Changes since 1.253: +3 -3 lines
Diff to previous 1.253 (colored)

temporarily neuter the syscall-callfrom check as a few people
haven't crossed over the ABI break as easily as expected.

Revision 1.253 / (download) - annotate - [select for diffs], Fri Nov 29 06:34:45 2019 UTC (4 years, 6 months ago) by deraadt
Branch: MAIN
Changes since 1.252: +55 -3 lines
Diff to previous 1.252 (colored)

Repurpose the "syscalls must be on a writeable page" mechanism to
enforce a new policy: system calls must be in pre-registered regions.
We have discussed more strict checks than this, but none satisfy the
cost/benefit based upon our understanding of attack methods, anyways
let's see what the next iteration looks like.

This is intended to harden (translation: attackers must put extra
effort into attacking) against a mixture of W^X failures and JIT bugs
which allow syscall misinterpretation, especially in environments with
polymorphic-instruction/variable-sized instructions.  It fits in a bit
with libc/libcrypto/ld.so random relink on boot and no-restart-at-crash
behaviour, particularily for remote problems. Less effective once on-host
since someone the libraries can be read.

For static-executables the kernel registers the main program's
PIE-mapped exec section valid, as well as the randomly-placed sigtramp
page.  For dynamic executables ELF ld.so's exec segment is also
labelled valid; ld.so then has enough information to register libc's
exec section as valid via call-once msyscall(2)

For dynamic binaries, we continue to to permit the main program exec
segment because "go" (and potentially a few other applications) have
embedded system calls in the main program.  Hopefully at least go gets
fixed soon.

We declare the concept of embedded syscalls a bad idea for numerous
reasons, as we notice the ecosystem has many of
static-syscall-in-base-binary which are dynamically linked against
libraries which in turn use libc, which contains another set of
syscall stubs.  We've been concerned about adding even one additional
syscall entry point... but go's approach tends to double the entry-point
attack surface.

This was started at a nano-hackathon in Bob Beck's basement 2 weeks
ago during a long discussion with mortimer trying to hide from the SSL
scream-conversations, and finished in more comfortable circumstances
next to a wood-stove at Elk Lakes cabin with UVM scream-conversations.

ok guenther kettenis mortimer, lots of feedback from others
conversations about go with jsing tb sthen

Revision 1.252 / (download) - annotate - [select for diffs], Tue Nov 26 18:23:48 2019 UTC (4 years, 6 months ago) by mlarkin
Branch: MAIN
Changes since 1.251: +3 -4 lines
Diff to previous 1.251 (colored)

Fix a panic string that had the wrong function name and an improperly
wrapped line.

No code change.

Revision 1.251 / (download) - annotate - [select for diffs], Tue Nov 26 18:19:40 2019 UTC (4 years, 6 months ago) by mlarkin
Branch: MAIN
Changes since 1.250: +28 -28 lines
Diff to previous 1.250 (colored)

Fix a bunch of lines that had trailing whitespace.

No code change.

Revision 1.250 / (download) - annotate - [select for diffs], Sat Nov 2 16:41:57 2019 UTC (4 years, 7 months ago) by mpi
Branch: MAIN
Changes since 1.249: +3 -3 lines
Diff to previous 1.249 (colored)

Revert previous, a race is present and can be triggered with golang.

Found by jsing@

Revision 1.249 / (download) - annotate - [select for diffs], Fri Nov 1 19:33:09 2019 UTC (4 years, 7 months ago) by mpi
Branch: MAIN
Changes since 1.248: +3 -3 lines
Diff to previous 1.248 (colored)

Push the KERNEL_LOCK() down in uvm_map_inentry().

The lookup in uvm_map_inentry_fix() is already serialized by the
vm_map_lock and such lookup is already executed w/o the KERNEL_LOCK().

ok kettenis@, deraadt@

Revision 1.248 / (download) - annotate - [select for diffs], Fri Nov 1 19:18:29 2019 UTC (4 years, 7 months ago) by mpi
Branch: MAIN
Changes since 1.247: +5 -1 lines
Diff to previous 1.247 (colored)

Keep local function definitions in C files.

Revision 1.247 / (download) - annotate - [select for diffs], Mon Sep 9 20:02:26 2019 UTC (4 years, 8 months ago) by bluhm
Branch: MAIN
CVS Tags: OPENBSD_6_6_BASE, OPENBSD_6_6
Changes since 1.246: +3 -1 lines
Diff to previous 1.246 (colored)

Inform about system call memory write protection and stack mapping
violations in system accounting.  This will help to find missbehaving
programs and possible attacks.  The flags bit field is full, so
recycle the PDP-11 compatibility on VAX.  lastcomm(1) prints the
AMAP flag as 'M'.  daily(8) prints a list of affected processes.
OK deraadt@

Revision 1.246 / (download) - annotate - [select for diffs], Fri Jun 14 05:52:43 2019 UTC (4 years, 11 months ago) by deraadt
Branch: MAIN
Changes since 1.245: +5 -6 lines
Diff to previous 1.245 (colored)

The addition of writeable-syscall checking near MAP_STACK checking
damaged the error messages.  Repair that, passing distinct format
strings for the two cases.
ok beck

Revision 1.245 / (download) - annotate - [select for diffs], Sat Jun 1 22:42:20 2019 UTC (5 years ago) by deraadt
Branch: MAIN
Changes since 1.244: +90 -22 lines
Diff to previous 1.244 (colored)

Refactor the MAP_STACK feature, and introduce another similar variation:
Lookup the address that a syscall instruction is executed from, and kill
the process if that page is writeable.  This brings an aspect of W^X
behaviour to W|X mappings (in JITs not yet adapted to W^X).  The goal is
to remove simple attack methods and force use of ret2libc or other more
complicated means.
ok kettenis stefan visa

Revision 1.244 / (download) - annotate - [select for diffs], Thu May 16 04:24:14 2019 UTC (5 years ago) by kettenis
Branch: MAIN
Changes since 1.243: +12 -2 lines
Diff to previous 1.243 (colored)

Handle a bit more work without taking the kernel lock.  This should avoid
taking the kernel lock on when operating on the kernel_map when called from
all kernel memory allocation interfaces.

ok visa@, mlarkin@

Revision 1.243 / (download) - annotate - [select for diffs], Tue Apr 23 13:35:12 2019 UTC (5 years, 1 month ago) by visa
Branch: MAIN
Changes since 1.242: +16 -18 lines
Diff to previous 1.242 (colored)

Remove file name and line number output from witness(4)

Reduce code clutter by removing the file name and line number output
from witness(4). Typically it is easy enough to locate offending locks
using the stack traces that are shown in lock order conflict reports.
Tricky cases can be tracked using sysctl kern.witness.locktrace=1 .

This patch additionally removes the witness(4) wrapper for mutexes.
Now each mutex implementation has to invoke the WITNESS_*() macros
in order to utilize the checker.

Discussed with and OK dlg@, OK mpi@

Revision 1.242 / (download) - annotate - [select for diffs], Fri Mar 1 01:46:18 2019 UTC (5 years, 3 months ago) by cheloha
Branch: MAIN
CVS Tags: OPENBSD_6_5_BASE, OPENBSD_6_5
Changes since 1.241: +5 -1 lines
Diff to previous 1.241 (colored)

New mmap(2) flag: MAP_CONCEAL.

MAP_CONCEAL'd memory is not written to disk in the event of a core dump.
It may grow other qualities in the future.

Wanted by libressl, probably useful elsewhere, too.

Prompted by deraadt@, concept from deraadt@/kettenis@.  With input from
deraadt@, cjeker@, kettenis@, otto@, bcook@, matthew@, guenther@, djm@,
and tedu@.

ok otto@ deraadt@

Revision 1.241 / (download) - annotate - [select for diffs], Fri Feb 15 16:46:59 2019 UTC (5 years, 3 months ago) by deraadt
Branch: MAIN
Changes since 1.240: +6 -2 lines
Diff to previous 1.240 (colored)

With an opportunistic check performed at every trap, we insist userland
sp must be on a MAP_STACK page.  Relax the check a bit -- the sp may be
on a PROT_NONE page.  Can't see how an attacker can leverage that situation.

(New perl build process contains a "how many call frames can my stack
hold" checker, and this triggers via the MAP_STACK fault rather than
the normal access check.  The MAP_STACK check still has a kernel printf
as we hunt for applications which map stacks poorly.  Interestingly the
perl code has a knob to disable similar printing alerts on Windows, which
apparently has a feature somewhat like MAP_STACK!)

ok tedu guenther kettenis

Revision 1.240 / (download) - annotate - [select for diffs], Sun Feb 10 16:42:35 2019 UTC (5 years, 3 months ago) by phessler
Branch: MAIN
Changes since 1.239: +2 -2 lines
Diff to previous 1.239 (colored)

"non-existant" is one of those words that don't exist, so use "non-existent"
instead

From Pamela Mosiejczuk, many thanks!
OK phessler@ deraadt@

Revision 1.239 / (download) - annotate - [select for diffs], Wed Oct 31 08:50:25 2018 UTC (5 years, 7 months ago) by kettenis
Branch: MAIN
Changes since 1.238: +3 -1 lines
Diff to previous 1.238 (colored)

Add support to uvm to establish write-combining mappings.  Use this in the
inteldrm driver to add support for the I915_MMAP_WC flag.

ok deraadt@, jsg@

Revision 1.238 / (download) - annotate - [select for diffs], Sun Jul 22 14:33:44 2018 UTC (5 years, 10 months ago) by kettenis
Branch: MAIN
CVS Tags: OPENBSD_6_4_BASE, OPENBSD_6_4
Changes since 1.237: +2 -2 lines
Diff to previous 1.237 (colored)

In uvm_map_protect(), make sure we select a first map entry that ends after
the start of the range of pages that we're changing.  Prevents a panic from
a somewhat convoluted test case that anton@ came up with.

ok guenther@, anton@

Revision 1.237 / (download) - annotate - [select for diffs], Wed Apr 18 16:05:21 2018 UTC (6 years, 1 month ago) by deraadt
Branch: MAIN
Changes since 1.236: +8 -1 lines
Diff to previous 1.236 (colored)

Some programs create a PROT_NONE guard page at the far-end of the provided
stack buffer.  With a page-aligned buffer, creating a MAP_STACK sub-region
would undo the PROT_NONE guard.  Ignore that last page.
(We could check if the last page is non-RW before choosing to skip it. But
we've already elected to grow STK sizes to compensate.  Always ignoring the
last page makes it a non-MAP_STACK guard page which can be opportunistically
discovered)
ok semarie stefan kettenis

Revision 1.236 / (download) - annotate - [select for diffs], Tue Apr 17 15:50:05 2018 UTC (6 years, 1 month ago) by otto
Branch: MAIN
Changes since 1.235: +6 -8 lines
Diff to previous 1.235 (colored)

- Make rnd hints avoid the brk area. The rnd allocator refuses to allocate in
  the brk area anyway.
- Use a larger hint bound to spread the allocations more for the 32-bit case
- Simplified the overy abstracted brs/stack allocator and switch of
  guard pages for the brk case. This allows i386 some extra space,
  depending on memory usage patterns.
- Reduce brk area on i386 to give the rnd space more room

ok stefan@ sthen@

Revision 1.235 / (download) - annotate - [select for diffs], Tue Apr 17 14:39:59 2018 UTC (6 years, 1 month ago) by stefan
Branch: MAIN
Changes since 1.234: +2 -15 lines
Diff to previous 1.234 (colored)

Remove protection checks from uvm_map_is_stack_remappable

Other parts of uvm/pmap check for proper prot flags
already. This fixes the qemu startup problems that
semarie@ reported on tech@.

Revision 1.234 / (download) - annotate - [select for diffs], Thu Apr 12 17:13:44 2018 UTC (6 years, 1 month ago) by deraadt
Branch: MAIN
Changes since 1.233: +160 -5 lines
Diff to previous 1.233 (colored)

Implement MAP_STACK option for mmap().  Synchronous faults (pagefault and
syscall) confirm the stack register points at MAP_STACK memory, otherwise
SIGSEGV is delivered. sigaltstack() and pthread_attr_setstack() are modified
to create a MAP_STACK sub-region which satisfies alignment requirements.
Observe that MAP_STACK can only be set/cleared by mmap(), which zeroes the
contents of the region -- there is no mprotect() equivalent operation, so
there is no MAP_STACK-adding gadget.
This opportunistic software-emulation of a stack protection bit makes
stack-pivot operations during ROPchain fragile (kind of like removing a
tool from the toolbox).
original discussion with tedu, uvm work by stefan, testing by mortimer
ok kettenis

Revision 1.233 / (download) - annotate - [select for diffs], Thu Nov 30 00:36:10 2017 UTC (6 years, 6 months ago) by guenther
Branch: MAIN
CVS Tags: OPENBSD_6_3_BASE, OPENBSD_6_3
Changes since 1.232: +1 -3 lines
Diff to previous 1.232 (colored)

__MAP_NOFAULT doesn't make sense with anon mappings, so return EINVAL if
that is attempted.
Minor cleanups:
 - Eliminate some always false and always true tests against MAP_ANON
 - We treat anon mappings with neither MAP_{SHARED,PRIVATE} as MAP_PRIVATE
   so explicitly indicate that

ok kettenis@ beck@

Revision 1.232 / (download) - annotate - [select for diffs], Sat Aug 12 16:30:10 2017 UTC (6 years, 9 months ago) by guenther
Branch: MAIN
CVS Tags: OPENBSD_6_2_BASE, OPENBSD_6_2
Changes since 1.231: +18 -16 lines
Diff to previous 1.231 (colored)

In the locking wrappers for &map->lock and &map->mtx, pass through file+line
when WITNESS is enabled

ok visa@ kettenis@

Revision 1.231 / (download) - annotate - [select for diffs], Wed May 17 08:13:33 2017 UTC (7 years ago) by mpi
Branch: MAIN
Changes since 1.230: +2 -2 lines
Diff to previous 1.230 (colored)

Raise "uvm_map_entry_kmem_pool" IPL level to IPL_VM to prevent a deadlock.

A deadlock can occur when the uvm_km_thread(), running without KERNEL_LOCK()
is interrupted by and non-MPSAFE handler while holding the pool's mutex.  At
that moment if another CPU is holding the KERNEL_LOCK() and wants to grab the
pool mutex, like in sys_kbind(), kaboom!

This is a temporaty solution, a more generate approach regarding mutexes and
un-KERNEL_LOCK()ed threads is beeing discussed.

Deadlock reported by sthen@, ok kettenis@

Revision 1.230 / (download) - annotate - [select for diffs], Thu Apr 20 14:13:00 2017 UTC (7 years, 1 month ago) by visa
Branch: MAIN
Changes since 1.229: +2 -2 lines
Diff to previous 1.229 (colored)

Tweak lock inits to make the system runnable with witness(4)
on amd64 and i386.

Revision 1.229 / (download) - annotate - [select for diffs], Tue Feb 14 10:31:15 2017 UTC (7 years, 3 months ago) by mpi
Branch: MAIN
CVS Tags: OPENBSD_6_1_BASE, OPENBSD_6_1
Changes since 1.228: +2 -2 lines
Diff to previous 1.228 (colored)

Convert most of the manual checks for CPU hogging to sched_pause().

The distinction between preempt() and yield() stays as it is usueful
to know if a thread decided to yield by itself or if the kernel told
him to go away.

ok tedu@, guenther@

Revision 1.228 / (download) - annotate - [select for diffs], Sun Feb 5 01:08:31 2017 UTC (7 years, 3 months ago) by guenther
Branch: MAIN
Changes since 1.227: +1 -5 lines
Diff to previous 1.227 (colored)

Delete comment obsoleted by the rewrite in rev 1.136 (2011-05-24)

Revision 1.227 / (download) - annotate - [select for diffs], Tue Jan 17 17:19:21 2017 UTC (7 years, 4 months ago) by stefan
Branch: MAIN
Changes since 1.226: +1 -14 lines
Diff to previous 1.226 (colored)

Remove uaddr_hint allocator

The hint allocator would have to check that the
allocation does not overlap with brk, stack or text
areas. This would make the address selectors too
entagled. Just use the rnd allocator for hinted allocations
in case pivots are used. This also reduces the amount of code somewhat.

ok kettenis visa deraadt

Revision 1.226 / (download) - annotate - [select for diffs], Mon Nov 7 00:26:33 2016 UTC (7 years, 6 months ago) by guenther
Branch: MAIN
Changes since 1.225: +2 -2 lines
Diff to previous 1.225 (colored)

Split PID from TID, giving processes a PID unrelated to the TID of their
initial thread

ok jsing@ kettenis@

Revision 1.225 / (download) - annotate - [select for diffs], Fri Sep 16 02:35:42 2016 UTC (7 years, 8 months ago) by dlg
Branch: MAIN
Changes since 1.224: +3 -3 lines
Diff to previous 1.224 (colored)

move the vm_page struct from being stored in RB macro trees to RBT functions

vm_page structs go into three trees, uvm_objtree, uvm_pmr_addr, and
uvm_pmr_size. all these have been moved to RBT code.

this should give us a decent chunk of code space back.

Revision 1.224 / (download) - annotate - [select for diffs], Fri Sep 16 01:09:53 2016 UTC (7 years, 8 months ago) by dlg
Branch: MAIN
Changes since 1.223: +80 -87 lines
Diff to previous 1.223 (colored)

move the uvm_map_addr RB tree from RB macros to the RBT functions

this tree is interesting because it uses all the red black tree
features, specifically the augment callback thats called on tree
topology changes, and it poisons and checks entries as theyre removed
from and inserted back into the tree respectively.

ok stefan@

Revision 1.223 / (download) - annotate - [select for diffs], Thu Sep 15 02:00:18 2016 UTC (7 years, 8 months ago) by dlg
Branch: MAIN
Changes since 1.222: +7 -10 lines
Diff to previous 1.222 (colored)

all pools have their ipl set via pool_setipl, so fold it into pool_init.

the ioff argument to pool_init() is unused and has been for many
years, so this replaces it with an ipl argument. because the ipl
will be set on init we no longer need pool_setipl.

most of these changes have been done with coccinelle using the spatch
below. cocci sucks at formatting code though, so i fixed that by hand.

the manpage and subr_pool.c bits i did myself.

ok tedu@ jmatthew@

@ipl@
expression pp;
expression ipl;
expression s, a, o, f, m, p;
@@
-pool_init(pp, s, a, o, f, m, p);
-pool_setipl(pp, ipl);
+pool_init(pp, s, a, ipl, f, m, p);

Revision 1.222 / (download) - annotate - [select for diffs], Sat Sep 3 18:43:34 2016 UTC (7 years, 9 months ago) by stefan
Branch: MAIN
Changes since 1.221: +3 -5 lines
Diff to previous 1.221 (colored)

Only use uaddr_exe for address selection when PROT_EXEC is requested

Checking whether a memory range could be mprotect()'ed to PROT_EXEC
attempts to put every mapping into the uaddr_exe range, if it exists.
This would fill up the exe range on i386 quickly, once uaddr_exe gets
used. So only use uaddr_exe if we know PROT_EXEC is needed for sure
No change in current behavior, since uaddr_exe will only be used
with uvm pivots.

ok tedu@

Revision 1.221 / (download) - annotate - [select for diffs], Wed Aug 31 13:13:58 2016 UTC (7 years, 9 months ago) by stefan
Branch: MAIN
Changes since 1.220: +5 -9 lines
Diff to previous 1.220 (colored)

Simplify arguments to uaddr_*_create functions

min is already clamped before invoking these functions.
ok kettenis@

Revision 1.220 / (download) - annotate - [select for diffs], Thu Aug 11 01:17:33 2016 UTC (7 years, 9 months ago) by dlg
Branch: MAIN
Changes since 1.219: +12 -16 lines
Diff to previous 1.219 (colored)

replace abuse of the static map entries RB_ENTRY pointers with an SLIST

free static entries are kept in a simple linked list, so use SLIST
to make this obvious. the RB_PARENT manipulations are ugly and
confusing.

ok kettenis@

Revision 1.217.2.1 / (download) - annotate - [select for diffs], Mon Aug 1 19:22:55 2016 UTC (7 years, 10 months ago) by tedu
Branch: OPENBSD_6_0
Changes since 1.217: +16 -1 lines
Diff to previous 1.217 (colored) next main 1.218 (colored)

backport overflow checks from 1.218 and 1.219:
add a check that the arguments to isavail don't overflow.
callers should probably check too, but checking here won't hurt.
possible panic reported by tim newsham.
Check for wraparound before the "commit" phase of uvm_map() and uvm_mapanon(),
to prevent hitting assertions and/or corrupting data structures during that
phase.

Revision 1.205.2.1 / (download) - annotate - [select for diffs], Mon Aug 1 19:20:23 2016 UTC (7 years, 10 months ago) by tedu
Branch: OPENBSD_5_9
Changes since 1.205: +16 -1 lines
Diff to previous 1.205 (colored) next main 1.206 (colored)

backport overflow checks from 1.218 and 1.219:
add a check that the arguments to isavail don't overflow.
callers should probably check too, but checking here won't hurt.
possible panic reported by tim newsham.
Check for wraparound before the "commit" phase of uvm_map() and uvm_mapanon(),
to prevent hitting assertions and/or corrupting data structures during that
phase.

Revision 1.192.4.1 / (download) - annotate - [select for diffs], Mon Aug 1 19:19:14 2016 UTC (7 years, 10 months ago) by tedu
Branch: OPENBSD_5_8
Changes since 1.192: +16 -1 lines
Diff to previous 1.192 (colored) next main 1.193 (colored)

backport overflow checks from 1.218 and 1.219:
add a check that the arguments to isavail don't overflow.
callers should probably check too, but checking here won't hurt.
possible panic reported by tim newsham.
Check for wraparound before the "commit" phase of uvm_map() and uvm_mapanon(),
to prevent hitting assertions and/or corrupting data structures during that
phase.

Revision 1.219 / (download) - annotate - [select for diffs], Sat Jul 30 16:43:44 2016 UTC (7 years, 10 months ago) by kettenis
Branch: MAIN
Changes since 1.218: +13 -1 lines
Diff to previous 1.218 (colored)

Check for wraparound before the "commit" phase of uvm_map() and uvm_mapanon(),
to prevent hitting assertions and/or corrupting data structures during that
phase.

ok deraadt@, tedu@

Revision 1.218 / (download) - annotate - [select for diffs], Fri Jul 29 20:44:40 2016 UTC (7 years, 10 months ago) by tedu
Branch: MAIN
Changes since 1.217: +4 -1 lines
Diff to previous 1.217 (colored)

add a check that the arguments to isavail don't overflow.
callers should probably check too, but checking here won't hurt.
possible panic reported by tim newsham.
ok kettenis

Revision 1.217 / (download) - annotate - [select for diffs], Fri Jun 17 10:48:25 2016 UTC (7 years, 11 months ago) by dlg
Branch: MAIN
CVS Tags: OPENBSD_6_0_BASE
Branch point for: OPENBSD_6_0
Changes since 1.216: +3 -1 lines
Diff to previous 1.216 (colored)

pool_setipl on all uvm pools.

ok kettenis@ visa@

Revision 1.216 / (download) - annotate - [select for diffs], Mon Jun 13 17:14:09 2016 UTC (7 years, 11 months ago) by kettenis
Branch: MAIN
Changes since 1.215: +5 -2 lines
Diff to previous 1.215 (colored)

In uvm_map(), call uvm_unmap_detach_intrsafe() if we have an interrupt-safe
map, to avoid grabbing the kernel lock when pool_get() needs to allocate
a new pool page.  Hopefully this really is the last case where we might grab
the kernel lock for interrupt-safe pools.

ok mpi@

Revision 1.215 / (download) - annotate - [select for diffs], Sun Jun 5 08:35:57 2016 UTC (7 years, 11 months ago) by stefan
Branch: MAIN
Changes since 1.214: +138 -26 lines
Diff to previous 1.214 (colored)

Add uvm_share() to share a memory range between two address spaces

Its primary use is to make guest VM memory accessible to the host
(e.g. vmd(8)). That will later allow us to remove the readpage and
writepage ioctls from vmm(4), and use ordinary loads and stores instead.

"looks good to me" kettenis@

Revision 1.214 / (download) - annotate - [select for diffs], Fri Jun 3 06:47:51 2016 UTC (8 years ago) by kettenis
Branch: MAIN
Changes since 1.213: +2 -2 lines
Diff to previous 1.213 (colored)

We should never decrease uvm_maxkaddr.  Currently this may happen if
uvm_map_kmem_grow() gets called for submaps of the kernel_map on
architectures that don't implement pmap_growkernel().  When that happens
we get the infamous "address selector returned unavailable address" panic.

ok tedu@, mglocker@, beck@, stefan@

Revision 1.213 / (download) - annotate - [select for diffs], Sun May 8 16:29:57 2016 UTC (8 years ago) by stefan
Branch: MAIN
Changes since 1.212: +3 -3 lines
Diff to previous 1.212 (colored)

Additional parameter for amap_alloc().

It is supposed to control whether an amap should allocate memory
to store anon pointers lazily or upfront. Needed for upcoming amap
changes.

ok kettenis@

Revision 1.212 / (download) - annotate - [select for diffs], Thu May 5 11:23:39 2016 UTC (8 years ago) by stefan
Branch: MAIN
Changes since 1.211: +1 -21 lines
Diff to previous 1.211 (colored)

Remove uvm_mapentry_freecmp which has been unused for years

Found by David Hill with clang.

Revision 1.211 / (download) - annotate - [select for diffs], Mon Apr 4 16:34:16 2016 UTC (8 years, 2 months ago) by stefan
Branch: MAIN
Changes since 1.210: +3 -7 lines
Diff to previous 1.210 (colored)

UVM_FLAG_AMAPPAD has no effect anymore, nuke it.

This flag caused amaps to be allocated with additional spare slots, to
make extending them cheaper. However, the kernel never extends amaps,
so allocating spare slots is pointless. Also UVM_FLAG_AMAPPAD only
has an effect in combination with UVM_FLAG_OVERLAY. The only function
that used both flags was sys_obreak, but that function had the use of
UVM_FLAG_OVERLAY removed recently.

While there, kill the unused prototypes amap_flags and amap_refs.
They're defined as macros already.

ok mlarkin@ kettenis@ mpi@

Revision 1.210 / (download) - annotate - [select for diffs], Sun Mar 27 09:51:37 2016 UTC (8 years, 2 months ago) by stefan
Branch: MAIN
Changes since 1.209: +6 -6 lines
Diff to previous 1.209 (colored)

amap_extend is never called, remove it.

In the code, this function is called when vm_map_entries are merged.
However, only kernel map entries are merged, and these do not use amaps.
Therefore amap_extend() is never called at runtime.

ok millert@, KASSERT suggestion and ok mpi@

Revision 1.209 / (download) - annotate - [select for diffs], Tue Mar 15 20:50:23 2016 UTC (8 years, 2 months ago) by krw
Branch: MAIN
Changes since 1.208: +2 -2 lines
Diff to previous 1.208 (colored)

'accomodate' -> 'accommodate' in comments.

Started by diff from Mical Mazurek.

Revision 1.208 / (download) - annotate - [select for diffs], Wed Mar 9 16:45:43 2016 UTC (8 years, 2 months ago) by deraadt
Branch: MAIN
Changes since 1.207: +1 -3 lines
Diff to previous 1.207 (colored)

remove vaxisms

Revision 1.207 / (download) - annotate - [select for diffs], Sun Mar 6 08:56:16 2016 UTC (8 years, 2 months ago) by stefan
Branch: MAIN
Changes since 1.206: +12 -22 lines
Diff to previous 1.206 (colored)

Tweak uvm assertions to avoid locking in some cases.

When only one thread can access a map, there's no need
to lock it. Tweak the assertion instead of appeasing it
by acquiring a lock when it's not necessary.

ok kettenis@

Revision 1.206 / (download) - annotate - [select for diffs], Thu Mar 3 12:41:30 2016 UTC (8 years, 3 months ago) by naddy
Branch: MAIN
Changes since 1.205: +1 -5 lines
Diff to previous 1.205 (colored)

Remove option USER_LDT and everything depending on it.
Remove machdep.userldt sysctl.
Remove i386_[gs]et_ldt syscall stub from libi386.
Remove i386_[gs]et_ldt regression test.

ok mlarkin@ millert@ guenther@

Revision 1.205 / (download) - annotate - [select for diffs], Wed Dec 16 14:22:21 2015 UTC (8 years, 5 months ago) by kettenis
Branch: MAIN
CVS Tags: OPENBSD_5_9_BASE
Branch point for: OPENBSD_5_9
Changes since 1.204: +20 -2 lines
Diff to previous 1.204 (colored)

Avoid grabbing the kernel lock in uvm_unmap() if we have an interrupt-safe
map.  This removes the (hopefully) last case in which pool_put() might try
to grab the kernel lock for interrupt-safe pools.  Note that pools that are
created with the PR_WAITOK flag will still grab the kernel lock.

ok mpi@, tedu@

Revision 1.204 / (download) - annotate - [select for diffs], Sat Nov 14 14:53:14 2015 UTC (8 years, 6 months ago) by miod
Branch: MAIN
Changes since 1.203: +2 -2 lines
Diff to previous 1.203 (colored)

mutli -> multi

Revision 1.203 / (download) - annotate - [select for diffs], Wed Nov 11 15:59:33 2015 UTC (8 years, 6 months ago) by mmcc
Branch: MAIN
Changes since 1.202: +4 -3 lines
Diff to previous 1.202 (colored)

Remove the superfluous typedef uvm_flag_t (unsigned int). Also, fix an
associated mistake in the uvm manpage.

Suggested by and ok tedu@

Revision 1.202 / (download) - annotate - [select for diffs], Thu Oct 1 20:27:51 2015 UTC (8 years, 8 months ago) by kettenis
Branch: MAIN
Changes since 1.201: +7 -2 lines
Diff to previous 1.201 (colored)

In uvm_map_splitentry(), grab the kernel lock before calling into the amap
or pager code.  We may end up here without holding the kernel lock from
uvm_unmap().

"ja ja" tedu@

Revision 1.201 / (download) - annotate - [select for diffs], Mon Sep 28 18:33:42 2015 UTC (8 years, 8 months ago) by tedu
Branch: MAIN
Changes since 1.200: +7 -2 lines
Diff to previous 1.200 (colored)

add a flag to indicate to uvm_map that it should unmap to make space.
this pulls all the relevant operations under the same map locking, and
relieves calling code from responsibility.
ok kettenis matthew

Revision 1.200 / (download) - annotate - [select for diffs], Sat Sep 26 17:55:00 2015 UTC (8 years, 8 months ago) by kettenis
Branch: MAIN
Changes since 1.199: +8 -8 lines
Diff to previous 1.199 (colored)

Protect the list of free map entries with a mutex.  This should fix the
crashes seen by sthen@ on i386.

ok visa@, guenther@, tedu@

Revision 1.199 / (download) - annotate - [select for diffs], Sat Sep 12 18:54:47 2015 UTC (8 years, 8 months ago) by kettenis
Branch: MAIN
Changes since 1.198: +7 -2 lines
Diff to previous 1.198 (colored)

Enable some diagnostics for interrupt-safe maps that are already happening for
normal maps.

ok beck@, miod@, guenther@

Revision 1.198 / (download) - annotate - [select for diffs], Wed Sep 9 23:33:37 2015 UTC (8 years, 8 months ago) by kettenis
Branch: MAIN
Changes since 1.197: +15 -2 lines
Diff to previous 1.197 (colored)

Add locking for interrupt-safe maps (those that have the VM_MAP_INTRSAFE flag
set).  Since we cannot sleep in that case, use a mutex instead of an rwlock.
This is ok as the more complex code paths in the uvm code are not entered
for interrupt-safe maps as paging isn't allowed in those maps.

ok tedu@

Revision 1.197 / (download) - annotate - [select for diffs], Wed Sep 9 14:52:12 2015 UTC (8 years, 8 months ago) by miod
Branch: MAIN
Changes since 1.196: +1 -6 lines
Diff to previous 1.196 (colored)

All our pmap implementations provide pmap_resident_count(), so remove
#ifndef pmap_resident_count code paths.

Revision 1.196 / (download) - annotate - [select for diffs], Tue Sep 1 05:49:37 2015 UTC (8 years, 9 months ago) by deraadt
Branch: MAIN
Changes since 1.195: +7 -7 lines
Diff to previous 1.195 (colored)

size for free(), and make allocation side look similar

Revision 1.195 / (download) - annotate - [select for diffs], Thu Aug 27 21:58:15 2015 UTC (8 years, 9 months ago) by kettenis
Branch: MAIN
Changes since 1.194: +1 -4 lines
Diff to previous 1.194 (colored)

After more than a decade it seems safe to conclude that amap_clean works.

ok mpi@, visa@

Revision 1.194 / (download) - annotate - [select for diffs], Fri Aug 21 16:04:35 2015 UTC (8 years, 9 months ago) by visa
Branch: MAIN
Changes since 1.193: +6 -17 lines
Diff to previous 1.193 (colored)

Remove the unused loan_count field and the related uvm logic. Most of
the page loaning code is already in the Attic.

ok kettenis@, beck@

Revision 1.193 / (download) - annotate - [select for diffs], Wed Aug 19 12:23:25 2015 UTC (8 years, 9 months ago) by visa
Branch: MAIN
Changes since 1.192: +3 -3 lines
Diff to previous 1.192 (colored)

Sync page_flagbits with reality.

ok kettenis@

Revision 1.192 / (download) - annotate - [select for diffs], Fri Jul 17 21:56:14 2015 UTC (8 years, 10 months ago) by kettenis
Branch: MAIN
CVS Tags: OPENBSD_5_8_BASE
Branch point for: OPENBSD_5_8
Changes since 1.191: +20 -13 lines
Diff to previous 1.191 (colored)

Release the kernel lock while tearing down the uvm map in the reaper.  Speeds
up workloads that fork a lot of processes and, more importantly reduces
latency because it makes sure the reaper doesn't hold on to the kernel lock
for long periods of time.

This almost certainly breaks MP kernels on alpha, macppc, m88k and sgi;
hppa might work, but probably doesn't.

ok deraadt@, beck@

Revision 1.191 / (download) - annotate - [select for diffs], Thu Apr 23 00:49:37 2015 UTC (9 years, 1 month ago) by dlg
Branch: MAIN
Changes since 1.190: +3 -3 lines
Diff to previous 1.190 (colored)

dont need \n on panic strings

Revision 1.190 / (download) - annotate - [select for diffs], Mon Mar 30 21:09:55 2015 UTC (9 years, 2 months ago) by miod
Branch: MAIN
Changes since 1.189: +2 -2 lines
Diff to previous 1.189 (colored)

Revert 1.173 (special-casing mips64) now that uvm_map_hint()'s return value is
constrained to a suitable range.

Revision 1.189 / (download) - annotate - [select for diffs], Mon Mar 30 21:08:40 2015 UTC (9 years, 2 months ago) by miod
Branch: MAIN
Changes since 1.188: +7 -2 lines
Diff to previous 1.188 (colored)

Extend uvm_map_hint() to get an address range as extra arguments, and make
sure it will return an address within that range.

Use this in uaddr_rnd_select() to make sure we will not attempt to pick
an address beyond what we are allowed to map.

In my trees for 9 months, blackmailed s2k15 attendees into agreeing now would
be a good time to commit.

Revision 1.188 / (download) - annotate - [select for diffs], Sat Mar 14 03:38:53 2015 UTC (9 years, 2 months ago) by jsg
Branch: MAIN
Changes since 1.187: +1 -2 lines
Diff to previous 1.187 (colored)

Remove some includes include-what-you-use claims don't
have any direct symbols used.  Tested for indirect use by compiling
amd64/i386/sparc64 kernels.

ok tedu@ deraadt@

Revision 1.187 / (download) - annotate - [select for diffs], Thu Feb 19 03:06:53 2015 UTC (9 years, 3 months ago) by mlarkin
Branch: MAIN
CVS Tags: OPENBSD_5_7_BASE, OPENBSD_5_7
Changes since 1.186: +1 -2 lines
Diff to previous 1.186 (colored)


Remove a lie from a comment that ratholed me for an evening.
Thanks to tedu for hinting that I may have been the victim of UVM's lies,
which pointed me in this direction.

ok tedu

Revision 1.186 / (download) - annotate - [select for diffs], Sun Feb 15 21:34:33 2015 UTC (9 years, 3 months ago) by miod
Branch: MAIN
Changes since 1.185: +3 -3 lines
Diff to previous 1.185 (colored)

Change pmap_remove_holes() to take a vmspace instead of a map as its argument.

Use this on vax to correctly pick the end of the stack area now that the
stackgap adjustment code will no longer guarantee it is a fixed location.

Revision 1.185 / (download) - annotate - [select for diffs], Mon Feb 9 07:14:38 2015 UTC (9 years, 3 months ago) by kettenis
Branch: MAIN
Changes since 1.184: +2 -2 lines
Diff to previous 1.184 (colored)

Make sure we actually have an entry before checking its limits.

ok deraadt@

Revision 1.184 / (download) - annotate - [select for diffs], Fri Feb 6 11:41:55 2015 UTC (9 years, 3 months ago) by beck
Branch: MAIN
Changes since 1.183: +187 -3 lines
Diff to previous 1.183 (colored)

-Split out uvm_mmap and uvm_map into a version for anon's and a version
for everything else.
-Adapt the anon version to be callable without the biglock held.
Done by tedu@, kettenis@ and me.. pounded on a bunch.

This does not yet make mmap a NOLOCK call, but permits it to be so.
ok tedu@, kettenis@, guenther@ jsing@

Revision 1.183 / (download) - annotate - [select for diffs], Fri Feb 6 09:04:34 2015 UTC (9 years, 3 months ago) by tedu
Branch: MAIN
Changes since 1.182: +32 -4 lines
Diff to previous 1.182 (colored)

make vm_map_lock lock when it's supposed to. add mutex to protect flags
and then double check we didn't lose the unavoidable race.
ok beck guenther kettenis miod

Revision 1.182 / (download) - annotate - [select for diffs], Tue Dec 23 02:01:57 2014 UTC (9 years, 5 months ago) by tedu
Branch: MAIN
Changes since 1.181: +3 -3 lines
Diff to previous 1.181 (colored)

convert nointr pool_init argument to pr_waitok

Revision 1.181 / (download) - annotate - [select for diffs], Fri Dec 5 04:12:48 2014 UTC (9 years, 5 months ago) by uebayasi
Branch: MAIN
Changes since 1.180: +57 -1 lines
Diff to previous 1.180 (colored)

Introduce a new sysctl to retrieve VM map entries

This adds a new sysctl KERN_PROC_VMMAP, which returns an array of VM map
entries of a specified process.  This prevents debuggers from iterating
vm_map_entry RB tree via kvm(3).

The name KERN_PROC_VMMAP and struct kinfo_vmentry are chosen from the same
function in FreeBSD.  struct kinfo_vmentry is revised to reduce size, because
OpenBSD does not keep track of filepaths.  The semantic is also changed to
return max buffer size as a hint, and start iteration at the specified base
address.

Much valuable input from deraadt@, guenther@, tedu@

OK tedu@ deraadt@

Revision 1.180 / (download) - annotate - [select for diffs], Sun Nov 30 19:50:53 2014 UTC (9 years, 6 months ago) by deraadt
Branch: MAIN
Changes since 1.179: +8 -1 lines
Diff to previous 1.179 (colored)

panic if the kernel requests W | X pages; ok kettenis

Revision 1.179 / (download) - annotate - [select for diffs], Tue Nov 18 02:37:31 2014 UTC (9 years, 6 months ago) by tedu
Branch: MAIN
Changes since 1.178: +1 -3 lines
Diff to previous 1.178 (colored)

move arc4random prototype to systm.h. more appropriate for most code
to include that than rdnvar.h. ok deraadt dlg

Revision 1.178 / (download) - annotate - [select for diffs], Sun Nov 16 12:31:00 2014 UTC (9 years, 6 months ago) by deraadt
Branch: MAIN
Changes since 1.177: +20 -21 lines
Diff to previous 1.177 (colored)

Replace a plethora of historical protection options with just
PROT_NONE, PROT_READ, PROT_WRITE, and PROT_EXEC from mman.h.
PROT_MASK is introduced as the one true way of extracting those bits.
Remove UVM_ADV_* wrapper, using the standard names.
ok doug guenther kettenis

Revision 1.177 / (download) - annotate - [select for diffs], Thu Nov 13 00:47:44 2014 UTC (9 years, 6 months ago) by tedu
Branch: MAIN
Changes since 1.176: +2 -2 lines
Diff to previous 1.176 (colored)

bzero -> memset

Revision 1.176 / (download) - annotate - [select for diffs], Fri Oct 3 17:41:00 2014 UTC (9 years, 8 months ago) by kettenis
Branch: MAIN
Changes since 1.175: +3 -1 lines
Diff to previous 1.175 (colored)

Introduce __MAP_NOFAULT, a mmap(2) flag that makes sure a mapping will not
cause a SIGSEGV or SIGBUS when a mapped file gets truncated.  Access to
pages that are not backed by a file on such a mapping will be replaced by
zero-filled anonymous pages.  Makes passing file descriptors of mapped files
usable without having to play tricks with signal handlers.

"steal your mmap flag" deraadt@

Revision 1.175 / (download) - annotate - [select for diffs], Thu Aug 14 17:21:38 2014 UTC (9 years, 9 months ago) by miod
Branch: MAIN
Changes since 1.174: +2 -2 lines
Diff to previous 1.174 (colored)

Bring back 1.173 (reverting 1.174) - mips64 systems are still unhappy when
the hint returned is over VM_MAXUSER_ADDRESS, apparently; better be safe for
now while this is investigated further.

Revision 1.174 / (download) - annotate - [select for diffs], Tue Aug 12 04:29:05 2014 UTC (9 years, 9 months ago) by miod
Branch: MAIN
Changes since 1.173: +2 -2 lines
Diff to previous 1.173 (colored)

Revert 1.173 now that the real cause of the octeon regression has been fixed.

Revision 1.173 / (download) - annotate - [select for diffs], Sun Jul 13 15:33:28 2014 UTC (9 years, 10 months ago) by pirofti
Branch: MAIN
CVS Tags: OPENBSD_5_6_BASE, OPENBSD_5_6
Changes since 1.172: +2 -2 lines
Diff to previous 1.172 (colored)

Fall back to smaller spacing on the mips64 machines.

Please spare some change for the mips64 memory-challenged machines..
Some change, Sir?

Fixes at least the octeon platform. Found the hardway on my DSR500.

Found by Boss tedu@ and Boss deraadt@
Okay Boss miod@

Revision 1.172 / (download) - annotate - [select for diffs], Sun Jul 13 08:15:16 2014 UTC (9 years, 10 months ago) by tedu
Branch: MAIN
Changes since 1.171: +5 -1 lines
Diff to previous 1.171 (colored)

more mmap random on 64-bit platforms. noticed in freebsd aslr patches.

Revision 1.171 / (download) - annotate - [select for diffs], Sat Jul 12 18:44:01 2014 UTC (9 years, 10 months ago) by tedu
Branch: MAIN
Changes since 1.170: +2 -2 lines
Diff to previous 1.170 (colored)

add a size argument to free. will be used soon, but for now default to 0.
after discussions with beck deraadt kettenis.

Revision 1.170 / (download) - annotate - [select for diffs], Fri Jul 11 16:35:40 2014 UTC (9 years, 10 months ago) by jsg
Branch: MAIN
Changes since 1.169: +2 -7 lines
Diff to previous 1.169 (colored)

Chuck Cranor rescinded clauses in his license
on the 2nd of February 2011 in NetBSD.

http://marc.info/?l=netbsd-source-changes&m=129658899212732&w=2
http://marc.info/?l=netbsd-source-changes&m=129659095515558&w=2
http://marc.info/?l=netbsd-source-changes&m=129659157916514&w=2
http://marc.info/?l=netbsd-source-changes&m=129665962324372&w=2
http://marc.info/?l=netbsd-source-changes&m=129666033625342&w=2
http://marc.info/?l=netbsd-source-changes&m=129666052825545&w=2
http://marc.info/?l=netbsd-source-changes&m=129666922906480&w=2
http://marc.info/?l=netbsd-source-changes&m=129667725518082&w=2

Revision 1.169 / (download) - annotate - [select for diffs], Fri Jun 13 01:48:52 2014 UTC (9 years, 11 months ago) by matthew
Branch: MAIN
Changes since 1.168: +68 -25 lines
Diff to previous 1.168 (colored)

Add support for MAP_INHERIT_ZERO.

This provides a way for a process to designate pages in its address
space that should be replaced by fresh, zero-initialized anonymous
memory in forked child processes, rather than being copied or shared.

ok jmc, kettenis, tedu, deraadt; positive feedback from many more

Revision 1.168 / (download) - annotate - [select for diffs], Thu May 15 03:52:25 2014 UTC (10 years ago) by guenther
Branch: MAIN
Changes since 1.167: +19 -15 lines
Diff to previous 1.167 (colored)

Move from struct proc to process the reference-count-holding pointers
to the process's vmspace and filedescs.  struct proc continues to
keep copies of the pointers, copying them on fork, clearing them
on exit, and (for vmspace) refreshing on exec.
Also, make uvm_swapout_threads() thread aware, eliminating p_swtime
in kernel.

particular testing by ajacoutot@ and sebastia@

Revision 1.167 / (download) - annotate - [select for diffs], Sun Apr 13 23:14:15 2014 UTC (10 years, 1 month ago) by tedu
Branch: MAIN
Changes since 1.166: +94 -309 lines
Diff to previous 1.166 (colored)

compress code by turning four line comments into one line comments.
emphatic ok usual suspects, grudging ok miod

Revision 1.166 / (download) - annotate - [select for diffs], Thu Apr 10 01:40:04 2014 UTC (10 years, 1 month ago) by tedu
Branch: MAIN
Changes since 1.165: +10 -10 lines
Diff to previous 1.165 (colored)

rename waitable to waitok as suggested by kettenis

Revision 1.165 / (download) - annotate - [select for diffs], Thu Apr 3 21:40:10 2014 UTC (10 years, 2 months ago) by tedu
Branch: MAIN
Changes since 1.164: +14 -6 lines
Diff to previous 1.164 (colored)

add a uvm_yield function and use it in the reaper path to prevent the
reaper from hogging the cpu. it will do the kernel lock twiddle trick to
allow other CPUs a chance to run, and also checks if the reaper has been
running for an entire timeslice and should be preempted.
ok deraadt

Revision 1.164 / (download) - annotate - [select for diffs], Thu Jan 23 22:06:30 2014 UTC (10 years, 4 months ago) by miod
Branch: MAIN
CVS Tags: OPENBSD_5_5_BASE, OPENBSD_5_5
Changes since 1.163: +1 -5 lines
Diff to previous 1.163 (colored)

unifdef -D__HAVE_VM_PAGE_MD - no functional change.

Revision 1.163 / (download) - annotate - [select for diffs], Sat Sep 21 10:01:27 2013 UTC (10 years, 8 months ago) by miod
Branch: MAIN
Changes since 1.162: +9 -7 lines
Diff to previous 1.162 (colored)

Don't invoke pmap_copy() on map holes.

Revision 1.162 / (download) - annotate - [select for diffs], Thu May 30 15:17:59 2013 UTC (11 years ago) by tedu
Branch: MAIN
CVS Tags: OPENBSD_5_4_BASE, OPENBSD_5_4
Changes since 1.161: +1 -21 lines
Diff to previous 1.161 (colored)

remove simple_locks from uvm code. ok beck deraadt

Revision 1.161 / (download) - annotate - [select for diffs], Wed Apr 17 23:22:42 2013 UTC (11 years, 1 month ago) by tedu
Branch: MAIN
Changes since 1.160: +3 -2 lines
Diff to previous 1.160 (colored)

it is better if we always start addr at something reasonable, and
then move it up. previous revision would leave addr uninitialized.
pointed out by oga at nicotinebsd.org

Revision 1.160 / (download) - annotate - [select for diffs], Wed Apr 17 17:46:53 2013 UTC (11 years, 1 month ago) by tedu
Branch: MAIN
Changes since 1.159: +13 -4 lines
Diff to previous 1.159 (colored)

do not permanently avoid the BRKSIZ gap in the heap for mmap. after some
allocations have been made, open it up. this is a variation on a previous
change that was lost in the great uvm map rewrite. allows some platforms,
notably i386, to fully utilize their address space.

Revision 1.159 / (download) - annotate - [select for diffs], Sun Feb 10 19:19:30 2013 UTC (11 years, 3 months ago) by beck
Branch: MAIN
CVS Tags: OPENBSD_5_3_BASE, OPENBSD_5_3
Changes since 1.158: +28 -9 lines
Diff to previous 1.158 (colored)

Don't wait for memory from pool while holding vm_map_lock or we can
deadlock ourselves - based on an infrequent hang caught by sthen, and
diagnosed by kettenis and me. Fix after some iterations is to simply
call uvm_map_allocate and allocate the map entry before grabbing the
lock so we don't wait while holding the lock.
ok miod@ kettenis@

Revision 1.158 / (download) - annotate - [select for diffs], Thu Oct 18 08:46:23 2012 UTC (11 years, 7 months ago) by gerhard
Branch: MAIN
Changes since 1.157: +10 -5 lines
Diff to previous 1.157 (colored)

Wiring map entries with VM_PROT_NONE only waists RAM and bears no
advantages. We shouln't do this. If the protection changes later on
(and VM_MAP_WIREFUTURE was set), uvm_map_protect() will wire them.
Found by Matthias Pitzl.

ok miod@ markus@

Revision 1.157 / (download) - annotate - [select for diffs], Thu Jun 14 15:54:36 2012 UTC (11 years, 11 months ago) by ariane
Branch: MAIN
CVS Tags: OPENBSD_5_2_BASE, OPENBSD_5_2
Changes since 1.156: +1 -3 lines
Diff to previous 1.156 (colored)

Remove uvm_km_kmem_grow printf.

It's no longer required, code is stable.

ok kettenis@

Revision 1.156 / (download) - annotate - [select for diffs], Thu Jun 14 11:57:18 2012 UTC (11 years, 11 months ago) by jasper
Branch: MAIN
Changes since 1.155: +2 -2 lines
Diff to previous 1.155 (colored)

fix typo in comment

ok ariane@

Revision 1.155 / (download) - annotate - [select for diffs], Sun Jun 3 13:30:04 2012 UTC (12 years ago) by kettenis
Branch: MAIN
Changes since 1.154: +3 -2 lines
Diff to previous 1.154 (colored)

Make sure uvm_map_extract() entesr mappings at an address that doesn't
introduce any virtual cache aliasing problems.  Fixes a regression introduced
by vmmap.

ok ariane@, jsing@

Revision 1.154 / (download) - annotate - [select for diffs], Fri Jun 1 05:47:10 2012 UTC (12 years ago) by guenther
Branch: MAIN
Changes since 1.153: +6 -2 lines
Diff to previous 1.153 (colored)

Correct handling of mlock()/munlock() with len==0 to return success
instead of crashing.  Add a KASSERT() to catch other bugs that might
result in the tree iterators being reversed.

Problem observed by Tom Doherty (tomd at singlesecond.com)
ok deraadt@

Revision 1.153 / (download) - annotate - [select for diffs], Thu Apr 19 12:42:03 2012 UTC (12 years, 1 month ago) by ariane
Branch: MAIN
Changes since 1.152: +100 -13 lines
Diff to previous 1.152 (colored)

Backout misplaced optimization in vmmap.

(That means the misplaced optimization is back in.)  It broke mips and
possibly other architectures.

Revision 1.152 / (download) - annotate - [select for diffs], Tue Apr 17 20:22:52 2012 UTC (12 years, 1 month ago) by ariane
Branch: MAIN
Changes since 1.151: +13 -100 lines
Diff to previous 1.151 (colored)

uvmspace_exec: Remove disfunctional "optimization".

The optimization goes through great lengths to use less optimized code
paths in place of the simple path, where the latter is actually faster.

ok tedu, guenther

Revision 1.151 / (download) - annotate - [select for diffs], Wed Apr 11 11:23:22 2012 UTC (12 years, 1 month ago) by ariane
Branch: MAIN
Changes since 1.150: +79 -39 lines
Diff to previous 1.150 (colored)

vmmap: speed up allocations

Reduces O(n log n) allocations to O(log n).

ok deraadt, tedu

Revision 1.150 / (download) - annotate - [select for diffs], Thu Mar 15 22:22:28 2012 UTC (12 years, 2 months ago) by ariane
Branch: MAIN
Changes since 1.149: +22 -8 lines
Diff to previous 1.149 (colored)

Fix vmmap SMALL_KERNEL introduced bug.

The
	if (min < VMMAP_MIN_ADDR)
		min = VMMAP_MIN_ADDR;
code should have moved across when the small_kernel diff moved the
initialization from uvm_map_setup() to uvm_map_setup_md().
Prevents a nasty panic on hppa, sparc64 (and possibly other archs).

kettenis: the diff make some sense to me

Revision 1.149 / (download) - annotate - [select for diffs], Thu Mar 15 17:52:28 2012 UTC (12 years, 2 months ago) by ariane
Branch: MAIN
Changes since 1.148: +90 -39 lines
Diff to previous 1.148 (colored)

Reduce installmedia pressure from new vmmap.

Has less special allocators on install media (where they aren't required
anyway).
Bonus: makes the vmmap initialization code easier to read.

Revision 1.148 / (download) - annotate - [select for diffs], Fri Mar 9 13:01:29 2012 UTC (12 years, 2 months ago) by ariane
Branch: MAIN
Changes since 1.147: +4071 -2923 lines
Diff to previous 1.147 (colored)

New vmmap implementation.

no oks (it is really a pain to review properly)
extensively tested, I'm confident it'll be stable
'now is the time' from several icb inhabitants

Diff provides:
- ability to specify different allocators for different regions/maps
- a simpler implementation of the current allocator
- currently in compatibility mode: it will generate similar addresses
  as the old allocator

Revision 1.147 / (download) - annotate - [select for diffs], Thu Nov 24 18:47:34 2011 UTC (12 years, 6 months ago) by guenther
Branch: MAIN
CVS Tags: OPENBSD_5_1_BASE, OPENBSD_5_1
Changes since 1.146: +3 -3 lines
Diff to previous 1.146 (colored)

Fix spelling and remove question

Revision 1.146 / (download) - annotate - [select for diffs], Tue Nov 8 11:42:43 2011 UTC (12 years, 6 months ago) by miod
Branch: MAIN
Changes since 1.145: +9 -4 lines
Diff to previous 1.145 (colored)

In ddb `show page', print the address of the vm_page_md substruct if
defined(__HAVE_VM_PAGE_MD), for convenience.

Revision 1.145 / (download) - annotate - [select for diffs], Tue Jul 5 03:10:29 2011 UTC (12 years, 11 months ago) by dhill
Branch: MAIN
CVS Tags: OPENBSD_5_0_BASE, OPENBSD_5_0
Changes since 1.144: +2 -2 lines
Diff to previous 1.144 (colored)

allow option KVA_GUARDPAGES to compile.

Revision 1.144 / (download) - annotate - [select for diffs], Sun Jul 3 18:36:49 2011 UTC (12 years, 11 months ago) by oga
Branch: MAIN
Changes since 1.143: +2 -35 lines
Diff to previous 1.143 (colored)

endodoify UVM_CNT too.

``beat it'' tedu@ the deleteotron

Revision 1.143 / (download) - annotate - [select for diffs], Sun Jul 3 18:34:14 2011 UTC (12 years, 11 months ago) by oga
Branch: MAIN
Changes since 1.142: +1 -138 lines
Diff to previous 1.142 (colored)

Rip out and burn support for UVM_HIST.

The vm hackers don't use it, don't maintain it and have to look at it all the
time. About time this 800 lines of code hit /dev/null.

``never liked it'' tedu@. ariane@ was very happy when i told her i wrote
this diff.

Revision 1.142 / (download) - annotate - [select for diffs], Thu Jun 30 15:51:06 2011 UTC (12 years, 11 months ago) by tedu
Branch: MAIN
Changes since 1.141: +6 -11 lines
Diff to previous 1.141 (colored)

finish ansi in uvm.  ok ariane oga

Revision 1.141 / (download) - annotate - [select for diffs], Mon Jun 6 17:10:23 2011 UTC (12 years, 11 months ago) by ariane
Branch: MAIN
Changes since 1.140: +3126 -4011 lines
Diff to previous 1.140 (colored)

Backout vmmap in order to repair virtual address selection algorithms
outside the tree.

Revision 1.140 / (download) - annotate - [select for diffs], Fri Jun 3 16:20:29 2011 UTC (13 years ago) by deraadt
Branch: MAIN
Changes since 1.139: +1 -2 lines
Diff to previous 1.139 (colored)

randomness might be broken, but this change
a) chooses incorrect kernel memory on the macppc
b) perhaps on zaurus too, which does not make it to copyright
c) was not tested on those platforms before commit

Revision 1.139 / (download) - annotate - [select for diffs], Wed Jun 1 22:29:25 2011 UTC (13 years ago) by ariane
Branch: MAIN
Changes since 1.138: +3 -2 lines
Diff to previous 1.138 (colored)

Oops, I broke randomness. (Please upgrade, this is _bad_.)

sel_addr &= ~(pmap_align - 1);
with pmap_align allowed to be 0 (no PMAP_PREFER) is a bad idea.
Fix this by a conditional.

ok oga@

Revision 1.138 / (download) - annotate - [select for diffs], Sun May 29 17:18:22 2011 UTC (13 years ago) by ariane
Branch: MAIN
Changes since 1.137: +4 -3 lines
Diff to previous 1.137 (colored)

Replace the lower bound PAGE_SIZE with VMMAP_MIN_ADDR.
This makes writing a diff that makes 64-bit unclean applications explode
a one-line diff.

ok deraadt

Revision 1.137 / (download) - annotate - [select for diffs], Sun May 29 15:18:19 2011 UTC (13 years ago) by ariane
Branch: MAIN
Changes since 1.136: +37 -24 lines
Diff to previous 1.136 (colored)

Fix parameter range clamping in vmmap routines.
The old VM_MAP_RANGE_CHECK macro was wrong and caused code to be unreadable
(argument altering macros are harmful).

Each function now treats the memory range outside the map as it would treat
free memory: if it would error on being given free memory, it'll error
in a similar fashion when the start,end parameters fall outside the map.
If it would accept free memory in its argument range, it'll silently accept
the outside-map memory too.

Confirmed to help ports build machines.

Revision 1.136 / (download) - annotate - [select for diffs], Tue May 24 15:27:36 2011 UTC (13 years ago) by ariane
Branch: MAIN
Changes since 1.135: +3939 -3068 lines
Diff to previous 1.135 (colored)

Reimplement uvm/uvm_map.

vmmap is designed to perform address space randomized allocations,
without letting fragmentation of the address space go through the roof.

Some highlights:
- kernel address space randomization
- proper implementation of guardpages
- roughly 10% system time reduction during kernel build

Tested by alot of people on tech@ and developers.
Theo's machines are still happy.

Revision 1.135 / (download) - annotate - [select for diffs], Tue Apr 26 23:50:21 2011 UTC (13 years, 1 month ago) by ariane
Branch: MAIN
Changes since 1.134: +9 -1 lines
Diff to previous 1.134 (colored)

MMU address space holes are at a fixed position (ofcourse).
Therefore set UVM_FLAG_FIXED and enforce this.

ok oga@

Revision 1.134 / (download) - annotate - [select for diffs], Mon Apr 18 19:23:46 2011 UTC (13 years, 1 month ago) by art
Branch: MAIN
Changes since 1.133: +4 -3 lines
Diff to previous 1.133 (colored)

Put back the change of pool and malloc into the new km_alloc(9) api.
The problems during the hackathon were not caused by this (most likely).

prodded by deraadt@ and beck@

Revision 1.133 / (download) - annotate - [select for diffs], Wed Apr 6 15:52:13 2011 UTC (13 years, 2 months ago) by art
Branch: MAIN
Changes since 1.132: +3 -4 lines
Diff to previous 1.132 (colored)

Backout the uvm_km_getpage -> km_alloc conversion. Weird things are happening
and we aren't sure what's causing them.

shouted oks by many before I even built a kernel with the diff.

Revision 1.132 / (download) - annotate - [select for diffs], Tue Apr 5 01:28:05 2011 UTC (13 years, 2 months ago) by art
Branch: MAIN
Changes since 1.131: +4 -3 lines
Diff to previous 1.131 (colored)

 - Change pool constraints to use kmem_pa_mode instead of uvm_constraint_range
 - Use km_alloc for all backend allocations in pools.
 - Use km_alloc for the emergmency kentry allocations in uvm_mapent_alloc
 - Garbage collect uvm_km_getpage, uvm_km_getpage_pla and uvm_km_putpage

ariane@ ok

Revision 1.131 / (download) - annotate - [select for diffs], Fri Dec 24 21:49:04 2010 UTC (13 years, 5 months ago) by tedu
Branch: MAIN
CVS Tags: OPENBSD_4_9_BASE, OPENBSD_4_9
Changes since 1.130: +5 -3 lines
Diff to previous 1.130 (colored)

add a param to uvm_map_hint to not skip over the heap, and use it as a last
resort if mmap fails otherwise to enable more complete address space
utilization.  tested for a while with no ill effects.

Revision 1.130 / (download) - annotate - [select for diffs], Wed Dec 15 04:59:52 2010 UTC (13 years, 5 months ago) by tedu
Branch: MAIN
Changes since 1.129: +3 -5 lines
Diff to previous 1.129 (colored)

add a BRKSIZ define and use it for the heap gap constant, decoupling
heap gap from max data size.  nothing else changes yet.  ok deraadt

Revision 1.129 / (download) - annotate - [select for diffs], Mon Dec 6 20:57:19 2010 UTC (13 years, 5 months ago) by miod
Branch: MAIN
Changes since 1.128: +3 -3 lines
Diff to previous 1.128 (colored)

Change the signature of PMAP_PREFER from void PMAP_PREFER(..., vaddr_t *) to
vaddr_t PMAP_PREFER(..., vaddr_t). This allows better compiler optimization
when the function is inlined, and avoids accessing memory on architectures
when we can pass function arguments in registers.

Revision 1.128 / (download) - annotate - [select for diffs], Wed Sep 29 18:04:33 2010 UTC (13 years, 8 months ago) by thib
Branch: MAIN
Changes since 1.127: +43 -28 lines
Diff to previous 1.127 (colored)

Band-aid to prevent uvm_mapent_alloc() sleeping with the pseg mutex held
(as this trips assertwaitok() in pool_get()).

This should get revisited soon.

"Commit it!" from many, as people like to be able to hit swap
without havoc.

Revision 1.127 / (download) - annotate - [select for diffs], Thu Jun 17 16:11:20 2010 UTC (13 years, 11 months ago) by miod
Branch: MAIN
CVS Tags: OPENBSD_4_8_BASE, OPENBSD_4_8
Changes since 1.126: +2 -2 lines
Diff to previous 1.126 (colored)

aligment -> alignment

Revision 1.126 / (download) - annotate - [select for diffs], Mon Apr 26 05:48:19 2010 UTC (14 years, 1 month ago) by deraadt
Branch: MAIN
Changes since 1.125: +3 -3 lines
Diff to previous 1.125 (colored)

cut down simple locks (so simple that they don't even lock) to the point
where there is almost nothing left to them, so that we can continue getting
rid of them
ok oga

Revision 1.125 / (download) - annotate - [select for diffs], Fri Apr 23 04:49:46 2010 UTC (14 years, 1 month ago) by tedu
Branch: MAIN
Changes since 1.124: +18 -21 lines
Diff to previous 1.124 (colored)

remove unnecessary temp_entry variables and hoist simple check out of a loop.
no functional change.  from Anton Maksimenkov

Revision 1.124 / (download) - annotate - [select for diffs], Thu Apr 22 19:02:55 2010 UTC (14 years, 1 month ago) by oga
Branch: MAIN
Changes since 1.123: +6 -4 lines
Diff to previous 1.123 (colored)

Committing on behalf or ariane@.

recommit pmemrange:
        physmem allocator: change the view of free memory from single
        free pages to free ranges.  Classify memory based on region with
        associated use-counter (which is used to construct a priority
        list of where to allocate memory).

	Based on code from tedu@, help from many.

Useable now that bugs have been found and fixed in most architecture's
pmap.c

ok by everyone who has done a pmap or uvm commit in the last year.

Revision 1.123 / (download) - annotate - [select for diffs], Fri Aug 28 00:40:03 2009 UTC (14 years, 9 months ago) by ariane
Branch: MAIN
CVS Tags: OPENBSD_4_7_BASE, OPENBSD_4_7
Changes since 1.122: +69 -8 lines
Diff to previous 1.122 (colored)

kva_guardpages: make guard pages separate map entries
- fixes ps(1)
- fixes kva deadbeef entries

Revision 1.122 / (download) - annotate - [select for diffs], Mon Aug 24 22:45:29 2009 UTC (14 years, 9 months ago) by miod
Branch: MAIN
Changes since 1.121: +2 -2 lines
Diff to previous 1.121 (colored)

Properly check for VM_MAX_KERNEL_ADDRESS wraparound in the guard pages code.
ok ariane@

Revision 1.121 / (download) - annotate - [select for diffs], Thu Aug 13 20:40:13 2009 UTC (14 years, 9 months ago) by ariane
Branch: MAIN
Changes since 1.120: +39 -1 lines
Diff to previous 1.120 (colored)

Enable guard pages and slow recycling of kva.
Debugging aid, hiding in "option KVA_GUARDPAGES" in config.

Revision 1.120 / (download) - annotate - [select for diffs], Thu Aug 6 15:28:14 2009 UTC (14 years, 9 months ago) by oga
Branch: MAIN
Changes since 1.119: +4 -5 lines
Diff to previous 1.119 (colored)

reintroduce the uvm_tree commit.

Now instead of the global object hashtable, we have a per object tree.

Testing shows no performance difference and a slight code shrink. OTOH when
locking is more fine grained this should be faster due to lock contention on
uvm.hashlock.

ok thib@, art@.

Revision 1.119 / (download) - annotate - [select for diffs], Sat Jul 25 12:55:40 2009 UTC (14 years, 10 months ago) by miod
Branch: MAIN
Changes since 1.118: +8 -5 lines
Diff to previous 1.118 (colored)

Add an extra argument to uvm_unmap_remove(), for the caller to tell it
whether removing holes or parts of them is allowed or not.
Only allow hole removal in uvmspace_free(), when tearing the vmspace down.

ok art@

Revision 1.118 / (download) - annotate - [select for diffs], Wed Jun 17 00:13:59 2009 UTC (14 years, 11 months ago) by oga
Branch: MAIN
CVS Tags: OPENBSD_4_6_BASE, OPENBSD_4_6
Changes since 1.117: +0 -0 lines
Diff to previous 1.117 (colored)

date based reversion of uvm to the 4th May.

More backouts in line with previous ones, this appears to bring us back to a
stable condition.

A machine forced to 64mb of ram cycled 10GB through swap with this diff
and is still running as I type this. Other tests by ariane@ and thib@
also seem to show that it's alright.

ok deraadt@, thib@, ariane@

Revision 1.117 / (download) - annotate - [select for diffs], Tue Jun 16 16:42:41 2009 UTC (14 years, 11 months ago) by ariane
Branch: MAIN
Changes since 1.116: +6 -9 lines
Diff to previous 1.116 (colored)

Backout pmemrange (which to most people is more well known as physmem
allocator).

"i can't see any obvious problems" oga

Revision 1.116 / (download) - annotate - [select for diffs], Tue Jun 16 00:11:29 2009 UTC (14 years, 11 months ago) by oga
Branch: MAIN
Changes since 1.115: +15 -5 lines
Diff to previous 1.115 (colored)

Backout all changes to uvm after pmemrange (which will be backed out
separately).

a change at or just before the hackathon has either exposed or added a
very very nasty memory corruption bug that is giving us hell right now.
So in the interest of kernel stability these diffs are being backed out
until such a time as that corruption bug has been found and squashed,
then the ones that are proven good may slowly return.

a quick hitlist of the main commits this backs out:

mine:
uvm_objwire
the lock change in uvm_swap.c
using trees for uvm objects instead of the hash
removing the pgo_releasepg callback.

art@'s:
putting pmap_page_protect(VM_PROT_NONE) in uvm_pagedeactivate() since
all callers called that just prior anyway.

ok beck@, ariane@.

prompted by deraadt@.

Revision 1.115 / (download) - annotate - [select for diffs], Sun Jun 14 02:53:09 2009 UTC (14 years, 11 months ago) by deraadt
Branch: MAIN
Changes since 1.114: +5 -3 lines
Diff to previous 1.114 (colored)

Noone else ever saw this diff except oga and ariane, so that is an
utter failure of process.

Revision 1.114 / (download) - annotate - [select for diffs], Tue Jun 9 20:07:59 2009 UTC (14 years, 11 months ago) by oga
Branch: MAIN
Changes since 1.113: +4 -6 lines
Diff to previous 1.113 (colored)

correct loop in debug code to not use an uninitialised page. it was
ass-backwards.

afaik this was found by the LLVM CLang static analyser.

ok ariane@ a couple of days ago.

Revision 1.113 / (download) - annotate - [select for diffs], Sat Jun 6 17:46:44 2009 UTC (14 years, 11 months ago) by art
Branch: MAIN
Changes since 1.112: +2 -10 lines
Diff to previous 1.112 (colored)

Since all callers of uvm_pagedeactivate did pmap_page_protect(.., VM_PROT_NONE)
just move that into uvm_pagedeactivate.

oga@ ok

Revision 1.112 / (download) - annotate - [select for diffs], Tue Jun 2 23:00:19 2009 UTC (15 years ago) by oga
Branch: MAIN
Changes since 1.111: +4 -6 lines
Diff to previous 1.111 (colored)

Instead of the global hash table with the terrible hashfunction and a
global lock, switch the uvm object pages to being kept in a per-object
RB_TREE. Right now this is approximately the same speed, but cleaner.
When biglock usage is reduced this will improve concurrency due to lock
contention..

ok beck@ art@. Thanks to jasper for the speed testing.

Revision 1.111 / (download) - annotate - [select for diffs], Mon Jun 1 17:42:33 2009 UTC (15 years ago) by ariane
Branch: MAIN
Changes since 1.110: +9 -6 lines
Diff to previous 1.110 (colored)

physmem allocator: change the view of free memory from single free pages
to free ranges.
Classify memory based on region with associated use-counter (which is used
to construct a priority list of where to allocate memory).

Based on code from tedu@, help from many.
Ok art@

Revision 1.110 / (download) - annotate - [select for diffs], Sat May 2 12:54:42 2009 UTC (15 years, 1 month ago) by oga
Branch: MAIN
Changes since 1.109: +2 -4 lines
Diff to previous 1.109 (colored)

a few more memset changes.

two cases of pool_get() + memset(0) -> pool_get(,,,PR_ZERO)
1.5 cases of global variables are already zeroed, so don't zero them.

ok ariane@, comments on stuff i'd missed from blambert@ and cnst@.

Revision 1.109 / (download) - annotate - [select for diffs], Wed Mar 25 20:00:18 2009 UTC (15 years, 2 months ago) by oga
Branch: MAIN
Changes since 1.108: +115 -2 lines
Diff to previous 1.108 (colored)

Move all of the pseudo-inline functions in uvm into C files.

By pseudo-inline, I mean that if a certain macro was defined, they would
be inlined. However, no architecture defines that, and none has for a
very very long time. Therefore mainly this just makes the code a damned
sight easier to read. Some k&r -> ansi declarations while I'm in there.

"just commit it" art@. ok weingart@.

Revision 1.108 / (download) - annotate - [select for diffs], Mon Nov 10 18:11:59 2008 UTC (15 years, 6 months ago) by oga
Branch: MAIN
CVS Tags: OPENBSD_4_5_BASE, OPENBSD_4_5
Changes since 1.107: +2 -2 lines
Diff to previous 1.107 (colored)

typo: be -> by in comment

``of course'' deraadt@.

Revision 1.107 / (download) - annotate - [select for diffs], Tue Nov 4 21:37:06 2008 UTC (15 years, 7 months ago) by deraadt
Branch: MAIN
Changes since 1.106: +1 -27 lines
Diff to previous 1.106 (colored)

uvmspace_unshare() is never used; ok miod

Revision 1.106 / (download) - annotate - [select for diffs], Thu Oct 23 23:54:02 2008 UTC (15 years, 7 months ago) by tedu
Branch: MAIN
Changes since 1.105: +3 -2 lines
Diff to previous 1.105 (colored)

a better fix for the "uvm_km thread runs out of memory" problem.

add a new arg to the backend so it can tell pool to slow down.  when we get
this flag, yield *after* putting the page in the pool's free list.  whatever
we do, don't let the thread sleep.

this makes things better by still letting the thread run when a huge pf
request comes in, but without artificially increasing pressure on the backend
by eating pages without feeding them forward.

ok deraadt

Revision 1.105 / (download) - annotate - [select for diffs], Wed Oct 8 08:41:19 2008 UTC (15 years, 7 months ago) by art
Branch: MAIN
Changes since 1.104: +3 -5 lines
Diff to previous 1.104 (colored)

Don't extend amaps beyond what their supposed maximum. This code path is
not taken anymore, but it doesn't hurt to be correct.

from NetBSD, through mickey in pr 5812
prodded by otto@

Revision 1.104 / (download) - annotate - [select for diffs], Tue Sep 23 13:25:46 2008 UTC (15 years, 8 months ago) by art
Branch: MAIN
Changes since 1.103: +12 -1 lines
Diff to previous 1.103 (colored)

Do not merge userland map entries.

 Imagine lots of random small mappings (think malloc(3)) and sometimes
 one large mapping (network buffer). If we've filled up our address space
 enough, the random address picked for the large allocation is likely to
 be overlapping an existing small allocation, so we'll do a linear scan
 to find the next free address. That next free address is likely to
 be just after a small allocation. Those two map entires get merged.
 If we now allocate an amap for the merged map entry, it will be large.
 When we later free the large allocation the amap is not truncated. All
 these are design decisions that made sense for sbrk, but with random
 allocations and malloc that actually returns memory, this really hurt us.

 This is the reason why certain processes like apache and sendmail could
 eat more than 10 times as much amap memory as they needed, eventually
 hitting the malloc limit and hanging or running the machine out of
 kmem_map and crashing.

otto@ ok

Revision 1.103 / (download) - annotate - [select for diffs], Fri Jul 25 12:05:04 2008 UTC (15 years, 10 months ago) by art
Branch: MAIN
CVS Tags: OPENBSD_4_4_BASE, OPENBSD_4_4
Changes since 1.102: +5 -10 lines
Diff to previous 1.102 (colored)

Correct printing of the pg_flags for ddb.

Revision 1.102 / (download) - annotate - [select for diffs], Fri Jul 25 12:02:09 2008 UTC (15 years, 10 months ago) by art
Branch: MAIN
Changes since 1.101: +5 -1 lines
Diff to previous 1.101 (colored)

some splassert paranoia.

Revision 1.101 / (download) - annotate - [select for diffs], Fri Jul 18 16:40:17 2008 UTC (15 years, 10 months ago) by kurt
Branch: MAIN
Changes since 1.100: +40 -1 lines
Diff to previous 1.100 (colored)

Add new uvm function called uvm_map_pie() which takes align as a
parameter and returns an aligned random load address for position
independent executables to use. This also adds three new vmparam.h
defines to specify the maximum address, minimum address and minimum
allowed alignment for uvm_map_pie() to use. The PIE address range
for i386 was carefully selected to work well within the i386 W^X
framework.

With much help and feedback from weingart@.
okay weingart@, miod@, kettenis@, drahn@

Revision 1.100 / (download) - annotate - [select for diffs], Mon Jun 9 20:30:23 2008 UTC (15 years, 11 months ago) by miod
Branch: MAIN
Changes since 1.99: +6 -2 lines
Diff to previous 1.99 (colored)

Define a new flag, UVM_FLAG_HOLE, for uvm_map to create a vm_map_entry of
a new etype, UVM_ET_HOLE, meaning it has no backend.

UVM_ET_HOLE entries (which should be created as UVM_PROT_NONE and with
UVM_FLAG_NOMERGE and UVM_FLAG_HOLE) are skipped in uvm_unmap_remove(), so
that pmap_{k,}remove() is not called on the entry.

This is intended to save time, and behave better, on pmaps with MMU holes
at process exit time.

ok art@, kettenis@ provided feedback as well.

Revision 1.99 / (download) - annotate - [select for diffs], Sat Sep 15 10:10:37 2007 UTC (16 years, 8 months ago) by martin
Branch: MAIN
CVS Tags: OPENBSD_4_3_BASE, OPENBSD_4_3
Changes since 1.98: +4 -4 lines
Diff to previous 1.98 (colored)

replace ctob and btoc with ptoa and atop respectively

help and ok miod@ thib@

Revision 1.98 / (download) - annotate - [select for diffs], Mon Sep 10 18:49:45 2007 UTC (16 years, 8 months ago) by miod
Branch: MAIN
Changes since 1.97: +17 -10 lines
Diff to previous 1.97 (colored)

Introduce a md pmap hook, pmap_remove_holes(), which is supposed to mark
the holes a MMU may have from a given vm_map. This will be automagically
invoked for newly created vmspaces.

On platforms with MMU holes (e.g. sun4, sun4c and vax), this prevents
mmap(2) hints which would end up being in the hole to be accepted as valid,
causing unexpected signals when the process tries to access the hole
(since pmap can not fill the hole anyway).

Unfortunately, the logic mmap() uses to pick a valid address for anonymous
mappings needs work, as it will only try to find an address higher than the
hint, which causes all mmap() with a hint in the hole to fail on vax. This
will be improved later.

Revision 1.97 / (download) - annotate - [select for diffs], Wed Jul 18 17:00:20 2007 UTC (16 years, 10 months ago) by art
Branch: MAIN
CVS Tags: OPENBSD_4_2_BASE, OPENBSD_4_2
Changes since 1.96: +2 -2 lines
Diff to previous 1.96 (colored)

Indentation nit.

Revision 1.96 / (download) - annotate - [select for diffs], Mon Jun 18 21:51:15 2007 UTC (16 years, 11 months ago) by pedro
Branch: MAIN
Changes since 1.95: +4 -4 lines
Diff to previous 1.95 (colored)

Bring back Mickey's UVM anon change. Testing by thib@, beck@ and
ckuethe@ for a while. Okay beck@, "it is good timing" deraadt@.

Revision 1.95 / (download) - annotate - [select for diffs], Wed Jun 13 13:32:26 2007 UTC (16 years, 11 months ago) by art
Branch: MAIN
Changes since 1.94: +14 -16 lines
Diff to previous 1.94 (colored)

Remove some statics and inlines (mostly to get a readable profile output).

"reads ok" dlg@

Revision 1.94 / (download) - annotate - [select for diffs], Fri Jun 1 20:10:04 2007 UTC (17 years ago) by tedu
Branch: MAIN
Changes since 1.93: +2 -1 lines
Diff to previous 1.93 (colored)

set hiwat mark for some of the more popular pools to reduce bouncing
ok art bob

Revision 1.93 / (download) - annotate - [select for diffs], Thu May 31 21:20:30 2007 UTC (17 years ago) by thib
Branch: MAIN
Changes since 1.92: +2 -4 lines
Diff to previous 1.92 (colored)

zap the vm_amap am_l simplelock, and amap_{lock/unlock} macros for
simple_{lock/unlock}.

ok art@

Revision 1.92 / (download) - annotate - [select for diffs], Fri Apr 27 18:01:49 2007 UTC (17 years, 1 month ago) by art
Branch: MAIN
Changes since 1.91: +7 -1 lines
Diff to previous 1.91 (colored)

For uvm_map and uvm_unmap, splassert(IPL_NONE) for non-INTRSAFE maps.

miod@ ok

Revision 1.91 / (download) - annotate - [select for diffs], Fri Apr 27 16:23:49 2007 UTC (17 years, 1 month ago) by art
Branch: MAIN
Changes since 1.90: +7 -7 lines
Diff to previous 1.90 (colored)

Some indentation cleanup.
md5@ ok.

Revision 1.90 / (download) - annotate - [select for diffs], Sat Apr 14 14:11:13 2007 UTC (17 years, 1 month ago) by art
Branch: MAIN
Changes since 1.89: +113 -174 lines
Diff to previous 1.89 (colored)

Clean up.
 - ansi-fy
 - use struct vm_map * and struct vm_map_entry * instead of _t types
 - fix some indentation problems.

miod@ ok

Revision 1.89 / (download) - annotate - [select for diffs], Fri Apr 13 18:57:49 2007 UTC (17 years, 1 month ago) by art
Branch: MAIN
Changes since 1.88: +10 -10 lines
Diff to previous 1.88 (colored)

While splitting flags and pqflags might have been a good idea in theory
to separate locking, on most modern machines this is not enough
since operations on short types touch other short types that share the
same word in memory.

Merge pg_flags and pqflags again and now use atomic operations to change
the flags. Also bump wire_count to an int and pg_version might go
int as well, just for alignment.

tested by many, many. ok miod@

Revision 1.88 / (download) - annotate - [select for diffs], Thu Apr 12 18:59:55 2007 UTC (17 years, 1 month ago) by art
Branch: MAIN
Changes since 1.87: +3 -3 lines
Diff to previous 1.87 (colored)

Unbreak compile with option UVMHIST after pg_flags changes.
from mickey

Revision 1.87 / (download) - annotate - [select for diffs], Wed Apr 11 12:10:42 2007 UTC (17 years, 1 month ago) by art
Branch: MAIN
Changes since 1.86: +9 -14 lines
Diff to previous 1.86 (colored)

Instead of managing pages for intrsafe maps in special objects (aka.
kmem_object) just so that we can remove them, just use pmap_extract
to get the pages to free and simplify a lot of code to not deal with
the list of intrsafe maps, intrsafe objects, etc.

miod@ ok

Revision 1.86 / (download) - annotate - [select for diffs], Wed Apr 4 17:44:45 2007 UTC (17 years, 2 months ago) by art
Branch: MAIN
Changes since 1.85: +5 -5 lines
Diff to previous 1.85 (colored)

Mechanically rename the "flags" and "version" fields in struct vm_page
to "pg_flags" and "pg_version", so that they are a bit easier to work with.
Whoever uses generic names like this for a popular struct obviously doesn't
read much code.

Most architectures compile and there are no functionality changes.

deraadt@ ok ("if something fails to compile, we fix that by hand")

Revision 1.85 / (download) - annotate - [select for diffs], Tue Mar 27 16:13:45 2007 UTC (17 years, 2 months ago) by art
Branch: MAIN
Changes since 1.84: +21 -38 lines
Diff to previous 1.84 (colored)

Clean up some return value handling now that we know that what's returned
is proper errnos.

millert@ ok and some help

Revision 1.84 / (download) - annotate - [select for diffs], Mon Mar 26 08:43:34 2007 UTC (17 years, 2 months ago) by art
Branch: MAIN
Changes since 1.83: +19 -19 lines
Diff to previous 1.83 (colored)

Rip out the KERN_ error codes.
ok otto@

Revision 1.83 / (download) - annotate - [select for diffs], Sun Mar 25 11:31:07 2007 UTC (17 years, 2 months ago) by art
Branch: MAIN
Changes since 1.82: +17 -18 lines
Diff to previous 1.82 (colored)

remove KERN_SUCCESS and use 0 instead.
eyeballed by miod@ and pedro@

Revision 1.82 / (download) - annotate - [select for diffs], Mon Jul 31 11:51:29 2006 UTC (17 years, 10 months ago) by mickey
Branch: MAIN
CVS Tags: OPENBSD_4_1_BASE, OPENBSD_4_1, OPENBSD_4_0_BASE, OPENBSD_4_0
Changes since 1.81: +19 -19 lines
Diff to previous 1.81 (colored)

fix uvmhist #2: args are always u_long so fix missing %d and %x and no %ll; no change for normal code

Revision 1.81 / (download) - annotate - [select for diffs], Wed Jul 26 23:15:55 2006 UTC (17 years, 10 months ago) by mickey
Branch: MAIN
Changes since 1.80: +28 -28 lines
Diff to previous 1.80 (colored)

fix fmts for UVMHIST_LOG() entries making it more useful on 64bit archs; miod@ ok

Revision 1.80 / (download) - annotate - [select for diffs], Thu Jul 13 22:51:26 2006 UTC (17 years, 10 months ago) by deraadt
Branch: MAIN
Changes since 1.79: +3 -3 lines
Diff to previous 1.79 (colored)

Back out the anon change.  Apparently it was tested by a few, but most of
us did not see it or get a chance to test it before it was commited. It
broke cvs, in the ami driver, making it not succeed at seeing it's devices.

Revision 1.79 / (download) - annotate - [select for diffs], Wed Jun 21 16:20:05 2006 UTC (17 years, 11 months ago) by mickey
Branch: MAIN
Changes since 1.78: +4 -4 lines
Diff to previous 1.78 (colored)

from netbsd: make anons dynamically allocated from pool.
this results in lesse kva waste due to static preallocation of those
for every phys page and also every swap page.
tested by beck krw miod

Revision 1.78 / (download) - annotate - [select for diffs], Thu Apr 27 15:23:56 2006 UTC (18 years, 1 month ago) by mickey
Branch: MAIN
Changes since 1.77: +4 -3 lines
Diff to previous 1.77 (colored)

from PAE work:
as paddr_t could be a long long (soon) always cast and print as llx.

Revision 1.77 / (download) - annotate - [select for diffs], Mon Jan 16 13:11:05 2006 UTC (18 years, 4 months ago) by mickey
Branch: MAIN
CVS Tags: OPENBSD_3_9_BASE, OPENBSD_3_9
Changes since 1.76: +7 -1 lines
Diff to previous 1.76 (colored)

add another uvm histroy for physpage alloc/free and propagate a debugging pgfree check into pglist; no functional change for normal kernels; make histories uncommon

Revision 1.76 / (download) - annotate - [select for diffs], Mon Jan 2 15:05:45 2006 UTC (18 years, 5 months ago) by tom
Branch: MAIN
Changes since 1.75: +2 -2 lines
Diff to previous 1.75 (colored)

fix typo in comment

ok deraadt@

Revision 1.75 / (download) - annotate - [select for diffs], Sat Dec 10 16:06:10 2005 UTC (18 years, 5 months ago) by krw
Branch: MAIN
Changes since 1.74: +1 -4 lines
Diff to previous 1.74 (colored)

Don't check/free new_entry here, since it can't have been set. Spotted
by lint.

"Probably a bogus cut'n paste." says moid.

ok miod@ pedro@

Revision 1.74 / (download) - annotate - [select for diffs], Sat Dec 10 11:45:43 2005 UTC (18 years, 5 months ago) by miod
Branch: MAIN
Changes since 1.73: +3 -3 lines
Diff to previous 1.73 (colored)

{en,re}trys -> {en,re}tries; eyeballed by jmc@

Revision 1.73 / (download) - annotate - [select for diffs], Wed Sep 28 00:24:03 2005 UTC (18 years, 8 months ago) by pedro
Branch: MAIN
Changes since 1.72: +25 -9 lines
Diff to previous 1.72 (colored)

- when we run out of static kernel map entries, grab a fresh page using
  the uvm_km_page allocator and use it instead of calling panic()
- add a counter to uvmexp so we can keep track of how many map entries
  we have in use

idea from tedu@, long ago, okay deraadt@

Revision 1.72 / (download) - annotate - [select for diffs], Wed Jun 29 06:07:32 2005 UTC (18 years, 11 months ago) by deraadt
Branch: MAIN
CVS Tags: OPENBSD_3_8_BASE, OPENBSD_3_8
Changes since 1.71: +4 -1 lines
Diff to previous 1.71 (colored)

on the vax, start mmap BRKSIZ (8MB) into data seg; ok tdeval

Revision 1.71 / (download) - annotate - [select for diffs], Tue May 24 21:11:47 2005 UTC (19 years ago) by tedu
Branch: MAIN
Changes since 1.70: +13 -4 lines
Diff to previous 1.70 (colored)

add a new field to vm_space and use it to track the number of anon
pages a process uses.  this is now the userland "data size" value.
ok art deraadt tdeval.  thanks testers.

Revision 1.70 / (download) - annotate - [select for diffs], Thu Dec 30 08:28:39 2004 UTC (19 years, 5 months ago) by niklas
Branch: MAIN
CVS Tags: OPENBSD_3_7_BASE, OPENBSD_3_7
Changes since 1.69: +13 -6 lines
Diff to previous 1.69 (colored)

Import M_CANFAIL support from NetBSD, removes a nasty panic during low-mem scenarios, instead generating an ENOMEM backfeed, ok tedu@, prodded by many

Revision 1.69 / (download) - annotate - [select for diffs], Fri Aug 6 22:39:14 2004 UTC (19 years, 10 months ago) by deraadt
Branch: MAIN
CVS Tags: OPENBSD_3_6_BASE, OPENBSD_3_6
Changes since 1.68: +2 -5 lines
Diff to previous 1.68 (colored)

rename sparc kill_user_windows() to pmap_unuse_final().  provide empty stubs
on all other architectures.  remove last architecture dependent #ifdef from
uvm code.

Revision 1.68 / (download) - annotate - [select for diffs], Wed Jul 21 01:02:09 2004 UTC (19 years, 10 months ago) by art
Branch: MAIN
Changes since 1.67: +29 -21 lines
Diff to previous 1.67 (colored)

Yet another victim of inline masturbation.

Remove inline from a few functions, shrink the kernel by a few kB and
make things faster. A simple compilation on amd64 spends around 5%
less time in kernel.

Yes, it's faster without inlines, now go buy a book about modern cpu
architectures and find a chapter about the new and revolutionary thing
called "cache".

deraadt@ ok

Revision 1.3.4.12 / (download) - annotate - [select for diffs], Sat Jun 5 23:13:12 2004 UTC (20 years ago) by niklas
Branch: SMP
Changes since 1.3.4.11: +19 -1 lines
Diff to previous 1.3.4.11 (colored) to branchpoint 1.3 (colored) next main 1.4 (colored)

Merge with the trunk

Revision 1.65.2.2 / (download) - annotate - [select for diffs], Tue Jun 1 03:44:10 2004 UTC (20 years ago) by brad
Branch: OPENBSD_3_5
Changes since 1.65.2.1: +9 -2 lines
Diff to previous 1.65.2.1 (colored) to branchpoint 1.65 (colored) next main 1.66 (colored)

MFC:
Fix by tedu@

only free pages if we have write permission and they are not COW.
prevents msync/madvise funniness

ok deraadt@ art@

Revision 1.62.2.1 / (download) - annotate - [select for diffs], Tue Jun 1 02:54:56 2004 UTC (20 years ago) by brad
Branch: OPENBSD_3_4
Changes since 1.62: +9 -2 lines
Diff to previous 1.62 (colored) next main 1.63 (colored)

MFC:
Fix by tedu@

only free pages if we have write permission and they are not COW.
prevents msync/madvise funniness

ok deraadt@ art@

Revision 1.67 / (download) - annotate - [select for diffs], Sun May 30 22:35:43 2004 UTC (20 years ago) by tedu
Branch: MAIN
CVS Tags: SMP_SYNC_B, SMP_SYNC_A
Changes since 1.66: +9 -2 lines
Diff to previous 1.66 (colored)

only free pages if we have write permission and they are not COW.
prevents msync/madvise funniness
from art@ ok deraadt@

Revision 1.65.2.1 / (download) - annotate - [select for diffs], Fri May 14 21:34:24 2004 UTC (20 years ago) by brad
Branch: OPENBSD_3_5
Changes since 1.65: +4 -1 lines
Diff to previous 1.65 (colored)

MFC:
Fix by tedu@

protecing with NONE means we must drop the wired count.
solves problems encountered by david@ and dtucker@ (pr3758)

ok deradt@

Revision 1.66 / (download) - annotate - [select for diffs], Mon May 3 07:14:53 2004 UTC (20 years, 1 month ago) by tedu
Branch: MAIN
Changes since 1.65: +4 -1 lines
Diff to previous 1.65 (colored)

protecing with NONE means we must drop the wired count.
solves problems encountered by david@ and dtucker@ (pr3758)

Revision 1.65 / (download) - annotate - [select for diffs], Mon Feb 23 06:19:32 2004 UTC (20 years, 3 months ago) by drahn
Branch: MAIN
CVS Tags: OPENBSD_3_5_BASE
Branch point for: OPENBSD_3_5
Changes since 1.64: +9 -1 lines
Diff to previous 1.64 (colored)

sync of pmap_update() calls with NetBSD. pmap_update is defined away on
all architectures but arm, where it is needed.

Revision 1.34.2.8 / (download) - annotate - [select for diffs], Sat Feb 21 00:20:22 2004 UTC (20 years, 3 months ago) by tedu
Branch: UBC
Changes since 1.34.2.7: +2 -2 lines
Diff to previous 1.34.2.7 (colored) to branchpoint 1.34 (colored) next main 1.35 (colored)

add VEXECMAP.  also make sure to modify filepages count only in the not
execpages case in uvm_pageremove().
this actually appears to solve the swap freak out problems.  sitting on it for
a long time, never checked if it worked.  sigh.

Revision 1.3.4.11 / (download) - annotate - [select for diffs], Thu Feb 19 11:01:44 2004 UTC (20 years, 3 months ago) by niklas
Branch: SMP
Changes since 1.3.4.10: +18 -6 lines
Diff to previous 1.3.4.10 (colored) to branchpoint 1.3 (colored)

Merge of current from two weeks agointo the SMP branch

Revision 1.64 / (download) - annotate - [select for diffs], Tue Nov 18 06:08:19 2003 UTC (20 years, 6 months ago) by tedu
Branch: MAIN
Changes since 1.63: +3 -2 lines
Diff to previous 1.63 (colored)

faster pools.  split pagelist into full, partial, and empty so we find what
we're looking for.  change small page_header hash table to a splay tree.
from Chuck Silvers.
tested by brad grange henning mcbride naddy otto

Revision 1.63 / (download) - annotate - [select for diffs], Wed Oct 8 22:23:56 2003 UTC (20 years, 7 months ago) by tedu
Branch: MAIN
Changes since 1.62: +3 -3 lines
Diff to previous 1.62 (colored)

randomize return from uvm_map_hint.  the random increment is limited
to prevent fragmentation.
this has the effect of randomizing unhinted mmap()s, sysV mem, and
position of ld.so.

tested on many archs by many developers for quite some time.
use of MIN to allow m68k to play from miod@.
vax is not included.
ok deraadt@ miod@

Revision 1.62 / (download) - annotate - [select for diffs], Wed Sep 3 22:52:47 2003 UTC (20 years, 9 months ago) by tedu
Branch: MAIN
CVS Tags: OPENBSD_3_4_BASE
Branch point for: OPENBSD_3_4
Changes since 1.61: +2 -2 lines
Diff to previous 1.61 (colored)

m68k at least doesn't like random mappings.  disable for now.
i386 exec mappings are still random.  detected by pvalchev@.  ok deraadt@

Revision 1.61 / (download) - annotate - [select for diffs], Tue Sep 2 17:57:12 2003 UTC (20 years, 9 months ago) by tedu
Branch: MAIN
Changes since 1.60: +15 -4 lines
Diff to previous 1.60 (colored)

add a random offset to uvm_map_hint.  this has the primary effect of
scattering ld.so and libraries around, although all mmaps will also
have some jitter too.  better version after some discussion with drahn
testing/ok deraadt henning marcm otto pb

Revision 1.60 / (download) - annotate - [select for diffs], Sun Jun 29 17:31:12 2003 UTC (20 years, 11 months ago) by avsm
Branch: MAIN
Changes since 1.59: +2 -2 lines
Diff to previous 1.59 (colored)

quell a "not a pointer" warning by using 0x%lx instead of %p for a vaddr_t
suggested by art@

Revision 1.34.2.7 / (download) - annotate - [select for diffs], Mon May 19 22:41:29 2003 UTC (21 years ago) by tedu
Branch: UBC
Changes since 1.34.2.6: +23 -3 lines
Diff to previous 1.34.2.6 (colored) to branchpoint 1.34 (colored)

sync

Revision 1.3.4.10 / (download) - annotate - [select for diffs], Tue May 13 19:36:58 2003 UTC (21 years ago) by ho
Branch: SMP
Changes since 1.3.4.9: +20 -2 lines
Diff to previous 1.3.4.9 (colored) to branchpoint 1.3 (colored)

Sync the SMP branch to -current. This includes moving to ELF.

Revision 1.59 / (download) - annotate - [select for diffs], Mon May 5 17:54:59 2003 UTC (21 years, 1 month ago) by drahn
Branch: MAIN
CVS Tags: UBC_SYNC_A
Changes since 1.58: +2 -2 lines
Diff to previous 1.58 (colored)

Move exec base to 0x1c000000, exe/data gap to 512MB. Allows better
interleave of exe/shared libs. Raise MAXDSIZ back to 1G.
This change REQUIRES a binary update on i386.

Revision 1.58 / (download) - annotate - [select for diffs], Thu Apr 17 03:50:54 2003 UTC (21 years, 1 month ago) by drahn
Branch: MAIN
Changes since 1.57: +10 -1 lines
Diff to previous 1.57 (colored)

changes to support mquery with 1Gsep on i386. avoid heap on mappings.

Revision 1.57 / (download) - annotate - [select for diffs], Mon Apr 14 04:53:51 2003 UTC (21 years, 1 month ago) by art
Branch: MAIN
Changes since 1.56: +11 -2 lines
Diff to previous 1.56 (colored)

There are two related changes.

The first one is an mquery(2) syscall. It's for asking the VM system
about where to map things. It will be used by ld.so, read the man page
for details.

The second change is related and is a centralization of uvm_map hint
that all callers of uvm_map calculated. This will allow us to adjust
this hint on architectures that have segments for non-exec mappings.

deraadt@ drahn@ ok.

Revision 1.3.4.9 / (download) - annotate - [select for diffs], Fri Mar 28 00:08:48 2003 UTC (21 years, 2 months ago) by niklas
Branch: SMP
Changes since 1.3.4.8: +27 -15 lines
Diff to previous 1.3.4.8 (colored) to branchpoint 1.3 (colored)

Sync the SMP branch with 3.3

Revision 1.56 / (download) - annotate - [select for diffs], Mon Dec 9 02:35:21 2002 UTC (21 years, 5 months ago) by art
Branch: MAIN
CVS Tags: OPENBSD_3_3_BASE, OPENBSD_3_3
Changes since 1.55: +3 -1 lines
Diff to previous 1.55 (colored)

Two splasserts in map entry allocation.

Revision 1.34.2.6 / (download) - annotate - [select for diffs], Mon Nov 4 18:02:33 2002 UTC (21 years, 7 months ago) by art
Branch: UBC
Changes since 1.34.2.5: +59 -68 lines
Diff to previous 1.34.2.5 (colored) to branchpoint 1.34 (colored)

Huge sync to NetBSD plus lots of bugfixes.
 - uvm is as in netbsd-current minus uvm_map forward merge.
 - various locking bugfixes in nfs.
 - make sure that all specops and fifoops are correct in all vnodeop vectors.
 - make the filesystem code more like filsystem code and less like vm code.

Revision 1.55 / (download) - annotate - [select for diffs], Tue Oct 29 18:30:21 2002 UTC (21 years, 7 months ago) by art
Branch: MAIN
Changes since 1.54: +3 -4 lines
Diff to previous 1.54 (colored)

Since memory deallocation can't fail, remove the error return from
uvm_unmap, uvm_deallocate and a few other functions.
Simplifies some code and reduces diff to the UBC branch.

Revision 1.34.2.5 / (download) - annotate - [select for diffs], Tue Oct 29 02:12:53 2002 UTC (21 years, 7 months ago) by art
Branch: UBC
Changes since 1.34.2.4: +5 -5 lines
Diff to previous 1.34.2.4 (colored) to branchpoint 1.34 (colored)

Fix merge botches.

Revision 1.54 / (download) - annotate - [select for diffs], Tue Oct 29 01:26:58 2002 UTC (21 years, 7 months ago) by art
Branch: MAIN
Changes since 1.53: +2 -2 lines
Diff to previous 1.53 (colored)

"len = entry->end - entry->start;" then logically "entry->start + len"
should be equal to "entry->end". (len is never changed)

Revision 1.34.2.4 / (download) - annotate - [select for diffs], Tue Oct 29 00:36:50 2002 UTC (21 years, 7 months ago) by art
Branch: UBC
Changes since 1.34.2.3: +16 -10 lines
Diff to previous 1.34.2.3 (colored) to branchpoint 1.34 (colored)

sync to -current

Revision 1.53 / (download) - annotate - [select for diffs], Thu Oct 17 22:08:37 2002 UTC (21 years, 7 months ago) by art
Branch: MAIN
CVS Tags: UBC_SYNC_B
Changes since 1.52: +8 -4 lines
Diff to previous 1.52 (colored)

 - name in uvm_tree_sanity must be const.
 - fix a typo in comment.
 - enable uvm_tree_sanity ifdef DEBUG

Revision 1.52 / (download) - annotate - [select for diffs], Tue Sep 17 13:01:20 2002 UTC (21 years, 8 months ago) by mpech
Branch: MAIN
CVS Tags: OPENBSD_3_2_BASE, OPENBSD_3_2
Changes since 1.51: +4 -4 lines
Diff to previous 1.51 (colored)

int is small for returned values from uvm_rb_{space,subtree_space}, use
vsize_t instead.

art@ ok

Revision 1.51 / (download) - annotate - [select for diffs], Fri Aug 30 09:56:22 2002 UTC (21 years, 9 months ago) by espie
Branch: MAIN
Changes since 1.50: +2 -2 lines
Diff to previous 1.50 (colored)

__FUNCTION__ -> __func__ that I forgot to commit.

Revision 1.50 / (download) - annotate - [select for diffs], Tue Aug 20 23:21:17 2002 UTC (21 years, 9 months ago) by mickey
Branch: MAIN
Changes since 1.49: +2 -2 lines
Diff to previous 1.49 (colored)

print as unsigned for unsigned values, when printing out a map in ddb; art@ ok

Revision 1.49 / (download) - annotate - [select for diffs], Tue Jul 23 15:53:45 2002 UTC (21 years, 10 months ago) by art
Branch: MAIN
Changes since 1.48: +3 -1 lines
Diff to previous 1.48 (colored)

Now that sparc64 implements reverse splassert, it make sense
to add splassert(IPL_NONE) in a few strategic places.

Revision 1.48 / (download) - annotate - [select for diffs], Fri Jun 14 21:35:00 2002 UTC (21 years, 11 months ago) by todd
Branch: MAIN
Changes since 1.47: +2 -2 lines
Diff to previous 1.47 (colored)

spelling; from Brian Poole <raj@cerias.purdue.edu>

Revision 1.34.2.3 / (download) - annotate - [select for diffs], Tue Jun 11 03:33:03 2002 UTC (21 years, 11 months ago) by art
Branch: UBC
Changes since 1.34.2.2: +418 -26 lines
Diff to previous 1.34.2.2 (colored) to branchpoint 1.34 (colored)

Sync UBC branch to -current

Revision 1.47 / (download) - annotate - [select for diffs], Wed Jun 5 17:40:08 2002 UTC (22 years ago) by art
Branch: MAIN
Changes since 1.46: +7 -2 lines
Diff to previous 1.46 (colored)

DIAGNOSTIC check for duplicate entry into the tree.
niels@ ok.

Revision 1.46 / (download) - annotate - [select for diffs], Mon Apr 29 06:26:51 2002 UTC (22 years, 1 month ago) by pvalchev
Branch: MAIN
Changes since 1.45: +2 -2 lines
Diff to previous 1.45 (colored)

wierd -> weird

Revision 1.3.4.8 / (download) - annotate - [select for diffs], Thu Mar 28 14:54:26 2002 UTC (22 years, 2 months ago) by niklas
Branch: SMP
Changes since 1.3.4.7: +219 -11 lines
Diff to previous 1.3.4.7 (colored) to branchpoint 1.3 (colored)

Merge in -current from roughly a week ago

Revision 1.45 / (download) - annotate - [select for diffs], Thu Mar 14 03:16:13 2002 UTC (22 years, 2 months ago) by millert
Branch: MAIN
CVS Tags: OPENBSD_3_1_BASE, OPENBSD_3_1
Changes since 1.44: +2 -2 lines
Diff to previous 1.44 (colored)

Final __P removal plus some cosmetic fixups

Revision 1.44 / (download) - annotate - [select for diffs], Thu Mar 14 01:27:18 2002 UTC (22 years, 2 months ago) by millert
Branch: MAIN
Changes since 1.43: +12 -12 lines
Diff to previous 1.43 (colored)

First round of __P removal in sys

Revision 1.43 / (download) - annotate - [select for diffs], Fri Mar 8 07:25:29 2002 UTC (22 years, 3 months ago) by mickey
Branch: MAIN
Changes since 1.42: +2 -2 lines
Diff to previous 1.42 (colored)

semicolon is not always what it seems, replace w/ a \n in asm labels

Revision 1.42 / (download) - annotate - [select for diffs], Thu Mar 7 01:08:57 2002 UTC (22 years, 3 months ago) by provos
Branch: MAIN
Changes since 1.41: +209 -1 lines
Diff to previous 1.41 (colored)

use an augmented red-black tree to keep track of free space in the vm_map.
uvm_tree_sanity is left as debugging help but needs to be enabled manually.
okay art@

Revision 1.3.4.7 / (download) - annotate - [select for diffs], Wed Mar 6 02:17:14 2002 UTC (22 years, 3 months ago) by niklas
Branch: SMP
Changes since 1.3.4.6: +531 -355 lines
Diff to previous 1.3.4.6 (colored) to branchpoint 1.3 (colored)

Merge in trunk

Revision 1.41 / (download) - annotate - [select for diffs], Thu Feb 28 18:50:26 2002 UTC (22 years, 3 months ago) by provos
Branch: MAIN
Changes since 1.40: +192 -18 lines
Diff to previous 1.40 (colored)

use red-black tree for lookup_entry.  the red-black tree case for
map_findspace is still broken on alpha.  this will make debugging easier.
okay millert@

Revision 1.40 / (download) - annotate - [select for diffs], Mon Feb 25 05:38:50 2002 UTC (22 years, 3 months ago) by provos
Branch: MAIN
Changes since 1.39: +16 -417 lines
Diff to previous 1.39 (colored)

back out red-black tree. they are very fast but alpha UVM is broken and
the tree triggers the bug, PMAP_PREFER case was broken also.

Revision 1.39 / (download) - annotate - [select for diffs], Mon Feb 25 00:20:45 2002 UTC (22 years, 3 months ago) by provos
Branch: MAIN
Changes since 1.38: +418 -17 lines
Diff to previous 1.38 (colored)

use a red-black tree to find entries in the vm_map. augment the red-black
tree to find free space between entries.  speeds up memory allocation,
etc...

Revision 1.38 / (download) - annotate - [select for diffs], Mon Feb 18 10:02:20 2002 UTC (22 years, 3 months ago) by art
Branch: MAIN
Changes since 1.37: +31 -25 lines
Diff to previous 1.37 (colored)

From the UBC branch and NetBSD.

We allocate map entries for the non-intrsafe kernel map (most notably
kernel_map and exec_map) from a pool that's backed by kmem_map (to avoid
deadlocking).

This should get rid of MAX_KMAPENT panics.

Revision 1.34.2.2 / (download) - annotate - [select for diffs], Sat Feb 2 03:28:26 2002 UTC (22 years, 4 months ago) by art
Branch: UBC
Changes since 1.34.2.1: +127 -156 lines
Diff to previous 1.34.2.1 (colored) to branchpoint 1.34 (colored)

Merge in UBC performance changes from NetBSD.
Fix a bunch of merge errors from yesterday.

Revision 1.34.2.1 / (download) - annotate - [select for diffs], Thu Jan 31 22:55:51 2002 UTC (22 years, 4 months ago) by niklas
Branch: UBC
Changes since 1.34: +19 -10 lines
Diff to previous 1.34 (colored)

Merge in -current, builds on i386, otherwise untested

Revision 1.37 / (download) - annotate - [select for diffs], Wed Jan 23 00:39:48 2002 UTC (22 years, 4 months ago) by art
Branch: MAIN
Changes since 1.36: +3 -5 lines
Diff to previous 1.36 (colored)

Pool deals fairly well with physical memory shortage, but it doesn't deal
well (not at all) with shortages of the vm_map where the pages are mapped
(usually kmem_map).

Try to deal with it:
 - group all information the backend allocator for a pool in a separate
   struct. The pool will only have a pointer to that struct.
 - change the pool_init API to reflect that.
 - link all pools allocating from the same allocator on a linked list.
 - Since an allocator is responsible to wait for physical memory it will
   only fail (waitok) when it runs out of its backing vm_map, carefully
   drain pools using the same allocator so that va space is freed.
   (see comments in code for caveats and details).
 - change pool_reclaim to return if it actually succeeded to free some
   memory, use that information to make draining easier and more efficient.
 - get rid of PR_URGENT, noone uses it.

Revision 1.36 / (download) - annotate - [select for diffs], Wed Jan 2 22:23:25 2002 UTC (22 years, 5 months ago) by miod
Branch: MAIN
Changes since 1.35: +18 -7 lines
Diff to previous 1.35 (colored)

Back out a few more uvm changes, especially wrt swap usage.
This unbreaks m68k m88k sparc and perhaps others, which eventually froze
when hitting swap.
Tested by various people on various platforms.
ok art@

Revision 1.35 / (download) - annotate - [select for diffs], Wed Dec 19 08:58:07 2001 UTC (22 years, 5 months ago) by art
Branch: MAIN
Changes since 1.34: +333 -346 lines
Diff to previous 1.34 (colored)

UBC was a disaster. It worked very good when it worked, but on some
machines or some configurations or in some phase of the moon (we actually
don't know when or why) files disappeared. Since we've not been able to
track down the problem in two weeks intense debugging and we need -current
to be stable, back out everything to a state it had before UBC.

We apologise for the inconvenience.

Revision 1.3.4.6 / (download) - annotate - [select for diffs], Wed Dec 5 01:23:58 2001 UTC (22 years, 6 months ago) by niklas
Branch: SMP
Changes since 1.3.4.5: +311 -298 lines
Diff to previous 1.3.4.5 (colored) to branchpoint 1.3 (colored)

Merge in -current

Revision 1.34 / (download) - annotate - [select for diffs], Tue Dec 4 23:22:42 2001 UTC (22 years, 6 months ago) by art
Branch: MAIN
CVS Tags: UBC_BASE
Branch point for: UBC
Changes since 1.33: +42 -42 lines
Diff to previous 1.33 (colored)

Yet another sync to NetBSD uvm.
Today we add a pmap argument to pmap_update() and allocate map entries for
kernel_map from kmem_map instead of using the static entries. This should
get rid of MAX_KMAPENT panics. Also some uvm_loan problems are fixed.

Revision 1.33 / (download) - annotate - [select for diffs], Wed Nov 28 19:28:14 2001 UTC (22 years, 6 months ago) by art
Branch: MAIN
Changes since 1.32: +245 -215 lines
Diff to previous 1.32 (colored)

Sync in more uvm from NetBSD. Mostly just cosmetic stuff.
Contains also support for page coloring.

Revision 1.32 / (download) - annotate - [select for diffs], Wed Nov 28 13:47:39 2001 UTC (22 years, 6 months ago) by art
Branch: MAIN
Changes since 1.31: +73 -90 lines
Diff to previous 1.31 (colored)

Sync in more uvm changes from NetBSD.
This time we're getting rid of KERN_* and VM_PAGER_* error codes and
use errnos instead.

Revision 1.3.4.5 / (download) - annotate - [select for diffs], Tue Nov 13 23:02:31 2001 UTC (22 years, 6 months ago) by niklas
Branch: SMP
Changes since 1.3.4.4: +248 -287 lines
Diff to previous 1.3.4.4 (colored) to branchpoint 1.3 (colored)

merge in -current

Revision 1.31 / (download) - annotate - [select for diffs], Mon Nov 12 01:26:09 2001 UTC (22 years, 6 months ago) by art
Branch: MAIN
Changes since 1.30: +34 -34 lines
Diff to previous 1.30 (colored)

Bring in more changes from NetBSD. Mostly pagedaemon improvements.

Revision 1.30 / (download) - annotate - [select for diffs], Fri Nov 9 03:32:23 2001 UTC (22 years, 6 months ago) by art
Branch: MAIN
Changes since 1.29: +10 -10 lines
Diff to previous 1.29 (colored)

minor sync to NetBSD.

Revision 1.29 / (download) - annotate - [select for diffs], Wed Nov 7 02:55:50 2001 UTC (22 years, 7 months ago) by art
Branch: MAIN
Changes since 1.28: +153 -227 lines
Diff to previous 1.28 (colored)

Another sync of uvm to NetBSD. Just minor fiddling, no major changes.

Revision 1.28 / (download) - annotate - [select for diffs], Wed Nov 7 01:18:01 2001 UTC (22 years, 7 months ago) by art
Branch: MAIN
Changes since 1.27: +61 -23 lines
Diff to previous 1.27 (colored)

Add an alignment argument to uvm_map that specifies an alignment hint
for the virtual address.

Revision 1.27 / (download) - annotate - [select for diffs], Tue Nov 6 13:36:52 2001 UTC (22 years, 7 months ago) by art
Branch: MAIN
Changes since 1.26: +8 -8 lines
Diff to previous 1.26 (colored)

More sync to NetBSD.
 - Use malloc/free instead of MALLOC/FREE for variable sized allocations.
 - Move the memory inheritance code to sys/mman.h and rename from VM_* to MAP_*
 - various cleanups and simplifications.

Revision 1.26 / (download) - annotate - [select for diffs], Tue Nov 6 01:35:04 2001 UTC (22 years, 7 months ago) by art
Branch: MAIN
Changes since 1.25: +2 -4 lines
Diff to previous 1.25 (colored)

Move the last content from vm/ to uvm/
The only thing left in vm/ are just dumb wrappers.
vm/vm.h includes uvm/uvm_extern.h
vm/pmap.h includes uvm/uvm_pmap.h
vm/vm_page.h includes uvm/uvm_page.h

Revision 1.25 / (download) - annotate - [select for diffs], Mon Nov 5 22:14:54 2001 UTC (22 years, 7 months ago) by art
Branch: MAIN
Changes since 1.24: +2 -3 lines
Diff to previous 1.24 (colored)

Minor sync to NetBSD.

Revision 1.3.4.4 / (download) - annotate - [select for diffs], Wed Oct 31 03:32:14 2001 UTC (22 years, 7 months ago) by nate
Branch: SMP
Changes since 1.3.4.3: +56 -41 lines
Diff to previous 1.3.4.3 (colored) to branchpoint 1.3 (colored)

Sync the SMP branch to something just after 3.0

Revision 1.24 / (download) - annotate - [select for diffs], Wed Sep 19 20:50:59 2001 UTC (22 years, 8 months ago) by mickey
Branch: MAIN
CVS Tags: OPENBSD_3_0_BASE, OPENBSD_3_0
Changes since 1.23: +1 -2 lines
Diff to previous 1.23 (colored)

merge vm/vm_kern.h into uvm/uvm_extern.h; art@ ok

Revision 1.23 / (download) - annotate - [select for diffs], Sat Aug 11 10:57:22 2001 UTC (22 years, 9 months ago) by art
Branch: MAIN
Changes since 1.22: +44 -26 lines
Diff to previous 1.22 (colored)

Various random fixes from NetBSD.
Including support for zeroing pages in the idle loop (not enabled yet).

Revision 1.22 / (download) - annotate - [select for diffs], Mon Aug 6 14:03:04 2001 UTC (22 years, 10 months ago) by art
Branch: MAIN
Changes since 1.21: +6 -6 lines
Diff to previous 1.21 (colored)

Add a new type voff_t (right now it's typedefed as off_t) used for offsets
into objects.

Gives the possibilty to mmap beyond the size of vaddr_t.

From NetBSD.

Revision 1.21 / (download) - annotate - [select for diffs], Wed Jul 18 14:38:07 2001 UTC (22 years, 10 months ago) by art
Branch: MAIN
Changes since 1.20: +2 -2 lines
Diff to previous 1.20 (colored)

Correct the NetBSD tag.

Revision 1.20 / (download) - annotate - [select for diffs], Wed Jul 18 10:47:05 2001 UTC (22 years, 10 months ago) by art
Branch: MAIN
Changes since 1.19: +2 -12 lines
Diff to previous 1.19 (colored)

Get rid of the PMAP_NEW option by making it mandatory for all archs.
The archs that didn't have a proper PMAP_NEW now have a dummy implementation
with wrappers around the old functions.

Revision 1.19 / (download) - annotate - [select for diffs], Tue Jul 17 10:55:02 2001 UTC (22 years, 10 months ago) by mts
Branch: MAIN
Changes since 1.18: +3 -3 lines
Diff to previous 1.18 (colored)

i suk. needs &'s on the locks...

Revision 1.18 / (download) - annotate - [select for diffs], Tue Jul 17 10:31:08 2001 UTC (22 years, 10 months ago) by mts
Branch: MAIN
Changes since 1.17: +6 -2 lines
Diff to previous 1.17 (colored)

current netbsd's uvm_map uses a 3-parm SAVE_HINT to perform a test/swap
under locked conditions.  we currently use a 2-parm SAVE_HINT... to meet
the same functionality, we instead need to validate the hint is the one
CURRENTLY in the map before substituing it, and we need to do that while
the lock is retained.

Revision 1.17 / (download) - annotate - [select for diffs], Wed Jul 11 13:57:54 2001 UTC (22 years, 10 months ago) by mts
Branch: MAIN
Changes since 1.16: +5 -1 lines
Diff to previous 1.16 (colored)

need to save hint (verified from current netbsd uvm_map.c) -- need mod
to allow bpf to manage shared address space.

Revision 1.3.4.3 / (download) - annotate - [select for diffs], Wed Jul 4 11:01:05 2001 UTC (22 years, 11 months ago) by niklas
Branch: SMP
Changes since 1.3.4.2: +276 -184 lines
Diff to previous 1.3.4.2 (colored) to branchpoint 1.3 (colored)

Merge in -current from two days ago in the SMP branch.
As usual with merges, they do not indicate progress, so do not hold
your breath for working SMP, and do not mail me and ask about the
state of it.  It has not changed.  There is work ongoing, but very, very
slowly.  The commit is done in parts as to not lock up the tree in too
big chunks at a time.

Revision 1.16 / (download) - annotate - [select for diffs], Sat Jun 23 19:24:33 2001 UTC (22 years, 11 months ago) by smart
Branch: MAIN
Changes since 1.15: +92 -26 lines
Diff to previous 1.15 (colored)

Sync with NetBSD 19990911 (just before PMAP_NEW was required)
  - thread_sleep_msg() -> uvm_sleep()
  - initialize reference count lock in uvm_anon_{init,add}()
  - add uao_flush()
  - replace boolean 'islocked' with 'lockflags'
  - in uvm_fault() change FALSE to TRUE to in 'wide' fault handling
  - get rid of uvm_km_get()
  - various bug fixes

Revision 1.3.4.2 / (download) - annotate - [select for diffs], Mon May 14 22:47:46 2001 UTC (23 years ago) by niklas
Branch: SMP
Changes since 1.3.4.1: +265 -57 lines
Diff to previous 1.3.4.1 (colored) to branchpoint 1.3 (colored)

merge in approximately 2.9 into SMP branch

Revision 1.15 / (download) - annotate - [select for diffs], Thu May 10 14:51:21 2001 UTC (23 years ago) by art
Branch: MAIN
Changes since 1.14: +159 -93 lines
Diff to previous 1.14 (colored)

More sync to NetBSD.
The highlight is some more advices to madvise(2).
 o MADV_DONTNEED will deactive the pages in the given range giving a quicker
   reuse.
 o MADV_FREE will garbage-collect the pages and swap resources causing the
   next fault to either page in new pages from backing store (mapped vnode)
   or allocate new zero-fill pages (anonymous mapping).

Revision 1.14 / (download) - annotate - [select for diffs], Thu May 10 07:59:06 2001 UTC (23 years ago) by art
Branch: MAIN
Changes since 1.13: +38 -22 lines
Diff to previous 1.13 (colored)

Some locking protocol fixes and better enforcement of wiring limits.

From NetBSD.

Revision 1.13 / (download) - annotate - [select for diffs], Mon May 7 16:08:40 2001 UTC (23 years, 1 month ago) by art
Branch: MAIN
Changes since 1.12: +3 -11 lines
Diff to previous 1.12 (colored)

Few fixes from NetBSD.
 - make sure that vsunlock doesn't unwire mlocked memory.
 - fix locking in uvm_useracc.
 - Return the error uvm_fault_wire in uvm_vslock (will be used soon).

Revision 1.12 / (download) - annotate - [select for diffs], Sat May 5 23:25:55 2001 UTC (23 years, 1 month ago) by art
Branch: MAIN
Changes since 1.11: +1 -49 lines
Diff to previous 1.11 (colored)

PMAP_NEW and UVM are no longer optional on i386.

Revision 1.11 / (download) - annotate - [select for diffs], Thu Mar 22 03:05:55 2001 UTC (23 years, 2 months ago) by smart
Branch: MAIN
CVS Tags: OPENBSD_2_9_BASE, OPENBSD_2_9
Changes since 1.10: +5 -8 lines
Diff to previous 1.10 (colored)

Sync style, typo, and comments a little closer to NetBSD.  art@ ok

Revision 1.10 / (download) - annotate - [select for diffs], Thu Mar 15 10:30:57 2001 UTC (23 years, 2 months ago) by art
Branch: MAIN
Changes since 1.9: +2 -2 lines
Diff to previous 1.9 (colored)

Let uvm_map_extract set the lower bound on the address range itself
instead of depending on the callers to do that. (which they don't)

Revision 1.9 / (download) - annotate - [select for diffs], Fri Mar 9 14:20:51 2001 UTC (23 years, 2 months ago) by art
Branch: MAIN
Changes since 1.8: +255 -45 lines
Diff to previous 1.8 (colored)

More syncing to NetBSD.

Implements mincore(2), mlockall(2) and munlockall(2). mlockall and munlockall
are disabled for the moment.

The rest is mostly cosmetic.

Revision 1.8 / (download) - annotate - [select for diffs], Mon Jan 29 02:07:46 2001 UTC (23 years, 4 months ago) by niklas
Branch: MAIN
Changes since 1.7: +1 -0 lines
Diff to previous 1.7 (colored)

$OpenBSD$

Revision 1.7 / (download) - annotate - [select for diffs], Fri Nov 10 15:33:11 2000 UTC (23 years, 6 months ago) by provos
Branch: MAIN
Changes since 1.6: +2 -2 lines
Diff to previous 1.6 (colored)

seperate -> separate, okay aaron@

Revision 1.6 / (download) - annotate - [select for diffs], Thu Sep 7 20:15:28 2000 UTC (23 years, 9 months ago) by art
Branch: MAIN
CVS Tags: OPENBSD_2_8_BASE, OPENBSD_2_8
Changes since 1.5: +3 -3 lines
Diff to previous 1.5 (colored)

Convert bzero to memset(X, 0..) and bcopy to memcpy.
This is to match (make diffs smaller) the code in NetBSD.
new gcc inlines those functions, so this could also be a performance win.

Revision 1.3.4.1 / (download) - annotate - [select for diffs], Fri Mar 24 09:09:50 2000 UTC (24 years, 2 months ago) by niklas
Branch: SMP
Changes since 1.3: +213 -90 lines
Diff to previous 1.3 (colored)

Sync with -current

Revision 1.5 / (download) - annotate - [select for diffs], Fri Mar 17 13:53:23 2000 UTC (24 years, 2 months ago) by deraadt
Branch: MAIN
CVS Tags: OPENBSD_2_7_BASE, OPENBSD_2_7
Changes since 1.4: +1 -1 lines
Diff to previous 1.4 (colored)

fix a non-DIAGNOSTIC gotcha

Revision 1.4 / (download) - annotate - [select for diffs], Thu Mar 16 22:11:04 2000 UTC (24 years, 2 months ago) by art
Branch: MAIN
Changes since 1.3: +213 -90 lines
Diff to previous 1.3 (colored)

Bring in some new UVM code from NetBSD (not current).

 - Introduce a new type of map that are interrupt safe and never allow faults
   in them. mb_map and kmem_map are made intrsafe.
 - Add "access protection" to uvm_vslock (to be passed down to uvm_fault and
   later to pmap_enter).
 - madvise(2) now works.
 - various cleanups.

Revision 1.3 / (download) - annotate - [select for diffs], Mon Aug 23 08:13:24 1999 UTC (24 years, 9 months ago) by art
Branch: MAIN
CVS Tags: kame_19991208, SMP_BASE, OPENBSD_2_6_BASE, OPENBSD_2_6
Branch point for: SMP
Changes since 1.2: +36 -46 lines
Diff to previous 1.2 (colored)

sync with NetBSD from 1999.05.24 (there is a reason for this date)
 Mostly cleanups, but also a few improvements to pagedaemon for better
 handling of low memory and/or low swap conditions.

Revision 1.2 / (download) - annotate - [select for diffs], Fri Feb 26 05:32:07 1999 UTC (25 years, 3 months ago) by art
Branch: MAIN
CVS Tags: OPENBSD_2_5_BASE, OPENBSD_2_5
Changes since 1.1: +1 -0 lines
Diff to previous 1.1 (colored)

add OpenBSD tags

Revision 1.1 / (download) - annotate - [select for diffs], Fri Feb 26 01:30:14 1999 UTC (25 years, 3 months ago) by art
Branch: MAIN

Import of uvm from NetBSD. Some local changes, some code disabled

This form allows you to request diff's between any two revisions of a file. You may select a symbolic revision name using the selection box or you may type in a numeric name using the type-in text box.