get_vaddr_frames(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… get_vaddr_frames(9) β€” like, the whole kernel API manual energy, bestie

okay so welcome to the glow-up of get_vaddr_frames, straight from your fave Kernel API Manual ✨ this one's a function page, so grab a strawberry drink πŸ“ and let's get into it.


πŸŽ€ NAME πŸŽ€

get_vaddr_frames β€” maps virtual addresses to pfns. that's it, that's the vibe πŸ¦‹


✨ SYNOPSIS ✨

int get_vaddr_frames (unsigned long start , unsigned int nr_frames ,
                      bool write , struct frame_vector *vec );

literally the whole signature, no cap πŸ’…


🌸 ARGUMENTS 🌸

  • start β€” the starting user address. like, where the whole thing begins πŸ‘‘
  • nr_frames β€” number of pages / pfns from start to map. the count, the amount, the quantity 🧚
  • write β€” the mapped address has write permission. yes, it's a bool, yes it's important πŸ”₯
  • vec β€” the struct frame_vector that receives the pages / pfns of the addresses mapped. it should have space for at least nr_frames entries, so pls size it right bestie πŸ™ˆ

πŸ¦‹ DESCRIPTION πŸ¦‹

so what does this icon actually do? it maps virtual addresses starting from start and fills the vec structure with page frame numbers or page pointers to the corresponding pages β€” the choice depends on the type of the vma underlying the virtual address πŸ‘€

here's the tea, split by case:

  • if start belongs to a normal vma, the function grabs a reference to each of the pages to pin them in memory πŸ“Œ
  • if start belongs to a VM_IO | VM_PFNMAP vma, we don't touch page structures and the caller must make sure pfns aren't reused for anything else while he is using them β€” that's on you, fr fr, this is the important warning part πŸ’€

the function returns the number of pages mapped, which may be less than nr_frames. in particular it stops mapping if there are more vmas of different type underlying the specified range of virtual addresses. and when the function isn't able to map a single page, it returns an error 😭

note that get_vaddr_frames cannot follow VM_IO mappings. it used to be able to do that, but that could (racily) return non-refcounted pfns. so like... we don't do that anymore, and honestly good for us πŸ’…

also this function takes care of grabbing mmap_lock as necessary β€” no need to do it yourself, she handles it 🫢


πŸ’œ SEE ALSO πŸ’œ

go read those too, iykyk 🌈


and that's the page, bestie πŸ’– sign-off time: this lil masterpiece lives in ./drivers/media/common/videobuf2, dated October 2026 β€” and honestly? iconic. periodt. 🌟

πŸ“¦ where this page comes from