kvm_pgtable_...e2_wrprotect(9)
π
kvm_pgtable_...e2_wrprotect(9) β from the Kernel API Manual β¨
okay so bestie, welcome to the glow-up page for kvm_pgtable_stage2_wrprotect, straight out of the Kernel API Manual. she's a little function with big main-character energy and she's about to make your guest memory read-only π₯
πΈ NAME πΈ
kvm_pgtable_stage2_wrprotect β write-protect a guest stage-2 address range without TLB invalidation. yeah. no flush. that part is on you, we'll get there π«Ά
β¨ SYNOPSIS β¨
int kvm_pgtable_stage2_wrprotect (struct kvm_pgtable *pgt , u64 addr ,
u64 size );
that's the whole mood. three args, one int back. slay π
π ARGUMENTS π
pgtβ the page-table structure, and it's gotta be initialised bykvm_pgtable_stage2_init*(). no half-baked structs in this house πaddrβ the intermediate physical address where the write-protecting starts,sizeβ the size of the range. just the size. the range's size. iykyk β¨
π¦ DESCRIPTION π¦
so here's the tea β β the offset of addr within a page is ignored, like literally does not matter at all, and size gets rounded-up to the next page boundary. so if you're sitting in the middle of a page thinking you're special? you're not, bestie, the whole page is getting the treatment π
β οΈ the actual important bit: it is the caller's responsibility to invalidate the TLB after calling this function, so the updated permissions are actually visible to the CPUs. she does the page tables, you do the TLB. split the chores. no cap π
like, this function will not flush anything for you. zero. none. if you forget, your CPUs are out here living in the past with stale permissions and that is not the vibe π
β RETURN β
0on success π- a negative error code on failure π
π SEE ALSO π
first up, the kernel file itself: ./arch/arm64/include/asm/kvm_pgtable.h π
and then the whole friend group, in order, because we don't skip anyone in this group chat:
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_annotate(9)kvm_pgtable_stage2_unmap(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)
thirty links. thirty. we ate and left zero crumbs π
and that's the page, bestie π§ the source lives over at ./arch/arm64/include/asm and it's dated October 2026 β so yeah, that's the version, that's the date, and if you forget the TLB flush i will be in your replies π byeee π
β¨
π¦ 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