History log of /openbsd-current/sys/uvm/uvm_addr.c
Revision (<<< Hide revision tags) (Show revision tags >>>) Date Author Comments
# 1.35 07-Jun-2024 jsg

remove UADDR_HINT_MAXGAP, missed when uaddr_hint allocator was removed


# 1.34 13-May-2024 jsg

remove prototypes with no matching function
ok mpi@


# 1.33 13-Apr-2024 jsg

correct indentation

no functional change, found by smatch warnings
ok miod@ bluhm@


Revision tags: OPENBSD_7_3_BASE OPENBSD_7_4_BASE OPENBSD_7_5_BASE
# 1.32 04-Nov-2022 mpi

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 tags: OPENBSD_7_1_BASE OPENBSD_7_2_BASE
# 1.31 21-Feb-2022 jsg

interting -> inserting


Revision tags: OPENBSD_6_9_BASE OPENBSD_7_0_BASE
# 1.30 20-Mar-2021 mpi

Sync some comments in order to reduce the difference with NetBSD.

No functionnal change.

ok kettenis@


Revision tags: OPENBSD_6_8_BASE
# 1.29 22-Sep-2020 mpi

Spell inline correctly.

Reduce differences with NetBSD.

ok mvs@, kettenis@


# 1.28 13-Sep-2020 mpi

Include <sys/systm.h> directly instead of relying on uvm_map.h to pull it.


Revision tags: OPENBSD_6_4_BASE OPENBSD_6_5_BASE OPENBSD_6_6_BASE OPENBSD_6_7_BASE
# 1.27 16-May-2018 otto

Avoid overflow in constraint computation; ok kettenis@ tb@


# 1.26 17-Apr-2018 otto

- 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@


# 1.25 10-Apr-2018 otto

Fix stop condition for linear search by taking into account the search
direction, otherwise we might break the loop prematurely; ok stefan@


Revision tags: OPENBSD_6_1_BASE OPENBSD_6_2_BASE OPENBSD_6_3_BASE
# 1.24 23-Jan-2017 patrick

Move static function to the bottom of the file, to the only user
of that function, to guard it with SMALL_KERNEL.

ok mpi@


# 1.23 17-Jan-2017 stefan

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


# 1.22 16-Sep-2016 dlg

fix spelling of RBT_NEXT in a comment


# 1.21 16-Sep-2016 dlg

move uaddr_free_rbtree from RB macros to RBT functions


# 1.20 16-Sep-2016 dlg

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@


# 1.19 15-Sep-2016 dlg

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);


# 1.18 02-Sep-2016 stefan

Mask out lower bits of randomly selected address

Fixes uvm pivots bug that would create non-page aligned addresses.
This fix is in code that's not yet enabled.


# 1.17 30-Jul-2016 kettenis

Add a few checks for potential integer overflow and underflow related to the
size of an address range.

ok deraadt@, tedu@


Revision tags: OPENBSD_6_0_BASE
# 1.16 02-Jun-2016 tedu

print the size when an unavailable address is returned. it is useful.
ok millert stefan


# 1.15 07-Mar-2016 naddy

Sync no-argument function declaration and definition by adding (void).
ok mpi@ millert@


Revision tags: OPENBSD_5_8_BASE OPENBSD_5_9_BASE
# 1.14 17-Jul-2015 kettenis

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@


# 1.13 30-Mar-2015 miod

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.


# 1.12 30-Mar-2015 miod

#if 0 various unused definitions.


Revision tags: OPENBSD_5_7_BASE
# 1.11 23-Dec-2014 tedu

convert nointr pool_init argument to pr_waitok


# 1.10 18-Nov-2014 tedu

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


# 1.9 13-Nov-2014 tedu

bzero -> memset


Revision tags: OPENBSD_5_6_BASE
# 1.8 10-Jun-2014 kettenis

KNF


# 1.7 13-Apr-2014 tedu

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


Revision tags: OPENBSD_5_5_BASE
# 1.6 04-Feb-2014 tedu

reduce the length of some pool names. ok deraadt guenther mpi


Revision tags: OPENBSD_5_2_BASE OPENBSD_5_3_BASE OPENBSD_5_4_BASE
# 1.5 18-Jul-2012 matthew

comment typo; s/lineair/linear/


# 1.4 06-Jun-2012 matthew

Fix address-space randomization that was accidentally disabled in
uvm_addr.c r1.3.

ok deraadt, tedu


# 1.3 11-Apr-2012 ariane

vmmap: speed up allocations

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

ok deraadt, tedu


# 1.2 15-Mar-2012 ariane

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.


# 1.1 09-Mar-2012 ariane

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


# 1.34 13-May-2024 jsg

remove prototypes with no matching function
ok mpi@


# 1.33 13-Apr-2024 jsg

correct indentation

no functional change, found by smatch warnings
ok miod@ bluhm@


Revision tags: OPENBSD_7_3_BASE OPENBSD_7_4_BASE OPENBSD_7_5_BASE
# 1.32 04-Nov-2022 mpi

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 tags: OPENBSD_7_1_BASE OPENBSD_7_2_BASE
# 1.31 21-Feb-2022 jsg

interting -> inserting


Revision tags: OPENBSD_6_9_BASE OPENBSD_7_0_BASE
# 1.30 20-Mar-2021 mpi

Sync some comments in order to reduce the difference with NetBSD.

No functionnal change.

ok kettenis@


Revision tags: OPENBSD_6_8_BASE
# 1.29 22-Sep-2020 mpi

Spell inline correctly.

Reduce differences with NetBSD.

ok mvs@, kettenis@


# 1.28 13-Sep-2020 mpi

Include <sys/systm.h> directly instead of relying on uvm_map.h to pull it.


Revision tags: OPENBSD_6_4_BASE OPENBSD_6_5_BASE OPENBSD_6_6_BASE OPENBSD_6_7_BASE
# 1.27 16-May-2018 otto

Avoid overflow in constraint computation; ok kettenis@ tb@


# 1.26 17-Apr-2018 otto

- 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@


# 1.25 10-Apr-2018 otto

Fix stop condition for linear search by taking into account the search
direction, otherwise we might break the loop prematurely; ok stefan@


Revision tags: OPENBSD_6_1_BASE OPENBSD_6_2_BASE OPENBSD_6_3_BASE
# 1.24 23-Jan-2017 patrick

Move static function to the bottom of the file, to the only user
of that function, to guard it with SMALL_KERNEL.

ok mpi@


# 1.23 17-Jan-2017 stefan

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


# 1.22 16-Sep-2016 dlg

fix spelling of RBT_NEXT in a comment


# 1.21 16-Sep-2016 dlg

move uaddr_free_rbtree from RB macros to RBT functions


# 1.20 16-Sep-2016 dlg

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@


# 1.19 15-Sep-2016 dlg

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);


# 1.18 02-Sep-2016 stefan

Mask out lower bits of randomly selected address

Fixes uvm pivots bug that would create non-page aligned addresses.
This fix is in code that's not yet enabled.


# 1.17 30-Jul-2016 kettenis

Add a few checks for potential integer overflow and underflow related to the
size of an address range.

ok deraadt@, tedu@


Revision tags: OPENBSD_6_0_BASE
# 1.16 02-Jun-2016 tedu

print the size when an unavailable address is returned. it is useful.
ok millert stefan


# 1.15 07-Mar-2016 naddy

Sync no-argument function declaration and definition by adding (void).
ok mpi@ millert@


Revision tags: OPENBSD_5_8_BASE OPENBSD_5_9_BASE
# 1.14 17-Jul-2015 kettenis

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@


# 1.13 30-Mar-2015 miod

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.


# 1.12 30-Mar-2015 miod

#if 0 various unused definitions.


Revision tags: OPENBSD_5_7_BASE
# 1.11 23-Dec-2014 tedu

convert nointr pool_init argument to pr_waitok


# 1.10 18-Nov-2014 tedu

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


# 1.9 13-Nov-2014 tedu

bzero -> memset


Revision tags: OPENBSD_5_6_BASE
# 1.8 10-Jun-2014 kettenis

KNF


# 1.7 13-Apr-2014 tedu

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


Revision tags: OPENBSD_5_5_BASE
# 1.6 04-Feb-2014 tedu

reduce the length of some pool names. ok deraadt guenther mpi


Revision tags: OPENBSD_5_2_BASE OPENBSD_5_3_BASE OPENBSD_5_4_BASE
# 1.5 18-Jul-2012 matthew

comment typo; s/lineair/linear/


# 1.4 06-Jun-2012 matthew

Fix address-space randomization that was accidentally disabled in
uvm_addr.c r1.3.

ok deraadt, tedu


# 1.3 11-Apr-2012 ariane

vmmap: speed up allocations

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

ok deraadt, tedu


# 1.2 15-Mar-2012 ariane

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.


# 1.1 09-Mar-2012 ariane

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


# 1.33 13-Apr-2024 jsg

correct indentation

no functional change, found by smatch warnings
ok miod@ bluhm@


Revision tags: OPENBSD_7_3_BASE OPENBSD_7_4_BASE OPENBSD_7_5_BASE
# 1.32 04-Nov-2022 mpi

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 tags: OPENBSD_7_1_BASE OPENBSD_7_2_BASE
# 1.31 21-Feb-2022 jsg

interting -> inserting


Revision tags: OPENBSD_6_9_BASE OPENBSD_7_0_BASE
# 1.30 20-Mar-2021 mpi

Sync some comments in order to reduce the difference with NetBSD.

No functionnal change.

ok kettenis@


Revision tags: OPENBSD_6_8_BASE
# 1.29 22-Sep-2020 mpi

Spell inline correctly.

Reduce differences with NetBSD.

ok mvs@, kettenis@


# 1.28 13-Sep-2020 mpi

Include <sys/systm.h> directly instead of relying on uvm_map.h to pull it.


Revision tags: OPENBSD_6_4_BASE OPENBSD_6_5_BASE OPENBSD_6_6_BASE OPENBSD_6_7_BASE
# 1.27 16-May-2018 otto

