PMAP_ENTER(9)
π PMAP_ENTER π
okay so this is the pmap_enter(9) page from the Kernel Developer's Manual β yes bestie, we're in kernel land now, grab your iced coffee π§β
β¨ NAME β¨
pmap_enter β insert a virtual page into a physical map πΊοΈβ¨
π¦ SYNOPSIS π¦
#include <sys/param.h>
#include <vm/vm.h>
#include <vm/pmap.h>
int
pmap_enter(pmap_t pmap, vm_offset_t va, vm_page_t m, vm_prot_t prot,
u_int flags, int8_t psind);
like, copy that exactly, no cap π
π DESCRIPTION π
The pmap_enter() function creates a mapping in the physical map pmap from the virtual address va to the physical page m with the protection prot. and listen β any previous mapping at the virtual address va? destroyed. gone. not invited to the group chat anymore π
The flags argument may have the following values:
VM_PROT_READβ a read access to the given virtual address triggered the call πVM_PROT_WRITEβ a write access to the given virtual address triggered the call βοΈVM_PROT_EXECUTEβ an execute access to the given virtual address triggered the call πββοΈPMAP_ENTER_WIREDβ the mapping should be marked as wired πPMAP_ENTER_NOSLEEPβ this function may not sleep during creation of the mapping π΄π« if the mapping cannot be created without sleeping, an appropriate Mach VM error is returned.
If the PMAP_ENTER_NOSLEEP flag is not specified, this function must create the requested mapping before returning. It may not fail. periodt. and to create that requested mapping, this function may destroy any non-wired mapping in any pmap π iconic but terrifying
The psind parameter specifies the page size that should be used by the mapping. The supported page sizes are described by the global array pagesizes[]. The desired page size is specified by passing the index of the array element that equals the desired page size πβ¨
When the pmap_enter() function destroys or updates a managed mapping β including an existing mapping at virtual address va β it updates the vm_page structure corresponding to the previously mapped physical page. If the physical page was accessed through the managed mapping, then the vm_page structure's PGA_REFERENCED aflag is set π·οΈ. If the physical page was modified through the managed mapping, then the vm_page_dirty() function is called on the vm_page structure π§Ό
The PGA_WRITEABLE aflag must be set for the page m if the new mapping is managed and writeable. It is advised to clear PGA_WRITEABLE for destroyed mappings if the implementation can ensure that no other writeable managed mappings for the previously mapped pages exist π
If the request modifies an existing mapping to use a different physical page, an implementation of pmap_enter must invalidate the previous mapping before installing the new one. This ensures that all threads sharing the pmap keep a consistent view of the mapping, which is necessary for the correct handling of CoW (copy on write) faults ππ lowkey the most important part, fr fr
If the page m is managed, the page must be busied by the caller or the owning object must be locked. In the later case, the PMAP_ENTER_NOSLEEP must be specified by the caller π
The pmap_enter() function must handle the multiprocessor TLB consistency for the given address π§ β¨
πΈ NOTES πΈ
On arm and i386 architectures the existing implementation of the pmap_enter function is incomplete β only value 0 for psind is supported π« Other supported architectures, except amd64, have a pagesizes[] array of size 1.
not me finding out arm and i386 are out here with only 0 for psind π we love an incomplete implementation tho
π RETURN VALUES π
- If successful, the
pmap_enter()function returnsKERN_SUCCESSβ slay - If the
PMAP_ENTER_NOSLEEPflag was specified and the resources required for the mapping cannot be acquired without sleeping,KERN_RESOURCE_SHORTAGEis returned ππΈ
β SEE ALSO β
π AUTHORS π
This manual page was first written by Bruce M Simpson <bms@spc.org> and then rewritten by Alan Cox <alc@FreeBSD.org> and Konstantin Belousov <kib@FreeBSD.org>. absolute legends, all three of them π«Άβ¨
and that's the whole page bestie π this Debian edition dropped December 16, 2018 β yeah it's giving vintage but it still ate π₯ mwah ππ
π¦ where this page comes from
- freebsd 14.5: base 14.5
- freebsd 15.1: base 15.1
- nixpkgs unstable: source
- Copyright (c) 2003 Bruce M Simpson <bms@spc.org>
- Copyright (c) 2014 The FreeBSD Foundation
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms