aboutsummaryrefslogtreecommitdiff
path: root/lib/libc/sys/mmap.2
Commit message (Collapse)AuthorAgeFilesLines
* libsys: relocate implementations and manpagesBrooks Davis2024-02-051-564/+0
| | | | | | | | | Remove core system call implementations and documentation to lib/libsys and lib/libsys/<arch> from lib/libc/sys and lib/libc/<arch>/<sys>. Update paths to allow libc to find them in their new home. Reviewed by: kib, emaste, imp Pull Request: https://github.com/freebsd/freebsd-src/pull/908
* lib: Remove ancient SCCS tags.Warner Losh2023-11-271-2/+0
| | | | | | | | Remove ancient SCCS tags from the tree, automated scripting, with two minor fixup to keep things compiling. All the common forms in the tree were removed with a perl script. Sponsored by: Netflix
* Remove $FreeBSD$: one-line nroff patternWarner Losh2023-08-161-1/+0
| | | | Remove /^\.\\"\s*\$FreeBSD\$$\n/
* vm: Allow MAP_32BIT for all architecturesDmitry Chagin2023-08-141-2/+1
| | | | | Reviewed by: alc, kib, markj Differential revision: https://reviews.freebsd.org/D41435
* mmap(2): Update .Dd missed in the last commitGuangyuan Yang2020-12-241-1/+1
| | | | | PR: 252097 MFC after: 1 week
* mmap(2): Fix a typoGuangyuan Yang2020-12-241-1/+1
| | | | | | PR: 252097 MFC after: 1 week Reported by: Nick Frampton <nick.frampton@akips.com>
* Revise the description of MAP_STACK. In particular, describe the guardAlan Cox2020-10-271-19/+23
| | | | | | | | | | | in more detail. Reviewed by: bcr, kib, markj MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D26908 Notes: svn path=/head/; revision=367087
* mmap(2): Document guard size for MAP_STACK and related EINVAL.Konstantin Belousov2020-10-211-1/+8
| | | | | | | | | | | Based on submission by: emaste Reviewed by: emaste, markj Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D26894 Notes: svn path=/head/; revision=366918
* mmap.2: correct prot argument terminologyEd Maste2020-06-031-2/+2
| | | | | | | | | | | | One of the error descriptions referred to permissions; in context the meaning was probably clear, but the prot values are properly called protections. MFC after: 1 week Sponsored by: The FreeBSD Foundation Notes: svn path=/head/; revision=361769
* Return ENOTSUP for mmap/mprotect if prot not subset of prot_maxEd Maste2020-02-261-6/+6
| | | | | | | | | | | | | | | | | | | From POSIX, [ENOTSUP] The implementation does not support the combination of accesses requested in the prot argument. This fits the case that prot contains permissions which are not a subset of prot_max. Reviewed by: brooks, cem Relnotes: Yes Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D23843 Notes: svn path=/head/; revision=358355
* Add PROT_MAX to the HISTORY section.Brooks Davis2019-06-201-0/+13
| | | | | | | | | | | | | | | In the case of mmap(), add a HISTORY section. Mention that mmap() and mprotect()'s documentation predates an implementation. The implementation first saw wide use in 4.3-Reno, but there seems to be no easy way to express that in mdoc so stick with 4.4BSD. Reviewed by: emaste Requested by: cem Sponsored by: DARPA, AFRL Differential Revision: https://reviews.freebsd.org/D20713 Notes: svn path=/head/; revision=349245
* Extend mmap/mprotect API to specify the max page protections.Brooks Davis2019-06-201-1/+22
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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 Notes: svn path=/head/; revision=349240
* Simplify language.Konstantin Belousov2017-07-081-3/+5
| | | | | | | | Submitted by: wblock MFC after: 3 days Notes: svn path=/head/; revision=320801
* Implement address space guards.Konstantin Belousov2017-06-241-0/+40
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Guard, requested by the MAP_GUARD mmap(2) flag, prevents the reuse of the allocated address space, but does not allow instantiation of the pages in the range. It is useful for more explicit support for usual two-stage reserve then commit allocators, since it prevents accidental instantiation of the mapping, e.g. by mprotect(2). Use guards to reimplement stack grow code. Explicitely track stack grow area with the guard, including the stack guard page. On stack grow, trivial shift of the guard map entry and stack map entry limits makes the stack expansion. Move the code to detect stack grow and call vm_map_growstack(), from vm_fault() into vm_map_lookup(). As result, it is impossible to get random mapping to occur in the stack grow area, or to overlap the stack guard page. Enable stack guard page by default. Reviewed by: alc, markj Man page update reviewed by: alc, bjk, emaste, markj, pho Tested by: pho, Qualys Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D11306 (man pages) Notes: svn path=/head/; revision=320317
* Remove the description of MAP_HASSEMAPHORE.Konstantin Belousov2017-06-241-4/+1
| | | | | | | | | | | | | | The flag is not implemented, all FreeBSD architectures correctly handle locks on normal cacheable mappings. On the other hand, the flag was specified by some software, so it is kept in the header as nop. Removal from the man page should discourage its use. Reviewed by: alc, bjk, emaste, markj, pho MFC after: 3 days X-Differential revision: https://reviews.freebsd.org/D11306 Notes: svn path=/head/; revision=320314
* Fix typo.Konstantin Belousov2017-06-241-1/+1
| | | | | | | | Noted by: alc MFC after: 3 days Notes: svn path=/head/; revision=320313
* Renumber copyright clause 4Warner Losh2017-02-281-1/+1
| | | | | | | | | | | | Renumber cluase 4 to 3, per what everybody else did when BSD granted them permission to remove clause 3. My insistance on keeping the same numbering for legal reasons is too pedantic, so give up on that point. Submitted by: Jan Schaumann <jschauma@stevens.edu> Pull Request: https://github.com/freebsd/freebsd/pull/96 Notes: svn path=/head/; revision=314436
* Consistently handle negative or wrapping offsets in the mmap(2) syscalls.Konstantin Belousov2017-02-121-3/+35
| | | | | | | | | | | | | | | | | | | | | | | | | | | For regular files and posix shared memory, POSIX requires that [offset, offset + size) range is legitimate. At the maping time, check that offset is not negative. Allowing negative offsets might expose the data that filesystem put into vm_object for internal use, esp. due to OFF_TO_IDX() signess treatment. Fault handler verifies that the mapped range is valid, assuming that mmap(2) checked that arithmetic gives no undefined results. For device mappings, leave the semantic of negative offsets to the driver. Correct object page index calculation to not erronously propagate sign. In either case, disallow overflow of offset + size. Update mmap(2) man page to explain the requirement of the range validity, and behaviour when the range becomes invalid after mapping. Reported and tested by: royger (previous version) Reviewed by: alc Sponsored by: The FreeBSD Foundation MFC after: 2 weeks Notes: svn path=/head/; revision=313690
* Launder VPO_NOSYNC pages upon vnode deactivation.Mark Johnston2016-11-261-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | | As of r234483, vnode deactivation causes non-VPO_NOSYNC pages to be laundered. This behaviour has two problems: 1. Dirty VPO_NOSYNC pages must be laundered before the vnode can be reclaimed, and this work may be unfairly deferred to the vnlru process or an unrelated application when the system is under vnode pressure. 2. Deactivation of a vnode with dirty VPO_NOSYNC pages requires a scan of the corresponding VM object's memq for non-VPO_NOSYNC dirty pages; if the laundry thread needs to launder pages from an unreferenced such vnode, it will reactivate and deactivate the vnode with each laundering, potentially resulting in a large number of expensive scans. Therefore, ensure that all dirty pages are laundered upon deactivation, i.e., when all maps of the vnode are removed and all references are released. Reviewed by: alc, kib MFC after: 1 month Differential Revision: https://reviews.freebsd.org/D8641 Notes: svn path=/head/; revision=309200
* fix spelling, add comma and remove BUGS section.. it provided no usefulJohn-Mark Gurney2015-02-191-17/+3
| | | | | | | information, and is not really bugs, but limitations for other reasons... Notes: svn path=/head/; revision=278981
* - Remove mention of MAP_INHERIT. It hasn't been implemented for thirteenJohn Baldwin2014-09-171-14/+1
| | | | | | | | | | | years. - Remove mention of unimplemented MAP_SWAP. There are no future plans to implement it. Submitted by: alc (2) Notes: svn path=/head/; revision=271722
* Add stricter checking of some mmap() arguments:John Baldwin2014-09-151-1/+24
| | | | | | | | | | | | | | | - Fail with EINVAL if an invalid protection mask is passed to mmap(). - Fail with EINVAL if an unknown flag is passed to mmap(). - Fail with EINVAL if both MAP_PRIVATE and MAP_SHARED are passed to mmap(). - Require one of either MAP_PRIVATE or MAP_SHARED for non-anonymous mappings. Reviewed by: alc, kib MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D698 Notes: svn path=/head/; revision=271635
* Add MAP_EXCL flag for mmap(2). It should be combined with MAP_FIXED,Konstantin Belousov2014-06-191-6/+27
| | | | | | | | | | | | | | and prevents the request from deleting existing mappings in the region, failing instead. Reviewed by: alc Discussed with: jhb Tested by: markj, pho (previous version, as part of the bigger patch) Sponsored by: The FreeBSD Foundation MFC after: 1 week Notes: svn path=/head/; revision=267630
* Add a mmap flag (MAP_32BIT) on 64-bit platforms to request that a mapping useJohn Baldwin2013-09-091-1/+14
| | | | | | | | | | | | | | | | an address in the first 2GB of the process's address space. This flag should have the same semantics as the same flag on Linux. To facilitate this, add a new parameter to vm_map_find() that specifies an optional maximum virtual address. While here, fix several callers of vm_map_find() to use a VMFS_* constant for the findspace argument instead of TRUE and FALSE. Reviewed by: alc Approved by: re (kib) Notes: svn path=/head/; revision=255426
* Add new mmap(2) flags to permit applications to request specific virtualJohn Baldwin2013-08-161-3/+50
| | | | | | | | | | | | | | | | | | | | | | | | | | | | address alignment of mappings. - MAP_ALIGNED(n) requests a mapping aligned on a boundary of (1 << n). Requests for n >= number of bits in a pointer or less than the size of a page fail with EINVAL. This matches the API provided by NetBSD. - MAP_ALIGNED_SUPER is a special case of MAP_ALIGNED. It can be used to optimize the chances of using large pages. By default it will align the mapping on a large page boundary (the system is free to choose any large page size to align to that seems best for the mapping request). However, if the object being mapped is already using large pages, then it will align the virtual mapping to match the existing large pages in the object instead. - Internally, VMFS_ALIGNED_SPACE is now renamed to VMFS_SUPER_SPACE, and VMFS_ALIGNED_SPACE(n) is repurposed for specifying a specific alignment. MAP_ALIGNED(n) maps to using VMFS_ALIGNED_SPACE(n), while MAP_ALIGNED_SUPER maps to VMFS_SUPER_SPACE. - mmap() of a device object now uses VMFS_OPTIMAL_SPACE rather than explicitly using VMFS_SUPER_SPACE. All device objects are forced to use a specific color on creation, so VMFS_OPTIMAL_SPACE is effectively equivalent. Reviewed by: alc MFC after: 1 month Notes: svn path=/head/; revision=254430
* Do not claim that msync(2) is obsoleted [1].Konstantin Belousov2012-03-171-2/+2
| | | | | | | | | | | Document EIO from msync(2). Inspired by PR: docs/165929 [1] Reviewed by: jilles MFC after: 2 weeks Notes: svn path=/head/; revision=233102
* Remove a left-over reference to make.conf(5) which was used as a place toSergey Kandaurov2012-01-271-2/+1
| | | | | | | | | | store the VM_STACK compile option to enable MAP_STACK support in its earliest stage of development. Found by: mux Notes: svn path=/head/; revision=230613
* Remove sysctl vm.max_proc_mmap used to protect from KVA space exhaustion.Sergey Kandaurov2011-02-241-3/+0
| | | | | | | | | | | | | | | | | As it was pointed out by Alan Cox, that no longer serves its purpose with the modern UMA allocator compared to the old one used in 4.x days. The removal of sysctl eliminates max_proc_mmap type overflow leading to the broken mmap(2) seen with large amount of physical memory on arches with factually unbound KVA space (such as amd64). It was found that slightly less than 256GB of physmem was enough to trigger the overflow. Reviewed by: alc, kib Approved by: avg (mentor) MFC after: 2 months Notes: svn path=/head/; revision=218989
* Add the MAP_PREFAULT_READ option to mmap(2).Alan Cox2010-08-281-1/+14
| | | | | | | Reviewed by: jhb, kib Notes: svn path=/head/; revision=211937
* Reject attempts to create a MAP_ANON mapping with a non-zero offset.John Baldwin2010-03-231-1/+6
| | | | | | | | | PR: kern/71258 Submitted by: Alexander Best MFC after: 2 weeks Notes: svn path=/head/; revision=205536
* Add MAP_ANONYMOUS.Ed Schouten2009-11-061-1/+5
| | | | | | | | | | | Many operating systems also provide MAP_ANONYMOUS. It's not hard to support this ourselves, we'd better add it to make it more likely for applications to work out of the box. Reviewed by: alc (mman.h) Notes: svn path=/head/; revision=198973
* Eliminate a stale paragraph from the BUGS section. This "bug" wasAlan Cox2009-07-261-8/+1
| | | | | | | | | eliminated in r195693. Approved by: re (kensmith) Notes: svn path=/head/; revision=195882
* - Change mmap() to fail requests with EINVAL that pass a length of 0. ThisJohn Baldwin2009-07-141-2/+2
| | | | | | | | | | | | | | | behavior is mandated by POSIX. - Do not fail requests that pass a length greater than SSIZE_MAX (such as > 2GB on 32-bit platforms). The 'len' parameter is actually an unsigned 'size_t' so negative values don't really make sense. Submitted by: Alexander Best alexbestms at math.uni-muenster.de Reviewed by: alc Approved by: re (kib) MFC after: 1 week Notes: svn path=/head/; revision=195693
* Finish what revision 1.40 started. Revision 1.40 removed a false statementAlan Cox2008-10-241-8/+6
| | | | | | | | | | from the description but not the errors section. This revision removes it from the errors statement. Add a statement about the non-portability of non-page-aligned offsets. Notes: svn path=/head/; revision=184226
* Per Regents of the University of Calfornia letter, remove advertisingWarner Losh2007-01-091-4/+0
| | | | | | | | | clause. # If I've done so improperly on a file, please let me know. Notes: svn path=/head/; revision=165903
* Markup fixes.Ruslan Ermilov2006-09-171-1/+2
| | | | Notes: svn path=/head/; revision=162385
* Update for rev 1.205 of vm_mmap.c.Tom Rhodes2006-04-211-7/+6
| | | | | | | Submitted by: fanf Notes: svn path=/head/; revision=157923
* Document that the documented 2GB mmap limit is actually aPeter Wemm2006-03-231-22/+8
| | | | | | | | | | | documentation bug. We switched to page indexes some time around FreeBSD 2.2. The actual 'len' limit is the maximum file size or what will fit in your address space, whichever comes first. It should be possible to make 1TB files on 32 bit systems, but of course address space runs out long before then. Notes: svn path=/head/; revision=157064
* -mdoc sweep.Ruslan Ermilov2005-11-171-2/+5
| | | | Notes: svn path=/head/; revision=152551
* Document the fact that if MAP_FIXED request has been successful itMaxim Sobolev2005-07-151-0/+7
| | | | | | | | | replaces any previous mapping to the same address. Obtained from: IEEE Std 1003.1, 2004 Edition Notes: svn path=/head/; revision=148043
* Mechanically kill hard sentence breaks.Ruslan Ermilov2004-07-021-1/+1
| | | | Notes: svn path=/head/; revision=131504
* Document POSIX stupidity: Attempts to mmap zero bytes will succeed (andColin Percival2004-04-181-0/+7
| | | | | | | have no effect), while attempts to munmap zero bytes will fail. Notes: svn path=/head/; revision=128411
* Spelling: s/then/than/ where appropriate.Ruslan Ermilov2002-12-241-3/+3
| | | | Notes: svn path=/head/; revision=108260
* mdoc(7) police: "The .Fa argument.".Ruslan Ermilov2002-12-191-9/+19
| | | | Notes: svn path=/head/; revision=108087
* mdoc(7) police: Tidy up the syscall language.Ruslan Ermilov2002-12-181-4/+6
| | | | | | | | | | | | | Stop calling system calls "function calls". Use "The .Fn system call" a-la "The .Nm utility". When referring to a non-BSD implementation in the HISTORY section, call syscall a function, to be safe. Notes: svn path=/head/; revision=108028
* Uniformly refer to a file system as "file system".Ruslan Ermilov2002-12-121-5/+5
| | | | | | | Approved by: re Notes: svn path=/head/; revision=107788
* Note that <sys/types.h> in no longer a prerequisite for <utime.h> andMike Barcroft2002-08-241-1/+0
| | | | | | | <sys/mman.h>. Notes: svn path=/head/; revision=102340
* mdoc(7) police: hard sentence breaks, whitespace at EOL, contractions.Ruslan Ermilov2002-03-151-10/+18
| | | | Notes: svn path=/head/; revision=92355
* Don't make it seem like vm.max_proc_mmap only affects MAP_FIXED.Dima Dorfman2002-02-101-4/+4
| | | | | | | | | PR: 34005 Submitted by: Steven Grady <grady@digitaldeck..com>, Hiten Pandya <hitmaster2k@yahoo.com> Notes: svn path=/head/; revision=90482
* The VM_STACK option is long dead. MAP_STACK is available everywhere.Peter Wemm2001-12-211-12/+0
| | | | Notes: svn path=/head/; revision=88351