VM_MAP_LOOKUP(9)
π VM_MAP_LOOKUP(9) π
okay bestie, welcome to the Kernel Developer's Manual page for vm_map_lookup and vm_map_lookup_done β the little duo that helps you look up the vm_object backing a given virtual region. itβs giving kernel-internals main character energy, and weβre gonna get through it together π«Άβ¨
π NAME π
vm_map_lookup, vm_map_lookup_done β lookup the vm_object backing a given virtual region π
β¨ SYNOPSIS β¨
#include <sys/param.h>
#include <vm/vm.h>
#include <vm/vm_map.h>
int
vm_map_lookup(vm_map_t *var_map, vm_offset_t vaddr,
vm_prot_t fault_type, vm_map_entry_t *out_entry,
vm_object_t *object, vm_pindex_t *pindex, vm_prot_t *out_prot,
boolean_t *wired);
void
vm_map_lookup_done(vm_map_t map, vm_map_entry_t entry);
no cap, those includes and signatures are literally copy-pasted from the source of truth, so keep them exactly like that π₯
πΈ DESCRIPTION πΈ
so vm_map_lookup() is the function that attempts to find the vm_object, page index and protection for the given virtual address vaddr, in the map var_map β assuming a page fault of the type fault_type had occurred. itβs basically doing the βwhatβs behind this virtual address?β detective work ππ
and this part is important, bestie: the return values are guaranteed until vm_map_lookup_done() is called to release the lock. so donβt go acting brand new and forget the cleanup, okay? πβ¨
π¦ IMPLEMENTATION NOTES π¦
not me spilling the lock tea: vm_map_lookup() acquires a read-lock on the map *var_map, but it does not release it. the caller should invoke vm_map_lookup_done() in order to release this lock. thatβs the whole vibe β lookup first, then done to release the lock, periodt π«Άπ
π RETURN VALUES π
the vm_map_lookup() function returns KERN_SUCCESS, and sets the *object, *pindex, *out_prot, and *out_entry arguments appropriately for the hypothetical page fault. slay, thatβs the success path β¨π
π SEE ALSO π
go read that one too, iykyk ππ
π AUTHORS π
this manual page was written by Bruce M Simpson <bms@spc.org>. iconic behavior, honestly π
β¨
this cutie comes from the Debian manual pages, dated July 19, 2003 β mwah, xoxo ππ
π¦ 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>
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms