kvm_pgtable_stage2_annotate(9)
π kvm_pgtable_stage2_annotate(9) π
okay so bestie, welcome to the Kernel API Manual, section 9 β this is the <pink>kvm_pgtable_stage2_annotate</pink> girlie and she's here to help you claim what's yours in the IPA space π
β¨ NAME β¨
kvm_pgtable_stage2_annotate β unmap and annotate pages in the IPA space so you can track ownership (and honestly, so much more). π
π¦ SYNOPSIS π¦
int kvm_pgtable_stage2_annotate (struct kvm_pgtable *pgt , u64 addr ,
u64 size , void *mc , enum kvm_invalid_pte_type type , kvm_pte_t
annotation );
literally the whole signature, no cap. π
πΈ ARGUMENTS πΈ
pgtβ the page-table struct, and it must have been initialised bykvm_pgtable_stage2_init*()first. no shortcuts babe, she needs her setup πaddrβ base intermediate physical address you're annotating. where the magic starts. β¨sizeβ how big the annotated range is, i.e. how much of the IPA space is getting the treatment. πmcβ the cache of pre-allocated, already-zeroed memory that page-table pages get allocated from. it's giving prepared queen π§typeβ the type of the annotation; this is the whole personality of it, since it determines its meaning and its format. πannotationβ a 59-bit value that gets stored in the page tables. lowkey crucial details:annotation[0]andannotation[63:60]must be 0, andannotation[59:1]is what's actually stored in the page tables, along withtype. π«Ά
fr fr,annotation[0]andannotation[63:60]must be 0 β don't try to be cute and sneak bits in there. π
π DESCRIPTION π
so by default, all page-tables are owned by identifier 0. like, everyone starts out as ID zero, that's just the vibe. π
this function is how you branch out: you can use it to mark portions of the IPA space as owned by other entities. main character energy for everyone involved π
and here's the slay part β when a stage 2 is used with identity-mappings, these annotations let you use the page-table data structure as a simple rmap. iconic honestly. π₯
β RETURN β
0on success π- a negative error code on failure π
π SEE ALSO π
start with the kernel file itself: ./arch/arm64/include/asm/kvm_pgtable.h β go read the source bestie, it ate π
then the whole friend group, all present and accounted for:
struct kvm_pgtable_mm_ops(9)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_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)
okay that's the whole page!! π«Ά this one ships out from ./arch/arm64/include/asm, dated October 2026, and it's kvm_pgtable_stage2_annotate(9) signing off from the Kernel API Manual. mwah π go annotate something, you've got this β¨ππ¦
π¦ 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