cond_install_uffd_wp_ptes(9)
π cond_install_uffd_wp_ptes(9) β kernel API manual energy β¨
okay so bestie, today's main character is cond_install_uffd_wp_ptes, straight out of the Kernel API Manual. she's a little niche, she's a little spicy, but she's doing very important page-table work and we're gonna stan π«Ά
πΈ NAME πΈ
cond_install_uffd_wp_ptes β installs uffd-wp markers after the PTEs have already been cleared. no cap, that ordering is the whole point π
π SYNOPSIS π
bool cond_install_uffd_wp_ptes (struct vm_area_struct *vma , unsigned
long addr , pte_t *ptep , pte_t pte , unsigned long nr_ptes );
that's the whole signature, copy it exactly, don't be weird about it π
β¨ ARGUMENTS β¨
vmaβ the VMA that the pages are mapped into. it's giving "the neighborhood these pages live in" π‘addrβ the address where the first page of this batch is mapped. like the street number for entry one πΊοΈptepβ the page table pointer for the first entry of this batch. your starting point fr fr πpteβ the old value of the entry thatpteppoints at. vintage, pre-loved, previous owner energy πnr_ptesβ how many entries we're installing. the batch size, the headcount, the "how many of these are we doing" number π’
π DESCRIPTION π
so here's the vibe: if the PTEs got write-protected by uffd-wp in any form, we arm special PTEs to replace none PTEs. it's giving glow-up, but make it page tables β¨
β οΈ NOTE! this should only be called when the PTEs are already cleared, so we never accidentally replace something valuable. like, ever. we do not touch the precious cargo π
meanwhile, none PTEs also mean we are not demoting the PTEs, so a TLB flush is not needed. e.g., when the PTEs were cleared, the caller should have already taken care of the TLB flush. that's the caller's job bestie, not ours π
it must be called with the page table lock held, so that no thread will see the none PTEs β and if they do see them, they'll fault and serialize at the page table lock. everyone gets in line, single file, no cutting π¦
returns true if uffd-wp PTEs were installed, and false otherwise. simple as that, slay π
π¦ SEE ALSO π¦
kernel file ./mm/memory.c β and the whole friend group:
free_pgd_range(9), free_pgtables(9), __vm_normal_page(9), vm_normal_page(9), vm_normal_folio(9), vm_normal_page_pmd(9), vm_normal_folio_pmd(9), vm_normal_page_pud(9), restore_exclusive_pte(9), zap_vma_for_reaping(9), unmap_vmas(9), zap_vma_range_batched(9), zap_vma_range(9), zap_special_vma_range(9), vm_insert_pages(9), vm_insert_page(9), vm_map_pages(9), vm_map_pages_zero(9), vmf_insert_pfn_prot(9), vmf_insert_pfn(9), remap_pfn_range(9), vm_iomap_memory(9), __vmf_anon_prepare(9), finish_mkwrite_fault(9), unmap_mapping_folio(9), unmap_mapping_pages(9), unmap_mapping_range(9), set_pte_range(9), finish_fault(9), mm_account_fault(9), follow_pfnmap_start(9), follow_pfnmap_end(9), generic_access_phys(9), access_remote_vm(9), copy_remote_vm_str(9), folio_zero_user(9)
like, that's the entire group chat, all tagged, no one left on read π
and that's the page!! π«Ά this one lives in ./mm, dated October 2026, and it's cond_install_uffd_wp_ptes(9) β go forth and install those markers responsibly, bestie π
π¦ where this page comes from
- nixpkgs unstable: linux-manual 7.3.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms