vmap_pages_range(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’– vmap_pages_range(9) β€” from the Kernel API Manual, bestie πŸ’–

okay so you're in the vmap_pages_range section of the Kernel API Manual and honestly? this one is a little baddie. it maps pages into a kernel virtual address. that's it, that's the whole personality. let's get into it 🫢


✨ NAME ✨

vmap_pages_range β€” map pages to a kernel virtual address

like literally, it puts your pages somewhere in kernel virtual address space. iconic behaviour, no notes πŸ’…


🌸 SYNOPSIS 🌸

int vmap_pages_range (unsigned long addr , unsigned long end , pgprot_t
prot , struct page **pages , unsigned int page_shift );

she returns an int, she takes five arguments, she does not elaborate further. main character energy fr fr ⭐


πŸŽ€ ARGUMENTS πŸŽ€

okay so the five things you're handing her:

  • addr β€” start of the VM area to map πŸ’œ where the mapping begins, bestie.
  • end β€” end of the VM area to map, and heads up, it's non-inclusive, so like, don't expect end itself to be in on the party πŸ™ˆ
  • prot β€” page protection flags to use. the whole vibe of the mapping, permission-wise πŸ¦‹
  • pages β€” the pages to map, and note that these are always PAGE_SIZE pages. always. no cap πŸ”₯
  • page_shift β€” the maximum shift the pages may be mapped with, and ngl this one has a whole situation attached: the pages must be aligned and contiguous up to at least this shift ⚠️ that's not a suggestion, that's the requirement.

πŸ‘‘ RETURN πŸ‘‘

  • 0 on success βœ…
  • -errno on failure 😭

that's the whole return situation. slay, consistent, predictable.


🌈 SEE ALSO 🌈

bestie there are so many friends in this orbit, buckle up 🧚 β€” Kernel file ./mm/vmalloc.c, plus:


πŸ’– bestie reminder: page_shift is not decorative β€” your pages need to be aligned and contiguous up to at least that shift. do not come for her with a raggedy page array, she will simply return -errno. 🫢

and that's the page!! brought to you by ./mm, the October 2026 edition of the Kernel API Manual, filed under vmap_pages_range(9) β€” mwah, go map some pages, you absolute legend πŸ’…βœ¨πŸ“

πŸ“¦ where this page comes from