STRUCT KVM_PGTABLE_MM_OPS(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

🌸 struct kvm_pgtable_mm_ops(9) 🌸

okay so bestie, welcome to the Kernel API Manual πŸ’– this one's a struct page, and it's basically the plug-in pack of memory-management callbacks that the KVM pagetable code calls into whenever it needs a page, a refcount, or a cache flush. Think of it as the group chat between the pgtable walker and whatever allocator you're using. iykyk 🫢


✨ NAME ✨

struct kvm_pgtable_mm_ops β€” Memory management callbacks. literally what it says on the tin, no cap πŸ’…


πŸŽ€ SYNOPSIS πŸŽ€

struct kvm_pgtable_mm_ops {
    void* (*zalloc_page)(void *arg);
    void* (*zalloc_pages_exact)(size_t size);
    void (*free_pages_exact)(void *addr, size_t size);
    void (*free_unlinked_table)(void *addr, s8 level);
    void (*get_page)(void *addr);
    void (*put_page)(void *addr);
    int (*page_count)(void *addr);
    void* (*phys_to_virt)(phys_addr_t phys);
    phys_addr_t (*virt_to_phys)(void *addr);
    void (*dcache_clean_inval_poc)(void *addr, size_t size);
    void (*icache_inval_pou)(void *addr, size_t size);
 };

like, that's the whole vibe right there ⭐


πŸ¦‹ Members πŸ¦‹

okay bestie, member-by-member, let's go πŸ”₯

  • zalloc_page β€” Allocate a single zeroed memory page ✨ The arg parameter can be used by the walker to pass a memcache πŸ‘€ The initial refcount of the page is 1.
  • zalloc_pages_exact β€” Allocate an exact number of zeroed memory pages πŸŽ€ The size parameter is in bytes, and is rounded up to the next page boundary. The resulting allocation is physically contiguous β€” yes, physically, she's that girl πŸ’…
  • free_pages_exact β€” Free an exact number of memory pages previously allocated by zalloc_pages_exact 🫢 (it's giving "clean up after yourself", we love a responsible icon)
  • free_unlinked_table β€” Free an unlinked paging structure by unlinking and dropping references 🌈
  • get_page β€” Increment the refcount on a page ⬆️
  • put_page β€” Decrement the refcount on a page ⬇️ When the refcount reaches 0 the page is automatically freed. she's gone, periodt πŸ’€
  • page_count β€” Return the refcount of a page πŸ”’
  • phys_to_virt β€” Convert a physical address into a virtual address mapped in the current context 🧚
  • virt_to_phys β€” Convert a virtual address mapped in the current context into a physical address πŸ¦‹ (yes she's the reverse of the one above, they're a matching set)
  • dcache_clean_inval_poc β€” Clean and invalidate the data cache to the PoC for the specified memory address range 🧼✨
  • icache_inval_pou β€” Invalidate the instruction cache to the PoU for the specified memory address range 🧹✨

πŸ’œ SEE ALSO πŸ’œ

Kernel file ./arch/arm64/include/asm/kvm_pgtable.h enum kvm_pgtable_stage2_flags(9), enum kvm_pgtable_prot(9), enum kvm_pgtable_walk_flags(9), struct kvm_pgtable_walker(9), struct kvm_pgtable(9), kvm_pgtable_hyp_init(9), kvm_pgtable_hyp_destroy(9), kvm_pgtable_hyp_map(9), kvm_pgtable_hyp_unmap(9), kvm_get_vtcr(9), kvm_pgtable_stage2_pgd_size(9), __kvm_pgtable_stage2_init(9), kvm_pgtable_stage2_destroy(9), kvm_pgtable_stage2_destroy_range(9), kvm_pgtable_stage2_destroy_pgd(9), kvm_pgtable_stage2_free_unlinked(9), kvm_pgtable_stage2_create_unlinked(9), kvm_pgtable_stage2_map(9), kvm_pgtable_stage2_annotate(9), kvm_pgtable_stage2_unmap(9), kvm_pgtable_stage2_wrprotect(9), kvm_pgtable_stage2_mkyoung(9), kvm_pgtable_stage2_test_clear_young(9), kvm_pgtable_stage2_relax_perms(9), kvm_pgtable_stage2_split(9), kvm_pgtable_walk(9), kvm_pgtable_get_leaf(9), kvm_pgtable_stage2_pte_prot(9), kvm_pgtable_hyp_pte_prot(9), kvm_tlb_flush_vmid_range(9)

like, that's a whole friend group right there, go read them all bestie, i believe in you πŸ˜­πŸ’–


and that's the page!! πŸŽ€ this little love letter lives in ./arch/arm64/include/asm, dropped in October 2026, and it's filed under struct kvm_pgtable_mm_ops(9) in the Kernel API Manual β€” mwah, slay, go allocate some pages responsibly πŸ’…βœ¨

πŸ“¦ where this page comes from