kvm_init_stage2_mmu(9)
π kvm_init_stage2_mmu(9) π
okay so bestie, buckle up β this is a page from the Kernel API Manual, and honestly? it's kind of a baddie. it's all about setting up a stage-2 MMU structure and it's lowkey iconic. let's get into it β¨
β¨ NAME β¨
kvm_init_stage2_mmu β Initialise a S2 MMU structure π
πΈ SYNOPSIS πΈ
int kvm_init_stage2_mmu (struct kvm *kvm , struct kvm_s2_mmu *mmu ,
unsigned long type );
like, that's the whole signature. no cap, that's it. π«Ά
π¦ ARGUMENTS π¦
kvmβ The pointer to theKVMstructure πmmuβ The pointer to the s2 MMU structure πtypeβ The machine type of the virtual machine π
three args, all vibes, all business. periodt. π
π₯ DESCRIPTION π₯
so what does it actually do? it Allocates only the stage-2 HW PGD level table(s). that's it. that's the whole job. no extra credit, no overachieving β just the PGD level tables, thank you very much. π
and here's the tea: Note we don't need locking here as this is only called in two cases:
- when the VM is created, which can't race against anything π§ (fr fr, nothing to race with, it's brand new)
- when secondary
kvm_s2_mmustructures are initialised for NV guests, and the caller must holdkvm->lockas this is called on a per-vcpu basis π
so likeβ¦ no lock inside the function, but if you're that second caller, the lock is your responsibility, bestie. don't come crying to me if you skip it π
π SEE ALSO π
the whole friend group, honestly β they all show up together:
- Kernel file
./arch/arm64/kvm/mmu.c 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)stage2_unmap_vm(9)kvm_phys_addr_ioremap(9)kvm_stage2_wp_range(9)kvm_mmu_wp_memory_region(9)kvm_mmu_split_memory_region(9)kvm_handle_guest_abort(9)
iykyk π
aaaand that's the page! πΈ this lil guy lives in ./arch/arm64/kvm, and the version we're looking at is dated October 2026. go forth and initialise those stage-2 MMU structures, main character. you 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