kvm_pgtable_...e2_wrprotect(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… 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 by kvm_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 ⭐

  • 0 on 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:

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