Avoid overflow in constraint computation; ok kettenis@ tb@


# 1.26 17-Apr-2018 otto

- 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@


# 1.25 10-Apr-2018 otto

Fix stop condition for linear search by taking into account the search
direction, otherwise we might break the loop prematurely; ok stefan@


Revision tags: OPENBSD_6_1_BASE OPENBSD_6_2_BASE OPENBSD_6_3_BASE
# 1.24 23-Jan-2017 patrick

Move static function to the bottom of the file, to the only user
of that function, to guard it with SMALL_KERNEL.

ok mpi@


# 1.23 17-Jan-2017 stefan

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


# 1.22 16-Sep-2016 dlg

fix spelling of RBT_NEXT in a comment


# 1.21 16-Sep-2016 dlg

move uaddr_free_rbtree from RB macros to RBT functions


# 1.20 16-Sep-2016 dlg

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@


# 1.19 15-Sep-2016 dlg

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);


# 1.18 02-Sep-2016 stefan

Mask out lower bits of randomly selected address

Fixes uvm pivots bug that would create non-page aligned addresses.
This fix is in code that's not yet enabled.


# 1.17 30-Jul-2016 kettenis

Add a few checks for potential integer overflow and underflow related to the
size of an address range.

ok deraadt@, tedu@


Revision tags: OPENBSD_6_0_BASE
# 1.16 02-Jun-2016 tedu

print the size when an unavailable address is returned. it is useful.
ok millert stefan


# 1.15 07-Mar-2016 naddy

Sync no-argument function declaration and definition by adding (void).
ok mpi@ millert@


Revision tags: OPENBSD_5_8_BASE OPENBSD_5_9_BASE
# 1.14 17-Jul-2015 kettenis

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@


# 1.13 30-Mar-2015 miod

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.


# 1.12 30-Mar-2015 miod

#if 0 various unused definitions.


Revision tags: OPENBSD_5_7_BASE
# 1.11 23-Dec-2014 tedu

convert nointr pool_init argument to pr_waitok


# 1.10 18-Nov-2014 tedu

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


# 1.9 13-Nov-2014 tedu

bzero -> memset


Revision tags: OPENBSD_5_6_BASE
# 1.8 10-Jun-2014 kettenis

KNF


# 1.7 13-Apr-2014 tedu

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


Revision tags: OPENBSD_5_5_BASE
# 1.6 04-Feb-2014 tedu

reduce the length of some pool names. ok deraadt guenther mpi


Revision tags: OPENBSD_5_2_BASE OPENBSD_5_3_BASE OPENBSD_5_4_BASE
# 1.5 18-Jul-2012 matthew

comment typo; s/lineair/linear/


# 1.4 06-Jun-2012 matthew

Fix address-space randomization that was accidentally disabled in
uvm_addr.c r1.3.

ok deraadt, tedu


# 1.3 11-Apr-2012 ariane

vmmap: speed up allocations

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

ok deraadt, tedu


# 1.2 15-Mar-2012 ariane

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.


# 1.1 09-Mar-2012 ariane

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


# 1.32 04-Nov-2022 mpi

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 tags: OPENBSD_7_1_BASE OPENBSD_7_2_BASE
# 1.31 21-Feb-2022 jsg

interting -> inserting


Revision tags: OPENBSD_6_9_BASE OPENBSD_7_0_BASE
# 1.30 20-Mar-2021 mpi

Sync some comments in order to reduce the difference with NetBSD.

No functionnal change.

ok kettenis@


Revision tags: OPENBSD_6_8_BASE
# 1.29 22-Sep-2020 mpi

Spell inline correctly.

Reduce differences with NetBSD.

ok mvs@, kettenis@


# 1.28 13-Sep-2020 mpi

Include <sys/systm.h> directly instead of relying on uvm_map.h to pull it.


Revision tags: OPENBSD_6_4_BASE OPENBSD_6_5_BASE OPENBSD_6_6_BASE OPENBSD_6_7_BASE
# 1.27 16-May-2018 otto

Avoid overflow in constraint computation; ok kettenis@ tb@


# 1.26 17-Apr-2018 otto

- 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@


# 1.25 10-Apr-2018 otto

Fix stop condition for linear search by taking into account the search
direction, otherwise we might break the loop prematurely; ok stefan@


Revision tags: OPENBSD_6_1_BASE OPENBSD_6_2_BASE OPENBSD_6_3_BASE
# 1.24 23-Jan-2017 patrick

Move static function to the bottom of the file, to the only user
of that function, to guard it with SMALL_KERNEL.

ok mpi@


# 1.23 17-Jan-2017 stefan

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


# 1.22 16-Sep-2016 dlg

fix spelling of RBT_NEXT in a comment


# 1.21 16-Sep-2016 dlg

move uaddr_free_rbtree from RB macros to RBT functions


# 1.20 16-Sep-2016 dlg

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@


# 1.19 15-Sep-2016 dlg

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);


# 1.18 02-Sep-2016 stefan

