kvm_pgtable_stage2_map(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’– NAME πŸ’–

okay so bestie, this is kvm_pgtable_stage2_map(9) from the Kernel API Manual, and the name is literally the assignment: kvm_pgtable_stage2_map β€” install a mapping in a guest stage-2 page-table. main character page-table energy ✨

✨ SYNOPSIS ✨

int kvm_pgtable_stage2_map (struct kvm_pgtable *pgt , u64 addr , u64
size , u64 phys , enum kvm_pgtable_prot prot , void *mc , enum
kvm_pgtable_walk_flags flags );

πŸŽ€ ARGUMENTS πŸŽ€

  • pgt β€” page-table structure initialised by kvm_pgtable_stage2_init*(). gotta be initialised first, bestie.
  • addr β€” intermediate physical address at which to place the mapping.
  • size β€” size of the mapping.
  • phys β€” physical address of the memory to map.
  • prot β€” permissions and attributes for the mapping.
  • mc β€” cache of pre-allocated and zeroed memory from which to allocate page-table pages.
  • flags β€” flags to control the page-table walk (ex. a shared walk). shared walk? noted.

πŸ¦‹ DESCRIPTION πŸ¦‹

The offset of addr within a page is ignored, size is rounded-up to the next page boundary, and phys is rounded-down to the previous page boundary. page math lowkey said what it said, periodt πŸ’…

If device attributes are not explicitly requested in prot, then the mapping will be normal, cacheable. normal + cacheable, iykyk.

Note that the update of a valid leaf PTE in this function will be aborted, if it's trying to recreate the exact same mapping or only change the access permissions. Instead, the vCPU will exit one more time from guest if still needed and then go through the path of relaxing permissions. so that update gets aborted β€” fr fr, no cap.

Note that this function will both coalesce existing table entries and split existing block mappings, relying on page-faults to fault back areas outside of the new mapping lazily. coalesce + split, lazy fault-back, iconic behaviour 😭

🌸 RETURN 🌸

0 on success, negative error code on failure. slay when it's zero, sad little negative when it's not.

πŸ’… SEE ALSO πŸ’…

Kernel file ./arch/arm64/include/asm/kvm_pgtable.h β€” plus the whole friend group:


and that's the vibe check, bestie 🫢 source path on the footer is ./arch/arm64/include/asm, date is October 2026, and the manual is kvm_pgtable_stage2_map(9) β€” mwah πŸ’‹

πŸ“¦ where this page comes from