freebsd-nq/sys/vm
Brooks Davis 74a1b66cf4 Extend mmap/mprotect API to specify the max page protections.
A new macro PROT_MAX() alters a protection value so it can be OR'd with
a regular protection value to specify the maximum permissions.  If
present, these flags specify the maximum permissions.

While these flags are non-portable, they can be used in portable code
with simple ifdefs to expand PROT_MAX() to 0.

This change allows (e.g.) a region that must be writable during run-time
linking or JIT code generation to be made permanently read+execute after
writes are complete.  This complements W^X protections allowing more
precise control by the programmer.

This change alters mprotect argument checking and returns an error when
unhandled protection flags are set.  This differs from POSIX (in that
POSIX only specifies an error), but is the documented behavior on Linux
and more closely matches historical mmap behavior.

In addition to explicit setting of the maximum permissions, an
experimental sysctl vm.imply_prot_max causes mmap to assume that the
initial permissions requested should be the maximum when the sysctl is
set to 1.  PROT_NONE mappings are excluded from this for compatibility
with rtld and other consumers that use such mappings to reserve
address space before mapping contents into part of the reservation.  A
final version this is expected to provide per-binary and per-process
opt-in/out options and this sysctl will go away in its current form.
As such it is undocumented.

Reviewed by:	emaste, kib (prior version), markj
Additional suggestions from:	alc
Obtained from:	CheriBSD
Sponsored by:	DARPA, AFRL
Differential Revision:	https://reviews.freebsd.org/D18880
2019-06-20 18:24:16 +00:00
..
_vm_radix.h
default_pager.c
device_pager.c
memguard.c Add a vm_page_wired() predicate. 2019-06-02 01:00:17 +00:00
memguard.h
phys_pager.c
pmap.h
redzone.c
redzone.h
sg_pager.c
swap_pager.c Simple code refactoring originally in D13484. 2019-06-08 17:49:17 +00:00
swap_pager.h
uma_core.c Replace uses of vm_page_unwire(m, PQ_NONE) with vm_page_unwire_noq(m). 2019-06-07 18:23:29 +00:00
uma_dbg.c
uma_dbg.h
uma_int.h
uma.h
vm_domainset.c
vm_domainset.h
vm_extern.h
vm_fault.c Add a vm_page_wired() predicate. 2019-06-02 01:00:17 +00:00
vm_glue.c Replace uses of vm_page_unwire(m, PQ_NONE) with vm_page_unwire_noq(m). 2019-06-07 18:23:29 +00:00
vm_init.c
vm_kern.c Replace uses of vm_page_unwire(m, PQ_NONE) with vm_page_unwire_noq(m). 2019-06-07 18:23:29 +00:00
vm_kern.h
vm_map.c Critical comments were lost in r349203. This patch seeks to restore 2019-06-15 04:30:13 +00:00
vm_map.h Style MAP_ENTRY_ and MAP_ definitions. 2019-06-08 20:28:04 +00:00
vm_meter.c Provide separate accounting for user-wired pages. 2019-05-13 16:38:48 +00:00
vm_mmap.c Extend mmap/mprotect API to specify the max page protections. 2019-06-20 18:24:16 +00:00
vm_object.c Add a vm_page_wired() predicate. 2019-06-02 01:00:17 +00:00
vm_object.h
vm_page.c Group vm_page_activate()'s definition with other related functions. 2019-06-19 21:36:00 +00:00
vm_page.h Add a vm_page_wired() predicate. 2019-06-02 01:00:17 +00:00
vm_pageout.c Add a vm_page_wired() predicate. 2019-06-02 01:00:17 +00:00
vm_pageout.h Provide separate accounting for user-wired pages. 2019-05-13 16:38:48 +00:00
vm_pagequeue.h
vm_pager.c
vm_pager.h
vm_param.h
vm_phys.c The function vm_phys_free_contig invokes vm_phys_free_pages for every 2019-05-31 21:02:42 +00:00
vm_phys.h The function vm_phys_free_contig invokes vm_phys_free_pages for every 2019-05-31 21:02:42 +00:00
vm_radix.c
vm_radix.h
vm_reserv.c The means of finding ranges of free pages was changed for 2019-06-06 16:28:34 +00:00
vm_reserv.h Retire vm_reserv_extend_{contig,page}(). These functions were introduced 2019-06-03 05:15:36 +00:00
vm_swapout_dummy.c
vm_swapout.c
vm_unix.c Provide separate accounting for user-wired pages. 2019-05-13 16:38:48 +00:00
vm.h
vnode_pager.c Include ktr.h in more compilation units 2019-05-21 20:38:48 +00:00
vnode_pager.h