Mask out lower bits of randomly selected address

Fixes uvm pivots bug that would create non-page aligned addresses.
This fix is in code that's not yet enabled.


# 1.17 30-Jul-2016 kettenis

Add a few checks for potential integer overflow and underflow related to the
size of an address range.

ok deraadt@, tedu@


Revision tags: OPENBSD_6_0_BASE
# 1.16 02-Jun-2016 tedu

print the size when an unavailable address is returned. it is useful.
ok millert stefan


# 1.15 07-Mar-2016 naddy

Sync no-argument function declaration and definition by adding (void).
ok mpi@ millert@


Revision tags: OPENBSD_5_8_BASE OPENBSD_5_9_BASE
# 1.14 17-Jul-2015 kettenis

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@


# 1.13 30-Mar-2015 miod

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.


# 1.12 30-Mar-2015 miod

#if 0 various unused definitions.


Revision tags: OPENBSD_5_7_BASE
# 1.11 23-Dec-2014 tedu

convert nointr pool_init argument to pr_waitok


# 1.10 18-Nov-2014 tedu

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


# 1.9 13-Nov-2014 tedu

bzero -> memset


Revision tags: OPENBSD_5_6_BASE
# 1.8 10-Jun-2014 kettenis

KNF


# 1.7 13-Apr-2014 tedu

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


Revision tags: OPENBSD_5_5_BASE
# 1.6 04-Feb-2014 tedu

reduce the length of some pool names. ok deraadt guenther mpi


Revision tags: OPENBSD_5_2_BASE OPENBSD_5_3_BASE OPENBSD_5_4_BASE
# 1.5 18-Jul-2012 matthew

comment typo; s/lineair/linear/


# 1.4 06-Jun-2012 matthew

Fix address-space randomization that was accidentally disabled in
uvm_addr.c r1.3.

ok deraadt, tedu


# 1.3 11-Apr-2012 ariane

vmmap: speed up allocations

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

ok deraadt, tedu


# 1.2 15-Mar-2012 ariane

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.


# 1.1 09-Mar-2012 ariane

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


# 1.31 21-Feb-2022 jsg

interting -> inserting


Revision tags: OPENBSD_6_9_BASE OPENBSD_7_0_BASE
# 1.30 20-Mar-2021 mpi

Sync some comments in order to reduce the difference with NetBSD.

No functionnal change.

ok kettenis@


Revision tags: OPENBSD_6_8_BASE
# 1.29 22-Sep-2020 mpi

Spell inline correctly.

Reduce differences with NetBSD.

ok mvs@, kettenis@


# 1.28 13-Sep-2020 mpi

Include <sys/systm.h> directly instead of relying on uvm_map.h to pull it.


Revision tags: OPENBSD_6_4_BASE OPENBSD_6_5_BASE OPENBSD_6_6_BASE OPENBSD_6_7_BASE
# 1.27 16-May-2018 otto

Avoid overflow in constraint computation; ok kettenis@ tb@


# 1.26 17-Apr-2018 otto

- 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@


# 1.25 10-Apr-2018 otto

Fix stop condition for linear search by taking into account the search
direction, otherwise we might break the loop prematurely; ok stefan@


Revision tags: OPENBSD_6_1_BASE OPENBSD_6_2_BASE OPENBSD_6_3_BASE
# 1.24 23-Jan-2017 patrick

Move static function to the bottom of the file, to the only user
of that function, to guard it with SMALL_KERNEL.

ok mpi@


# 1.23 17-Jan-2017 stefan

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


# 1.22 16-Sep-2016 dlg

fix spelling of RBT_NEXT in a comment


# 1.21 16-Sep-2016 dlg

move uaddr_free_rbtree from RB macros to RBT functions


# 1.20 16-Sep-2016 dlg

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@


# 1.19 15-Sep-2016 dlg

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);


# 1.18 02-Sep-2016 stefan

Mask out lower bits of randomly selected address

Fixes uvm pivots bug that would create non-page aligned addresses.
This fix is in code that's not yet enabled.


# 1.17 30-Jul-2016 kettenis

Add a few checks for potential integer overflow and underflow related to the
size of an address range.

ok deraadt@, tedu@


Revision tags: OPENBSD_6_0_BASE
# 1.16 02-Jun-2016 tedu

print the size when an unavailable address is returned. it is useful.
ok millert stefan


# 1.15 07-Mar-2016 naddy

Sync no-argument function declaration and definition by adding (void).
ok mpi@ millert@


Revision tags: OPENBSD_5_8_BASE OPENBSD_5_9_BASE
# 1.14 17-Jul-2015 kettenis

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@


# 1.13 30-Mar-2015 miod

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.


# 1.12 30-Mar-2015 miod

#if 0 various unused definitions.


Revision tags: OPENBSD_5_7_BASE
# 1.11 23-Dec-2014 tedu

convert nointr pool_init argument to pr_waitok


# 1.10 18-Nov-2014 tedu

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


# 1.9 13-Nov-2014 tedu

bzero -> memset


Revision tags: OPENBSD_5_6_BASE
# 1.8 10-Jun-2014 kettenis

