History log of /openbsd-current/sys/sys/mman.h
Revision (<<< Hide revision tags) (Show revision tags >>>) Date Author Comments
# 1.35 07-Oct-2022 deraadt

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 tags: OPENBSD_6_5_BASE OPENBSD_6_6_BASE OPENBSD_6_7_BASE OPENBSD_6_8_BASE OPENBSD_6_9_BASE OPENBSD_7_0_BASE OPENBSD_7_1_BASE OPENBSD_7_2_BASE
# 1.34 01-Mar-2019 cheloha

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@


# 1.33 11-Jan-2019 deraadt

mincore() is a relic from the past, exposing physical machine information
about shared resources which no program should see. only a few pieces of
software use it, generally poorly thought out. they are being fixed, so
mincore() can be deleted.
ok guenther tedu jca sthen, others


Revision tags: OPENBSD_6_3_BASE OPENBSD_6_4_BASE
# 1.32 11-Feb-2018 deraadt

oops, typo


# 1.31 11-Feb-2018 deraadt

light documentation for MAP_STACK


# 1.30 11-Feb-2018 deraadt

Add MAP_STACK flag. Currently masked by mmap()


Revision tags: OPENBSD_6_0_BASE OPENBSD_6_1_BASE OPENBSD_6_2_BASE
# 1.29 01-Jun-2016 guenther

Delete the kernel compat bits for old mmap() MAP_OLD* flags

ok deraadt@ matthew@ jca@


Revision tags: OPENBSD_5_7_BASE OPENBSD_5_8_BASE OPENBSD_5_9_BASE
# 1.28 17-Dec-2014 guenther

Prefer MADV_* over POSIX_MADV_* in kernel for consistency: the latter
doesn't have all the values and therefore can't be used everywhere.

ok deraadt@ kettenis@


# 1.27 03-Oct-2014 kettenis

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 tags: OPENBSD_5_6_BASE
# 1.26 10-Jul-2014 matthew

Add MAP_ANONYMOUS as a synonym for MAP_ANON, per POSIX proposal

ok miod


# 1.25 27-Jun-2014 matthew

Cleanup support for legacy mmap flags

Move all legacy MAP_FOO values behind #ifndef _KERNEL and redefine
them to either be aliases for existing flags (e.g., MAP_COPY ->
MAP_PRIVATE) or 0.

