kvm_mips_map_page(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… kvm_mips_map_page(9) β€” a Kernel API Manual moment

okay bestie so we're diving into kvm_mips_map_page from the Kernel API Manual, and honestly? she's a little workhorse and I'm obsessed. ✨


🌸 NAME 🌸

kvm_mips_map_page β€” maps a guest physical page, no big deal, just casually making guest memory real πŸ’–


πŸŽ€ SYNOPSIS πŸŽ€

int kvm_mips_map_page (struct kvm_vcpu *vcpu , unsigned long gpa , bool
       write_fault , pte_t *out_entry , pte_t *out_buddy );

✨ ARGUMENTS ✨

okay so the arg list, let's go 🫢

  • vcpu β€” the VCPU pointer. literally the main character of this call.
  • gpa β€” guest physical address of the fault. this is the address that had the audacity to fault πŸ™ˆ
  • write_fault β€” a bool telling you whether the fault happened because someone was trying to write.
  • out_entry β€” new PTE for gpa. it gets written on success β€” unless it's NULL, in which case, nothing happens there, and that's valid.
  • out_buddy β€” new PTE for gpa's buddy. also written on success, also skipped if NULL. friendship goals fr fr πŸ’œ

πŸ”₯ DESCRIPTION πŸ”₯

so what she does is handle GPA faults by creating a brand new GPA mapping β€” or updating one that already exists. both, either, she's flexible like that. πŸ’…

she's also the one taking care of marking pages young or dirty (that's idle/dirty page tracking, iykyk), asking KVM for the corresponding PFN, and creating the mapping inside the GPA page tables. all that? her job. ⭐

✨ important vibe check: derived mappings (like GVA page tables and TLBs) are not her problem. those must be handled by the caller. don't put that on her πŸŽ€

🌈 RETURN 🌈

  • 0 β€” success!! πŸŽ‰ and when it's 0, the caller is free to use the out_entry and out_buddy PTEs to update derived mappings and resume guest execution. slay.
  • -EFAULT β€” this happens if there's no memory region at gpa, or if someone tried to write to a read-only memory region 😭 and ngl this one is usually handled as an MMIO access.

πŸ¦‹ SEE ALSO πŸ¦‹

the kernel file is ./arch/mips/kvm/mmu.c bestie, and here's the whole friend group:


and that's the page!! source/version lives at ./arch/mips/kvm, dated October 2026, and the page itself is kvm_mips_map_page(9) β€” go forth and map some guest physical pages, ily, bye πŸ’–βœ¨πŸŽ€

πŸ“¦ where this page comes from