KNF


# 1.7 13-Apr-2014 tedu

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


Revision tags: OPENBSD_5_5_BASE
# 1.6 04-Feb-2014 tedu

reduce the length of some pool names. ok deraadt guenther mpi


Revision tags: OPENBSD_5_2_BASE OPENBSD_5_3_BASE OPENBSD_5_4_BASE
# 1.5 18-Jul-2012 matthew

comment typo; s/lineair/linear/


# 1.4 06-Jun-2012 matthew

Fix address-space randomization that was accidentally disabled in
uvm_addr.c r1.3.

ok deraadt, tedu


# 1.3 11-Apr-2012 ariane

vmmap: speed up allocations

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

ok deraadt, tedu


# 1.2 15-Mar-2012 ariane

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.


# 1.1 09-Mar-2012 ariane

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


# 1.30 20-Mar-2021 mpi

Sync some comments in order to reduce the difference with NetBSD.

No functionnal change.

ok kettenis@


Revision tags: OPENBSD_6_8_BASE
# 1.29 22-Sep-2020 mpi

Spell inline correctly.

Reduce differences with NetBSD.

ok mvs@, kettenis@


# 1.28 13-Sep-2020 mpi

Include <sys/systm.h> directly instead of relying on uvm_map.h to pull it.


Revision tags: OPENBSD_6_4_BASE OPENBSD_6_5_BASE OPENBSD_6_6_BASE OPENBSD_6_7_BASE
# 1.27 16-May-2018 otto

Avoid overflow in constraint computation; ok kettenis@ tb@


# 1.26 17-Apr-2018 otto

- 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@


# 1.25 10-Apr-2018 otto

Fix stop condition for linear search by taking into account the search
direction, otherwise we might break the loop prematurely; ok stefan@


Revision tags: OPENBSD_6_1_BASE OPENBSD_6_2_BASE OPENBSD_6_3_BASE
# 1.24 23-Jan-2017 patrick

Move static function to the bottom of the file, to the only user
of that function, to guard it with SMALL_KERNEL.

ok mpi@


# 1.23 17-Jan-2017 stefan

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


# 1.22 16-Sep-2016 dlg

fix spelling of RBT_NEXT in a comment


# 1.21 16-Sep-2016 dlg

move uaddr_free_rbtree from RB macros to RBT functions


# 1.20 16-Sep-2016 dlg

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@


# 1.19 15-Sep-2016 dlg

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);


# 1.18 02-Sep-2016 stefan

Mask out lower bits of randomly selected address

Fixes uvm pivots bug that would create non-page aligned addresses.
This fix is in code that's not yet enabled.


# 1.17 30-Jul-2016 kettenis

Add a few checks for potential integer overflow and underflow related to the
size of an address range.

ok deraadt@, tedu@


Revision tags: OPENBSD_6_0_BASE
# 1.16 02-Jun-2016 tedu

print the size when an unavailable address is returned. it is useful.
ok millert stefan


# 1.15 07-Mar-2016 naddy

Sync no-argument function declaration and definition by adding (void).
ok mpi@ millert@


Revision tags: OPENBSD_5_8_BASE OPENBSD_5_9_BASE
# 1.14 17-Jul-2015 kettenis

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@


# 1.13 30-Mar-2015 miod

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.


# 1.12 30-Mar-2015 miod

#if 0 various unused definitions.


Revision tags: OPENBSD_5_7_BASE
# 1.11 23-Dec-2014 tedu

convert nointr pool_init argument to pr_waitok


# 1.10 18-Nov-2014 tedu

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


# 1.9 13-Nov-2014 tedu

bzero -> memset


Revision tags: OPENBSD_5_6_BASE
# 1.8 10-Jun-2014 kettenis

KNF


# 1.7 13-Apr-2014 tedu

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


Revision tags: OPENBSD_5_5_BASE
# 1.6 04-Feb-2014 tedu

reduce the length of some pool names. ok deraadt guenther mpi


Revision tags: OPENBSD_5_2_BASE OPENBSD_5_3_BASE OPENBSD_5_4_BASE
# 1.5 18-Jul-2012 matthew

comment typo; s/lineair/linear/


# 1.4 06-Jun-2012 matthew

Fix address-space randomization that was accidentally disabled in
uvm_addr.c r1.3.

ok deraadt, tedu


# 1.3 11-Apr-2012 ariane

vmmap: speed up allocations

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

ok deraadt, tedu


# 1.2 15-Mar-2012 ariane

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.


# 1.1 09-Mar-2012 ariane

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


# 1.29 22-Sep-2020 mpi

Spell inline correctly.

Reduce differences with NetBSD.

ok mvs@, kettenis@


# 1.28 13-Sep-2020 mpi

Include <sys/systm.h> directly instead of relying on uvm_map.h to pull it.


Revision tags: OPENBSD_6_4_BASE OPENBSD_6_5_BASE OPENBSD_6_6_BASE OPENBSD_6_7_BASE
# 1.27 16-May-2018 otto

Avoid overflow in constraint computation; ok kettenis@ tb@


# 1.26 17-Apr-2018 otto

- 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@


# 1.25 10-Apr-2018 otto

Fix stop condition for linear search by taking into account the search
direction, otherwise we might break the loop prematurely; ok stefan@


Revision tags: OPENBSD_6_1_BASE OPENBSD_6_2_BASE OPENBSD_6_3_BASE
# 1.24 23-Jan-2017 patrick

Move static function to the bottom of the file, to the only user
of that function, to guard it with SMALL_KERNEL.

ok mpi@


# 1.23 17-Jan-2017 stefan

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


# 1.22 16-Sep-2016 dlg

fix spelling of RBT_NEXT in a comment


# 1.21 16-Sep-2016 dlg

move uaddr_free_rbtree from RB macros to RBT functions


# 1.20 16-Sep-2016 dlg

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@


# 1.19 15-Sep-2016 dlg

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);


# 1.18 02-Sep-2016 stefan

Mask out lower bits of randomly selected address

Fixes uvm pivots bug that would create non-page aligned addresses.
This fix is in code that's not yet enabled.


# 1.17 30-Jul-2016 kettenis

Add a few checks for potential integer overflow and underflow related to the
size of an address range.

ok deraadt@, tedu@


Revision tags: OPENBSD_6_0_BASE
# 1.16 02-Jun-2016 tedu

print the size when an unavailable address is returned. it is useful.
ok millert stefan


# 1.15 07-Mar-2016 naddy

Sync no-argument function declaration and definition by adding (void).
ok mpi@ millert@


Revision tags: OPENBSD_5_8_BASE OPENBSD_5_9_BASE
# 1.14 17-Jul-2015 kettenis

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@


# 1.13 30-Mar-2015 miod

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.


# 1.12 30-Mar-2015 miod

#if 0 various unused definitions.


Revision tags: OPENBSD_5_7_BASE
# 1.11 23-Dec-2014 tedu

convert nointr pool_init argument to pr_waitok


# 1.10 18-Nov-2014 tedu

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


# 1.9 13-Nov-2014 tedu

bzero -> memset


Revision tags: OPENBSD_5_6_BASE
# 1.8 10-Jun-2014 kettenis

KNF


# 1.7 13-Apr-2014 tedu

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


Revision tags: OPENBSD_5_5_BASE
# 1.6 04-Feb-2014 tedu

reduce the length of some pool names. ok deraadt guenther mpi


Revision tags: OPENBSD_5_2_BASE OPENBSD_5_3_BASE OPENBSD_5_4_BASE
# 1.5 18-Jul-2012 matthew

comment typo; s/lineair/linear/


# 1.4 06-Jun-2012 matthew

Fix address-space randomization that was accidentally disabled in
uvm_addr.c r1.3.

ok deraadt, tedu


# 1.3 11-Apr-2012 ariane

vmmap: speed up allocations

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

ok deraadt, tedu


# 1.2 15-Mar-2012 ariane

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.


# 1.1 09-Mar-2012 ariane

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


# 1.28 13-Sep-2020 mpi

Include <sys/systm.h> directly instead of relying on uvm_map.h to pull it.


Revision tags: OPENBSD_6_4_BASE OPENBSD_6_5_BASE OPENBSD_6_6_BASE OPENBSD_6_7_BASE
# 1.27 16-May-2018 otto

Avoid overflow in constraint computation; ok kettenis@ tb@


# 1.26 17-Apr-2018 otto

- 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@


# 1.25 10-Apr-2018 otto

Fix stop condition for linear search by taking into account the search
direction, otherwise we might break the loop prematurely; ok stefan@


Revision tags: OPENBSD_6_1_BASE OPENBSD_6_2_BASE OPENBSD_6_3_BASE
# 1.24 23-Jan-2017 patrick

Move static function to the bottom of the file, to the only user
of that function, to guard it with SMALL_KERNEL.

ok mpi@


# 1.23 17-Jan-2017 stefan

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


# 1.22 16-Sep-2016 dlg

fix spelling of RBT_NEXT in a comment


# 1.21 16-Sep-2016 dlg

move uaddr_free_rbtree from RB macros to RBT functions


# 1.20 16-Sep-2016 dlg

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@


# 1.19 15-Sep-2016 dlg

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);


# 1.18 02-Sep-2016 stefan

Mask out lower bits of randomly selected address

Fixes uvm pivots bug that would create non-page aligned addresses.
This fix is in code that's not yet enabled.


# 1.17 30-Jul-2016 kettenis

Add a few checks for potential integer overflow and underflow related to the
size of an address range.

ok deraadt@, tedu@


Revision tags: OPENBSD_6_0_BASE
# 1.16 02-Jun-2016 tedu

print the size when an unavailable address is returned. it is useful.
ok millert stefan


# 1.15 07-Mar-2016 naddy

Sync no-argument function declaration and definition by adding (void).
ok mpi@ millert@


Revision tags: OPENBSD_5_8_BASE OPENBSD_5_9_BASE
# 1.14 17-Jul-2015 kettenis

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@


