kvm_init_stage2_mmu(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’– 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 the KVM structure πŸ’œ
  • 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_mmu structures are initialised for NV guests, and the caller must hold kvm->lock as 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:

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