Also, add MAP_OLDFOO defines (behind #ifndef _KERNEL) so the kernel
and kdump can remain compatible with current OpenBSD binaries.

ok deraadt


# 1.24 13-Jun-2014 matthew

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 tags: OPENBSD_5_4_BASE OPENBSD_5_5_BASE
# 1.23 31-May-2013 tedu

add shm_open and friends which i have been told ports programs would
like to use.
ok deraadt guenther


Revision tags: OPENBSD_5_2_BASE OPENBSD_5_3_BASE
# 1.22 21-Jul-2012 matthew

Add a new mmap(2) flag __MAP_NOREMAP for use with MAP_FIXED to
indicate that the kernel should fail with MAP_FAILED if the specified
address is not currently available instead of unmapping it.

Change ld.so on i386 to make use of __MAP_NOREMAP to improve
reliability.

__MAP_NOREMAP diff by guenther based on an earlier diff by Ariane;
ld.so bits by guenther and me
bulk build stress testing of earlier diffs by sthen
ok deraadt; committing now for further testing


Revision tags: OPENBSD_4_8_BASE OPENBSD_4_9_BASE OPENBSD_5_0_BASE OPENBSD_5_1_BASE
# 1.21 04-Jul-2010 guenther

Remove an obsolete (was in rev 1.1) and unclear comment


# 1.20 21-May-2010 miod

defintion -> definition.


# 1.19 18-May-2010 tedu

add posix_madvise, posix_memalign, strndup, and strnlen. mostly from
brad and millert, with hints from guenther, jmc, and otto I think.
ok previous.


Revision tags: OPENBSD_3_4_BASE OPENBSD_3_5_BASE OPENBSD_3_6_BASE OPENBSD_3_7_BASE OPENBSD_3_8_BASE OPENBSD_3_9_BASE OPENBSD_4_0_BASE OPENBSD_4_1_BASE OPENBSD_4_2_BASE OPENBSD_4_3_BASE OPENBSD_4_4_BASE OPENBSD_4_5_BASE OPENBSD_4_6_BASE OPENBSD_4_7_BASE SMP_SYNC_A SMP_SYNC_B
# 1.18 21-Jul-2003 tedu

enforce restrictions on prot and flags to mprotect and mmap. invalid or
undefined flags are now rejected instead of silently ignored. makes
"unintentional" mprotect calls a touch harder.
ok art@ deraadt@ jason@


# 1.17 01-Jul-2003 tedu

add MAP_TRYFIXED, mostly to help emulate other systems.
when set, uvm will not attempt to avoid a heap address, if requested.
from todd vierling, via
http://marc.theaimsgroup.com/?l=netbsd-tech-kern&m=105612525808607&w=1


# 1.16 02-Jun-2003 millert

Remove the advertising clause in the UCB license which Berkeley
rescinded 22 July 1999. Proofed by myself and Theo.


Revision tags: UBC_SYNC_A
# 1.15 28-Apr-2003 drahn

Change mquery() function call signature to be the same a mmap(). It
needs the prot/flags info and passing the addresses via arg/return allows
it to be traced via ktrace better than an in/out paramter.
This adds a new mquery syscall and renames the old one to omquery.
New kernel _MUST_ be built, booted, and 'make includes' before building
ld.so with this change.


# 1.14 25-Apr-2003 drahn

backout mquery change, something broke when not combined with a different diff.


# 1.13 25-Apr-2003 drahn

change mquery() function call signature to be the same a mmap(). It
needs the prot/flags info and passing the addresses via arg/return allows
it to be traced via ktrace better than an in/out paramter.
This adds a new mquery syscall and renames the old one to omquery.
New kernel _MUST_ be built and installed before building ld.so with this change.
ok millert@ tedu@


# 1.12 14-Apr-2003 art

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 tags: OPENBSD_3_1_BASE OPENBSD_3_2_BASE OPENBSD_3_3_BASE UBC_SYNC_B
# 1.11 14-Mar-2002 millert

First round of __P removal in sys


Revision tags: UBC_BASE
# 1.10 06-Nov-2001 art

branches: 1.10.2;
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 tags: OPENBSD_3_0_BASE
# 1.9 10-May-2001 art

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 tags: OPENBSD_2_9_BASE
# 1.8 09-Mar-2001 art

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 tags: OPENBSD_2_4_BASE OPENBSD_2_5_BASE OPENBSD_2_6_BASE OPENBSD_2_7_BASE OPENBSD_2_8_BASE SMP_BASE kame_19991208
# 1.7 02-Jun-1998 deraadt

branches: 1.7.8;
const mlock(2) and munlock(2)


Revision tags: OPENBSD_2_3_BASE
# 1.6 02-Jan-1998 deraadt

make mmap() return void *, add MAP_FAILED


# 1.5 14-Nov-1997 deraadt

convert to void *addr


# 1.4 13-Nov-1997 deraadt

make msync() have 3 args


Revision tags: OPENBSD_2_0_BASE OPENBSD_2_1_BASE OPENBSD_2_2_BASE
# 1.3 24-Mar-1996 tholo

Add prototype for mincore(2)


# 1.2 03-Mar-1996 niklas

From NetBSD: 960217 merge


# 1.1 18-Oct-1995 deraadt

branches: 1.1.1;
Initial revision


# 1.34 01-Mar-2019 cheloha

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@


# 1.33 11-Jan-2019 deraadt

mincore() is a relic from the past, exposing physical machine information
about shared resources which no program should see. only a few pieces of
software use it, generally poorly thought out. they are being fixed, so
mincore() can be deleted.
ok guenther tedu jca sthen, others


Revision tags: OPENBSD_6_3_BASE OPENBSD_6_4_BASE
# 1.32 11-Feb-2018 deraadt

oops, typo


# 1.31 11-Feb-2018 deraadt

light documentation for MAP_STACK


# 1.30 11-Feb-2018 deraadt

Add MAP_STACK flag. Currently masked by mmap()


Revision tags: OPENBSD_6_0_BASE OPENBSD_6_1_BASE OPENBSD_6_2_BASE
# 1.29 01-Jun-2016 guenther

Delete the kernel compat bits for old mmap() MAP_OLD* flags

ok deraadt@ matthew@ jca@


Revision tags: OPENBSD_5_7_BASE OPENBSD_5_8_BASE OPENBSD_5_9_BASE
# 1.28 17-Dec-2014 guenther

Prefer MADV_* over POSIX_MADV_* in kernel for consistency: the latter
doesn't have all the values and therefore can't be used everywhere.

ok deraadt@ kettenis@


# 1.27 03-Oct-2014 kettenis

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 tags: OPENBSD_5_6_BASE
# 1.26 10-Jul-2014 matthew

Add MAP_ANONYMOUS as a synonym for MAP_ANON, per POSIX proposal

ok miod


# 1.25 27-Jun-2014 matthew

Cleanup support for legacy mmap flags

Move all legacy MAP_FOO values behind #ifndef _KERNEL and redefine
them to either be aliases for existing flags (e.g., MAP_COPY ->
MAP_PRIVATE) or 0.

Also, add MAP_OLDFOO defines (behind #ifndef _KERNEL) so the kernel
and kdump can remain compatible with current OpenBSD binaries.

ok deraadt


# 1.24 13-Jun-2014 matthew

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 tags: OPENBSD_5_4_BASE OPENBSD_5_5_BASE
# 1.23 31-May-2013 tedu

add shm_open and friends which i have been told ports programs would
like to use.
ok deraadt guenther


Revision tags: OPENBSD_5_2_BASE OPENBSD_5_3_BASE
# 1.22 21-Jul-2012 matthew

Add a new mmap(2) flag __MAP_NOREMAP for use with MAP_FIXED to
indicate that the kernel should fail with MAP_FAILED if the specified
address is not currently available instead of unmapping it.

Change ld.so on i386 to make use of __MAP_NOREMAP to improve
reliability.

__MAP_NOREMAP diff by guenther based on an earlier diff by Ariane;
ld.so bits by guenther and me
bulk build stress testing of earlier diffs by sthen
ok deraadt; committing now for further testing


Revision tags: OPENBSD_4_8_BASE OPENBSD_4_9_BASE OPENBSD_5_0_BASE OPENBSD_5_1_BASE
# 1.21 04-Jul-2010 guenther

Remove an obsolete (was in rev 1.1) and unclear comment


# 1.20 21-May-2010 miod

defintion -> definition.


# 1.19 18-May-2010 tedu

add posix_madvise, posix_memalign, strndup, and strnlen. mostly from
brad and millert, with hints from guenther, jmc, and otto I think.
ok previous.


Revision tags: OPENBSD_3_4_BASE OPENBSD_3_5_BASE OPENBSD_3_6_BASE OPENBSD_3_7_BASE OPENBSD_3_8_BASE OPENBSD_3_9_BASE OPENBSD_4_0_BASE OPENBSD_4_1_BASE OPENBSD_4_2_BASE OPENBSD_4_3_BASE OPENBSD_4_4_BASE OPENBSD_4_5_BASE OPENBSD_4_6_BASE OPENBSD_4_7_BASE SMP_SYNC_A SMP_SYNC_B
# 1.18 21-Jul-2003 tedu

enforce restrictions on prot and flags to mprotect and mmap. invalid or
undefined flags are now rejected instead of silently ignored. makes
"unintentional" mprotect calls a touch harder.
ok art@ deraadt@ jason@


# 1.17 01-Jul-2003 tedu

add MAP_TRYFIXED, mostly to help emulate other systems.
when set, uvm will not attempt to avoid a heap address, if requested.
from todd vierling, via
http://marc.theaimsgroup.com/?l=netbsd-tech-kern&m=105612525808607&w=1


# 1.16 02-Jun-2003 millert

Remove the advertising clause in the UCB license which Berkeley
rescinded 22 July 1999. Proofed by myself and Theo.


Revision tags: UBC_SYNC_A
# 1.15 28-Apr-2003 drahn

Change mquery() function call signature to be the same a mmap(). It
needs the prot/flags info and passing the addresses via arg/return allows
it to be traced via ktrace better than an in/out paramter.
This adds a new mquery syscall and renames the old one to omquery.
New kernel _MUST_ be built, booted, and 'make includes' before building
ld.so with this change.


# 1.14 25-Apr-2003 drahn

backout mquery change, something broke when not combined with a different diff.


# 1.13 25-Apr-2003 drahn

change mquery() function call signature to be the same a mmap(). It
needs the prot/flags info and passing the addresses via arg/return allows
it to be traced via ktrace better than an in/out paramter.
This adds a new mquery syscall and renames the old one to omquery.
New kernel _MUST_ be built and installed before building ld.so with this change.
ok millert@ tedu@


# 1.12 14-Apr-2003 art

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 tags: OPENBSD_3_1_BASE OPENBSD_3_2_BASE OPENBSD_3_3_BASE UBC_SYNC_B
# 1.11 14-Mar-2002 millert

First round of __P removal in sys


Revision tags: UBC_BASE
# 1.10 06-Nov-2001 art

branches: 1.10.2;
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 tags: OPENBSD_3_0_BASE
# 1.9 10-May-2001 art

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 tags: OPENBSD_2_9_BASE
# 1.8 09-Mar-2001 art

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 tags: OPENBSD_2_4_BASE OPENBSD_2_5_BASE OPENBSD_2_6_BASE OPENBSD_2_7_BASE OPENBSD_2_8_BASE SMP_BASE kame_19991208
# 1.7 02-Jun-1998 deraadt

branches: 1.7.8;
const mlock(2) and munlock(2)


Revision tags: OPENBSD_2_3_BASE
# 1.6 02-Jan-1998 deraadt

make mmap() return void *, add MAP_FAILED


# 1.5 14-Nov-1997 deraadt

convert to void *addr


# 1.4 13-Nov-1997 deraadt

make msync() have 3 args


Revision tags: OPENBSD_2_0_BASE OPENBSD_2_1_BASE OPENBSD_2_2_BASE
# 1.3 24-Mar-1996 tholo

Add prototype for mincore(2)


# 1.2 03-Mar-1996 niklas

From NetBSD: 960217 merge


# 1.1 18-Oct-1995 deraadt

branches: 1.1.1;
Initial revision


# 1.33 11-Jan-2019 deraadt

mincore() is a relic from the past, exposing physical machine information
about shared resources which no program should see. only a few pieces of
software use it, generally poorly thought out. they are being fixed, so
mincore() can be deleted.
ok guenther tedu jca sthen, others


Revision tags: OPENBSD_6_3_BASE OPENBSD_6_4_BASE
# 1.32 11-Feb-2018 deraadt

oops, typo


# 1.31 11-Feb-2018 deraadt

light documentation for MAP_STACK


# 1.30 11-Feb-2018 deraadt

Add MAP_STACK flag. Currently masked by mmap()


Revision tags: OPENBSD_6_0_BASE OPENBSD_6_1_BASE OPENBSD_6_2_BASE
# 1.29 01-Jun-2016 guenther

Delete the kernel compat bits for old mmap() MAP_OLD* flags

ok deraadt@ matthew@ jca@


Revision tags: OPENBSD_5_7_BASE OPENBSD_5_8_BASE OPENBSD_5_9_BASE
# 1.28 17-Dec-2014 guenther

Prefer MADV_* over POSIX_MADV_* in kernel for consistency: the latter
doesn't have all the values and therefore can't be used everywhere.

ok deraadt@ kettenis@


# 1.27 03-Oct-2014 kettenis

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 tags: OPENBSD_5_6_BASE
# 1.26 10-Jul-2014 matthew

Add MAP_ANONYMOUS as a synonym for MAP_ANON, per POSIX proposal

ok miod


# 1.25 27-Jun-2014 matthew

Cleanup support for legacy mmap flags

Move all legacy MAP_FOO values behind #ifndef _KERNEL and redefine
them to either be aliases for existing flags (e.g., MAP_COPY ->
MAP_PRIVATE) or 0.

Also, add MAP_OLDFOO defines (behind #ifndef _KERNEL) so the kernel
and kdump can remain compatible with current OpenBSD binaries.

ok deraadt


# 1.24 13-Jun-2014 matthew

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 tags: OPENBSD_5_4_BASE OPENBSD_5_5_BASE
# 1.23 31-May-2013 tedu

add shm_open and friends which i have been told ports programs would
like to use.
ok deraadt guenther


Revision tags: OPENBSD_5_2_BASE OPENBSD_5_3_BASE
# 1.22 21-Jul-2012 matthew

Add a new mmap(2) flag __MAP_NOREMAP for use with MAP_FIXED to
indicate that the kernel should fail with MAP_FAILED if the specified
address is not currently available instead of unmapping it.

Change ld.so on i386 to make use of __MAP_NOREMAP to improve
reliability.

__MAP_NOREMAP diff by guenther based on an earlier diff by Ariane;
ld.so bits by guenther and me
bulk build stress testing of earlier diffs by sthen
ok deraadt; committing now for further testing


Revision tags: OPENBSD_4_8_BASE OPENBSD_4_9_BASE OPENBSD_5_0_BASE OPENBSD_5_1_BASE
# 1.21 04-Jul-2010 guenther

Remove an obsolete (was in rev 1.1) and unclear comment


# 1.20 21-May-2010 miod

defintion -> definition.


# 1.19 18-May-2010 tedu

add posix_madvise, posix_memalign, strndup, and strnlen. mostly from
brad and millert, with hints from guenther, jmc, and otto I think.
ok previous.


Revision tags: OPENBSD_3_4_BASE OPENBSD_3_5_BASE OPENBSD_3_6_BASE OPENBSD_3_7_BASE OPENBSD_3_8_BASE OPENBSD_3_9_BASE OPENBSD_4_0_BASE OPENBSD_4_1_BASE OPENBSD_4_2_BASE OPENBSD_4_3_BASE OPENBSD_4_4_BASE OPENBSD_4_5_BASE OPENBSD_4_6_BASE OPENBSD_4_7_BASE SMP_SYNC_A SMP_SYNC_B
# 1.18 21-Jul-2003 tedu

enforce restrictions on prot and flags to mprotect and mmap. invalid or
undefined flags are now rejected instead of silently ignored. makes
"unintentional" mprotect calls a touch harder.
ok art@ deraadt@ jason@


# 1.17 01-Jul-2003 tedu

add MAP_TRYFIXED, mostly to help emulate other systems.
when set, uvm will not attempt to avoid a heap address, if requested.
from todd vierling, via
http://marc.theaimsgroup.com/?l=netbsd-tech-kern&m=105612525808607&w=1


# 1.16 02-Jun-2003 millert

Remove the advertising clause in the UCB license which Berkeley
rescinded 22 July 1999. Proofed by myself and Theo.


Revision tags: UBC_SYNC_A
# 1.15 28-Apr-2003 drahn

Change mquery() function call signature to be the same a mmap(). It
needs the prot/flags info and passing the addresses via arg/return allows
it to be traced via ktrace better than an in/out paramter.
This adds a new mquery syscall and renames the old one to omquery.
New kernel _MUST_ be built, booted, and 'make includes' before building
ld.so with this change.


# 1.14 25-Apr-2003 drahn

backout mquery change, something broke when not combined with a different diff.


# 1.13 25-Apr-2003 drahn

change mquery() function call signature to be the same a mmap(). It
needs the prot/flags info and passing the addresses via arg/return allows
it to be traced via ktrace better than an in/out paramter.
This adds a new mquery syscall and renames the old one to omquery.
New kernel _MUST_ be built and installed before building ld.so with this change.
ok millert@ tedu@


# 1.12 14-Apr-2003 art

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 tags: OPENBSD_3_1_BASE OPENBSD_3_2_BASE OPENBSD_3_3_BASE UBC_SYNC_B
# 1.11 14-Mar-2002 millert

First round of __P removal in sys


Revision tags: UBC_BASE
# 1.10 06-Nov-2001 art

branches: 1.10.2;
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 tags: OPENBSD_3_0_BASE
# 1.9 10-May-2001 art

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 tags: OPENBSD_2_9_BASE
# 1.8 09-Mar-2001 art

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 tags: OPENBSD_2_4_BASE OPENBSD_2_5_BASE OPENBSD_2_6_BASE OPENBSD_2_7_BASE OPENBSD_2_8_BASE SMP_BASE kame_19991208
# 1.7 02-Jun-1998 deraadt

branches: 1.7.8;
const mlock(2) and munlock(2)


Revision tags: OPENBSD_2_3_BASE
# 1.6 02-Jan-1998 deraadt

make mmap() return void *, add MAP_FAILED


# 1.5 14-Nov-1997 deraadt

convert to void *addr


# 1.4 13-Nov-1997 deraadt

make msync() have 3 args


Revision tags: OPENBSD_2_0_BASE OPENBSD_2_1_BASE OPENBSD_2_2_BASE
# 1.3 24-Mar-1996 tholo

Add prototype for mincore(2)


# 1.2 03-Mar-1996 niklas

From NetBSD: 960217 merge


# 1.1 18-Oct-1995 deraadt

branches: 1.1.1;
Initial revision


# 1.32 11-Feb-2018 deraadt

oops, typo


# 1.31 11-Feb-2018 deraadt

light documentation for MAP_STACK


# 1.30 11-Feb-2018 deraadt

Add MAP_STACK flag. Currently masked by mmap()


Revision tags: OPENBSD_6_0_BASE OPENBSD_6_1_BASE OPENBSD_6_2_BASE
# 1.29 01-Jun-2016 guenther

Delete the kernel compat bits for old mmap() MAP_OLD* flags

ok deraadt@ matthew@ jca@


Revision tags: OPENBSD_5_7_BASE OPENBSD_5_8_BASE OPENBSD_5_9_BASE
# 1.28 17-Dec-2014 guenther

Prefer MADV_* over POSIX_MADV_* in kernel for consistency: the latter
doesn't have all the values and therefore can't be used everywhere.

ok deraadt@ kettenis@


# 1.27 03-Oct-2014 kettenis

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 tags: OPENBSD_5_6_BASE
# 1.26 10-Jul-2014 matthew

Add MAP_ANONYMOUS as a synonym for MAP_ANON, per POSIX proposal

ok miod


# 1.25 27-Jun-2014 matthew

Cleanup support for legacy mmap flags

Move all legacy MAP_FOO values behind #ifndef _KERNEL and redefine
them to either be aliases for existing flags (e.g., MAP_COPY ->
MAP_PRIVATE) or 0.

Also, add MAP_OLDFOO defines (behind #ifndef _KERNEL) so the kernel
and kdump can remain compatible with current OpenBSD binaries.

ok deraadt


# 1.24 13-Jun-2014 matthew

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 tags: OPENBSD_5_4_BASE OPENBSD_5_5_BASE
# 1.23 31-May-2013 tedu

add shm_open and friends which i have been told ports programs would
like to use.
ok deraadt guenther


Revision tags: OPENBSD_5_2_BASE OPENBSD_5_3_BASE
# 1.22 21-Jul-2012 matthew

Add a new mmap(2) flag __MAP_NOREMAP for use with MAP_FIXED to
indicate that the kernel should fail with MAP_FAILED if the specified
address is not currently available instead of unmapping it.

Change ld.so on i386 to make use of __MAP_NOREMAP to improve
reliability.

__MAP_NOREMAP diff by guenther based on an earlier diff by Ariane;
ld.so bits by guenther and me
bulk build stress testing of earlier diffs by sthen
ok deraadt; committing now for further testing


Revision tags: OPENBSD_4_8_BASE OPENBSD_4_9_BASE OPENBSD_5_0_BASE OPENBSD_5_1_BASE
# 1.21 04-Jul-2010 guenther

Remove an obsolete (was in rev 1.1) and unclear comment


# 1.20 21-May-2010 miod

defintion -> definition.


# 1.19 18-May-2010 tedu

add posix_madvise, posix_memalign, strndup, and strnlen. mostly from
brad and millert, with hints from guenther, jmc, and otto I think.
ok previous.


Revision tags: OPENBSD_3_4_BASE OPENBSD_3_5_BASE OPENBSD_3_6_BASE OPENBSD_3_7_BASE OPENBSD_3_8_BASE OPENBSD_3_9_BASE OPENBSD_4_0_BASE OPENBSD_4_1_BASE OPENBSD_4_2_BASE OPENBSD_4_3_BASE OPENBSD_4_4_BASE OPENBSD_4_5_BASE OPENBSD_4_6_BASE OPENBSD_4_7_BASE SMP_SYNC_A SMP_SYNC_B
# 1.18 21-Jul-2003 tedu

enforce restrictions on prot and flags to mprotect and mmap. invalid or
undefined flags are now rejected instead of silently ignored. makes
"unintentional" mprotect calls a touch harder.
ok art@ deraadt@ jason@


# 1.17 01-Jul-2003 tedu

add MAP_TRYFIXED, mostly to help emulate other systems.
when set, uvm will not attempt to avoid a heap address, if requested.
from todd vierling, via
http://marc.theaimsgroup.com/?l=netbsd-tech-kern&m=105612525808607&w=1


# 1.16 02-Jun-2003 millert

Remove the advertising clause in the UCB license which Berkeley
rescinded 22 July 1999. Proofed by myself and Theo.


Revision tags: UBC_SYNC_A
# 1.15 28-Apr-2003 drahn

Change mquery() function call signature to be the same a mmap(). It
needs the prot/flags info and passing the addresses via arg/return allows
it to be traced via ktrace better than an in/out paramter.
This adds a new mquery syscall and renames the old one to omquery.
New kernel _MUST_ be built, booted, and 'make includes' before building
ld.so with this change.


# 1.14 25-Apr-2003 drahn

backout mquery change, something broke when not combined with a different diff.


# 1.13 25-Apr-2003 drahn

change mquery() function call signature to be the same a mmap(). It
needs the prot/flags info and passing the addresses via arg/return allows
it to be traced via ktrace better than an in/out paramter.
This adds a new mquery syscall and renames the old one to omquery.
New kernel _MUST_ be built and installed before building ld.so with this change.
ok millert@ tedu@


# 1.12 14-Apr-2003 art

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 tags: OPENBSD_3_1_BASE OPENBSD_3_2_BASE OPENBSD_3_3_BASE UBC_SYNC_B
# 1.11 14-Mar-2002 millert

First round of __P removal in sys


Revision tags: UBC_BASE
# 1.10 06-Nov-2001 art

branches: 1.10.2;
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 tags: OPENBSD_3_0_BASE
# 1.9 10-May-2001 art

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 tags: OPENBSD_2_9_BASE
# 1.8 09-Mar-2001 art

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 tags: OPENBSD_2_4_BASE OPENBSD_2_5_BASE OPENBSD_2_6_BASE OPENBSD_2_7_BASE OPENBSD_2_8_BASE SMP_BASE kame_19991208
# 1.7 02-Jun-1998 deraadt

branches: 1.7.8;
const mlock(2) and munlock(2)


Revision tags: OPENBSD_2_3_BASE
# 1.6 02-Jan-1998 deraadt

make mmap() return void *, add MAP_FAILED


# 1.5 14-Nov-1997 deraadt

convert to void *addr


# 1.4 13-Nov-1997 deraadt

make msync() have 3 args


Revision tags: OPENBSD_2_0_BASE OPENBSD_2_1_BASE OPENBSD_2_2_BASE
# 1.3 24-Mar-1996 tholo

Add prototype for mincore(2)


# 1.2 03-Mar-1996 niklas

From NetBSD: 960217 merge


# 1.1 18-Oct-1995 deraadt

branches: 1.1.1;
Initial revision


Revision tags: OPENBSD_6_0_BASE OPENBSD_6_1_BASE OPENBSD_6_2_BASE
# 1.29 01-Jun-2016 guenther

Delete the kernel compat bits for old mmap() MAP_OLD* flags

ok deraadt@ matthew@ jca@


Revision tags: OPENBSD_5_7_BASE OPENBSD_5_8_BASE OPENBSD_5_9_BASE
# 1.28 17-Dec-2014 guenther

Prefer MADV_* over POSIX_MADV_* in kernel for consistency: the latter
doesn't have all the values and therefore can't be used everywhere.

ok deraadt@ kettenis@


# 1.27 03-Oct-2014 kettenis

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 tags: OPENBSD_5_6_BASE
# 1.26 10-Jul-2014 matthew

Add MAP_ANONYMOUS as a synonym for MAP_ANON, per POSIX proposal

ok miod


# 1.25 27-Jun-2014 matthew

Cleanup support for legacy mmap flags

Move all legacy MAP_FOO values behind #ifndef _KERNEL and redefine
them to either be aliases for existing flags (e.g., MAP_COPY ->
MAP_PRIVATE) or 0.

Also, add MAP_OLDFOO defines (behind #ifndef _KERNEL) so the kernel
and kdump can remain compatible with current OpenBSD binaries.

ok deraadt


# 1.24 13-Jun-2014 matthew

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 tags: OPENBSD_5_4_BASE OPENBSD_5_5_BASE
# 1.23 31-May-2013 tedu

add shm_open and friends which i have been told ports programs would
like to use.
ok deraadt guenther


Revision tags: OPENBSD_5_2_BASE OPENBSD_5_3_BASE
# 1.22 21-Jul-2012 matthew

Add a new mmap(2) flag __MAP_NOREMAP for use with MAP_FIXED to
indicate that the kernel should fail with MAP_FAILED if the specified
address is not currently available instead of unmapping it.

Change ld.so on i386 to make use of __MAP_NOREMAP to improve
reliability.

__MAP_NOREMAP diff by guenther based on an earlier diff by Ariane;
ld.so bits by guenther and me
bulk build stress testing of earlier diffs by sthen
ok deraadt; committing now for further testing


Revision tags: OPENBSD_4_8_BASE OPENBSD_4_9_BASE OPENBSD_5_0_BASE OPENBSD_5_1_BASE
# 1.21 04-Jul-2010 guenther

Remove an obsolete (was in rev 1.1) and unclear comment


# 1.20 21-May-2010 miod

defintion -> definition.


# 1.19 18-May-2010 tedu

add posix_madvise, posix_memalign, strndup, and strnlen. mostly from
brad and millert, with hints from guenther, jmc, and otto I think.
ok previous.


Revision tags: OPENBSD_3_4_BASE OPENBSD_3_5_BASE OPENBSD_3_6_BASE OPENBSD_3_7_BASE OPENBSD_3_8_BASE OPENBSD_3_9_BASE OPENBSD_4_0_BASE OPENBSD_4_1_BASE OPENBSD_4_2_BASE OPENBSD_4_3_BASE OPENBSD_4_4_BASE OPENBSD_4_5_BASE OPENBSD_4_6_BASE OPENBSD_4_7_BASE SMP_SYNC_A SMP_SYNC_B
# 1.18 21-Jul-2003 tedu

enforce restrictions on prot and flags to mprotect and mmap. invalid or
undefined flags are now rejected instead of silently ignored. makes
"unintentional" mprotect calls a touch harder.
ok art@ deraadt@ jason@


# 1.17 01-Jul-2003 tedu

add MAP_TRYFIXED, mostly to help emulate other systems.
when set, uvm will not attempt to avoid a heap address, if requested.
from todd vierling, via
http://marc.theaimsgroup.com/?l=netbsd-tech-kern&m=105612525808607&w=1


# 1.16 02-Jun-2003 millert

Remove the advertising clause in the UCB license which Berkeley
rescinded 22 July 1999. Proofed by myself and Theo.


Revision tags: UBC_SYNC_A
# 1.15 28-Apr-2003 drahn

Change mquery() function call signature to be the same a mmap(). It
needs the prot/flags info and passing the addresses via arg/return allows
it to be traced via ktrace better than an in/out paramter.
This adds a new mquery syscall and renames the old one to omquery.
New kernel _MUST_ be built, booted, and 'make includes' before building
ld.so with this change.


# 1.14 25-Apr-2003 drahn

backout mquery change, something broke when not combined with a different diff.


# 1.13 25-Apr-2003 drahn

change mquery() function call signature to be the same a mmap(). It
needs the prot/flags info and passing the addresses via arg/return allows
it to be traced via ktrace better than an in/out paramter.
This adds a new mquery syscall and renames the old one to omquery.
New kernel _MUST_ be built and installed before building ld.so with this change.
ok millert@ tedu@


# 1.12 14-Apr-2003 art

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 tags: OPENBSD_3_1_BASE OPENBSD_3_2_BASE OPENBSD_3_3_BASE UBC_SYNC_B
# 1.11 14-Mar-2002 millert

First round of __P removal in sys


Revision tags: UBC_BASE
# 1.10 06-Nov-2001 art

branches: 1.10.2;
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 tags: OPENBSD_3_0_BASE
# 1.9 10-May-2001 art

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 tags: OPENBSD_2_9_BASE
# 1.8 09-Mar-2001 art

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 tags: OPENBSD_2_4_BASE OPENBSD_2_5_BASE OPENBSD_2_6_BASE OPENBSD_2_7_BASE OPENBSD_2_8_BASE SMP_BASE kame_19991208
# 1.7 02-Jun-1998 deraadt

branches: 1.7.8;
const mlock(2) and munlock(2)


Revision tags: OPENBSD_2_3_BASE
# 1.6 02-Jan-1998 deraadt

make mmap() return void *, add MAP_FAILED


# 1.5 14-Nov-1997 deraadt

convert to void *addr


# 1.4 13-Nov-1997 deraadt

make msync() have 3 args


Revision tags: OPENBSD_2_0_BASE OPENBSD_2_1_BASE OPENBSD_2_2_BASE
# 1.3 24-Mar-1996 tholo

Add prototype for mincore(2)


# 1.2 03-Mar-1996 niklas

From NetBSD: 960217 merge


# 1.1 18-Oct-1995 deraadt

branches: 1.1.1;
Initial revision