# 1.13 30-Mar-2015 miod

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.


# 1.12 30-Mar-2015 miod

#if 0 various unused definitions.


Revision tags: OPENBSD_5_7_BASE
# 1.11 23-Dec-2014 tedu

convert nointr pool_init argument to pr_waitok


# 1.10 18-Nov-2014 tedu

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


# 1.9 13-Nov-2014 tedu

bzero -> memset


Revision tags: OPENBSD_5_6_BASE
# 1.8 10-Jun-2014 kettenis

KNF


# 1.7 13-Apr-2014 tedu

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


Revision tags: OPENBSD_5_5_BASE
# 1.6 04-Feb-2014 tedu

reduce the length of some pool names. ok deraadt guenther mpi


Revision tags: OPENBSD_5_2_BASE OPENBSD_5_3_BASE OPENBSD_5_4_BASE
# 1.5 18-Jul-2012 matthew

comment typo; s/lineair/linear/


# 1.4 06-Jun-2012 matthew

Fix address-space randomization that was accidentally disabled in
uvm_addr.c r1.3.

ok deraadt, tedu


# 1.3 11-Apr-2012 ariane

vmmap: speed up allocations

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

ok deraadt, tedu


# 1.2 15-Mar-2012 ariane

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.


# 1.1 09-Mar-2012 ariane

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


# 1.27 16-May-2018 otto

Avoid overflow in constraint computation; ok kettenis@ tb@


# 1.26 17-Apr-2018 otto

- 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@


# 1.25 10-Apr-2018 otto

Fix stop condition for linear search by taking into account the search
direction, otherwise we might break the loop prematurely; ok stefan@


Revision tags: OPENBSD_6_1_BASE OPENBSD_6_2_BASE OPENBSD_6_3_BASE
# 1.24 23-Jan-2017 patrick

Move static function to the bottom of the file, to the only user
of that function, to guard it with SMALL_KERNEL.

ok mpi@


# 1.23 17-Jan-2017 stefan

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


# 1.22 16-Sep-2016 dlg

fix spelling of RBT_NEXT in a comment


# 1.21 16-Sep-2016 dlg

move uaddr_free_rbtree from RB macros to RBT functions


# 1.20 16-Sep-2016 dlg

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@


# 1.19 15-Sep-2016 dlg

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);


# 1.18 02-Sep-2016 stefan

Mask out lower bits of randomly selected address

Fixes uvm pivots bug that would create non-page aligned addresses.
This fix is in code that's not yet enabled.


# 1.17 30-Jul-2016 kettenis

Add a few checks for potential integer overflow and underflow related to the
size of an address range.

ok deraadt@, tedu@


Revision tags: OPENBSD_6_0_BASE
# 1.16 02-Jun-2016 tedu

print the size when an unavailable address is returned. it is useful.
ok millert stefan


# 1.15 07-Mar-2016 naddy

Sync no-argument function declaration and definition by adding (void).
ok mpi@ millert@


Revision tags: OPENBSD_5_8_BASE OPENBSD_5_9_BASE
# 1.14 17-Jul-2015 kettenis

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@


# 1.13 30-Mar-2015 miod

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.


# 1.12 30-Mar-2015 miod

#if 0 various unused definitions.


Revision tags: OPENBSD_5_7_BASE
# 1.11 23-Dec-2014 tedu

convert nointr pool_init argument to pr_waitok


# 1.10 18-Nov-2014 tedu

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


# 1.9 13-Nov-2014 tedu

bzero -> memset


Revision tags: OPENBSD_5_6_BASE
# 1.8 10-Jun-2014 kettenis

KNF


# 1.7 13-Apr-2014 tedu

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


Revision tags: OPENBSD_5_5_BASE
# 1.6 04-Feb-2014 tedu

reduce the length of some pool names. ok deraadt guenther mpi


Revision tags: OPENBSD_5_2_BASE OPENBSD_5_3_BASE OPENBSD_5_4_BASE
# 1.5 18-Jul-2012 matthew

comment typo; s/lineair/linear/


# 1.4 06-Jun-2012 matthew

Fix address-space randomization that was accidentally disabled in
uvm_addr.c r1.3.

ok deraadt, tedu


# 1.3 11-Apr-2012 ariane

vmmap: speed up allocations

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

ok deraadt, tedu


# 1.2 15-Mar-2012 ariane

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.


# 1.1 09-Mar-2012 ariane

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


# 1.26 17-Apr-2018 otto

- 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@


# 1.25 10-Apr-2018 otto

Fix stop condition for linear search by taking into account the search
direction, otherwise we might break the loop prematurely; ok stefan@


Revision tags: OPENBSD_6_1_BASE OPENBSD_6_2_BASE OPENBSD_6_3_BASE
# 1.24 23-Jan-2017 patrick

Move static function to the bottom of the file, to the only user
of that function, to guard it with SMALL_KERNEL.

ok mpi@


# 1.23 17-Jan-2017 stefan

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


# 1.22 16-Sep-2016 dlg

fix spelling of RBT_NEXT in a comment


