kvm_mmu_wp_memory_region(9)
π kvm_mmu_wp_memory_region(9) β from the Kernel API Manual, bestie π
okay so real quick, before we dive in: this is a page from the Kernel API Manual, and the function we're stanning today is kvm_mmu_wp_memory_region. yes it's a mouthful. yes it's iconic. let's get into it β¨
πΈ NAME πΈ
kvm_mmu_wp_memory_region β write protect stage 2 entries for memory slot
like, it goes in and write-protects the stage 2 entries for a memory slot. that's the whole vibe. no cap π«Ά
β¨ SYNOPSIS β¨
void kvm_mmu_wp_memory_region (struct kvm *kvm , int slot );
that's it. that's the whole signature. short, sweet, ate π
π¦ ARGUMENTS π¦
kvmβ the KVM pointer. you know the one. the main character pointer πslotβ the memory slot you want to write protect. literally the one getting protected π‘οΈ
π DESCRIPTION π
so here's the tea, bestie π΅ β you call this one to start logging dirty pages, and it happens right after the memory region KVM_MEM_LOG_DIRTY_PAGES operation is called. that's the trigger, okay? that's the moment. β
and after this function returns? every single present PUD, PMD and PTE is now write protected in the memory region. all of them. the whole set. not me being obsessed with page table levels but here we are ππ₯
once that's done, you can go ahead and read the dirty page log. it's giving "hand-off complete", it's giving "you may now proceed" π
π«Ά heads up: this function acquireskvm_mmu_lock. and it's called with thekvm->slots_lockmutex already acquired, which serializes operations for VM memory regions. so yes, the locking is very much on purpose, don't come for it π
π SEE ALSO π
the kernel file lives at ./arch/arm64/kvm/mmu.c β go say hi π§ and honestly the whole friend group is here, so let me introduce you:
kvm_arch_flush_remote_tlbs(9)__unmap_stage2_range(9)stage2_flush_vm(9)free_hyp_pgds(9)create_hyp_mappings(9)hyp_alloc_private_va_range(9)create_hyp_io_mappings(9)create_hyp_exec_mappings(9)kvm_init_stage2_mmu(9)stage2_unmap_vm(9)kvm_phys_addr_ioremap(9)kvm_stage2_wp_range(9)kvm_mmu_split_memory_region(9)kvm_handle_guest_abort(9)
every single one of them. no skips. we read the whole syllabus πβ¨
and that's the page!! mwah π this one's sourced from ./arch/arm64/kvm, dated October 2026, and it's kvm_mmu_wp_memory_region(9) forever and always ππ go protect some entries, bestie β 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