cond_install_uffd_wp_ptes(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… 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 that ptep points 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