# 1.21 16-Sep-2016 dlg

move uaddr_free_rbtree from RB macros to RBT functions


# 1.20 16-Sep-2016 dlg

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@


# 1.19 15-Sep-2016 dlg

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);


# 1.18 02-Sep-2016 stefan

Mask out lower bits of randomly selected address

Fixes uvm pivots bug that would create non-page aligned addresses.
This fix is in code that's not yet enabled.


# 1.17 30-Jul-2016 kettenis

Add a few checks for potential integer overflow and underflow related to the
size of an address range.

ok deraadt@, tedu@


Revision tags: OPENBSD_6_0_BASE
# 1.16 02-Jun-2016 tedu

print the size when an unavailable address is returned. it is useful.
ok millert stefan


# 1.15 07-Mar-2016 naddy

Sync no-argument function declaration and definition by adding (void).
ok mpi@ millert@


Revision tags: OPENBSD_5_8_BASE OPENBSD_5_9_BASE
# 1.14 17-Jul-2015 kettenis

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@


# 1.13 30-Mar-2015 miod

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.


# 1.12 30-Mar-2015 miod

#if 0 various unused definitions.


Revision tags: OPENBSD_5_7_BASE
# 1.11 23-Dec-2014 tedu

convert nointr pool_init argument to pr_waitok


# 1.10 18-Nov-2014 tedu

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


# 1.9 13-Nov-2014 tedu

bzero -> memset


Revision tags: OPENBSD_5_6_BASE
# 1.8 10-Jun-2014 kettenis

KNF


# 1.7 13-Apr-2014 tedu

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


Revision tags: OPENBSD_5_5_BASE
# 1.6 04-Feb-2014 tedu

reduce the length of some pool names. ok deraadt guenther mpi


Revision tags: OPENBSD_5_2_BASE OPENBSD_5_3_BASE OPENBSD_5_4_BASE
# 1.5 18-Jul-2012 matthew

comment typo; s/lineair/linear/


# 1.4 06-Jun-2012 matthew

Fix address-space randomization that was accidentally disabled in
uvm_addr.c r1.3.

ok deraadt, tedu


# 1.3 11-Apr-2012 ariane

vmmap: speed up allocations

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

ok deraadt, tedu


# 1.2 15-Mar-2012 ariane

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.


# 1.1 09-Mar-2012 ariane

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 tags: OPENBSD_6_1_BASE OPENBSD_6_2_BASE
# 1.24 23-Jan-2017 patrick

Move static function to the bottom of the file, to the only user
of that function, to guard it with SMALL_KERNEL.

ok mpi@


# 1.23 17-Jan-2017 stefan

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


# 1.22 16-Sep-2016 dlg

fix spelling of RBT_NEXT in a comment


# 1.21 16-Sep-2016 dlg

move uaddr_free_rbtree from RB macros to RBT functions


# 1.20 16-Sep-2016 dlg

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@


# 1.19 15-Sep-2016 dlg

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);


# 1.18 02-Sep-2016 stefan

Mask out lower bits of randomly selected address

Fixes uvm pivots bug that would create non-page aligned addresses.
This fix is in code that's not yet enabled.


# 1.17 30-Jul-2016 kettenis

Add a few checks for potential integer overflow and underflow related to the
size of an address range.

ok deraadt@, tedu@


Revision tags: OPENBSD_6_0_BASE
# 1.16 02-Jun-2016 tedu

print the size when an unavailable address is returned. it is useful.
ok millert stefan


# 1.15 07-Mar-2016 naddy

Sync no-argument function declaration and definition by adding (void).
ok mpi@ millert@


Revision tags: OPENBSD_5_8_BASE OPENBSD_5_9_BASE
# 1.14 17-Jul-2015 kettenis

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@


# 1.13 30-Mar-2015 miod

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.


# 1.12 30-Mar-2015 miod

#if 0 various unused definitions.


Revision tags: OPENBSD_5_7_BASE
# 1.11 23-Dec-2014 tedu

convert nointr pool_init argument to pr_waitok


# 1.10 18-Nov-2014 tedu

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


# 1.9 13-Nov-2014 tedu

bzero -> memset


Revision tags: OPENBSD_5_6_BASE
# 1.8 10-Jun-2014 kettenis

KNF


# 1.7 13-Apr-2014 tedu

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


Revision tags: OPENBSD_5_5_BASE
# 1.6 04-Feb-2014 tedu

reduce the length of some pool names. ok deraadt guenther mpi


Revision tags: OPENBSD_5_2_BASE OPENBSD_5_3_BASE OPENBSD_5_4_BASE
# 1.5 18-Jul-2012 matthew

comment typo; s/lineair/linear/


# 1.4 06-Jun-2012 matthew

Fix address-space randomization that was accidentally disabled in
uvm_addr.c r1.3.

ok deraadt, tedu


# 1.3 11-Apr-2012 ariane

vmmap: speed up allocations

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

ok deraadt, tedu


# 1.2 15-Mar-2012 ariane

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.


# 1.1 09-Mar-2012 ariane

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