memremap(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

✨ memremap β€” the kernel API manual, but make it make sense ✨

okay so this is memremap(9) from the Kernel API Manual, and honestly bestie, if you've ever been like "hmm I need to map an iomem_resource but as cacheable memory," this is literally your girl πŸ’…


πŸ’– NAME πŸ’–

memremap β€” remap an iomem_resource as cacheable memory πŸŽ€


πŸ¦‹ SYNOPSIS πŸ¦‹

void * memremap (resource_size_t offset , size_t size , unsigned long
flags );

like, that's the whole vibe. three args, one pointer out. slay.


🌸 ARGUMENTS 🌸

  • offset β€” the start address of the iomem resource. where the mapping begins, bestie πŸ“
  • size β€” how big the remap is. the size of it. yep 🫢
  • flags β€” any of MEMREMAP_WB, MEMREMAP_WT, MEMREMAP_WC, MEMREMAP_ENC, MEMREMAP_DEC 🚩

πŸ’œ DESCRIPTION πŸ’œ

so memremap is basically ioremap for the cases where you already know the resource you're mapping doesn't have i/o side effects, and the __iomem annotation just isn't applicable. it's the chill, no-drama version 😌✨

and here's the tea about multiple flags: if you pass more than one, the different mapping types get attempted in the order listed below until one of them succeeds. first come, first served, periodt πŸ”₯

🧚 the flags, one by one 🧚

  • MEMREMAP_WB β€” matches the default mapping for System RAM on the architecture, and that's usually a read-allocate write-back cache. AND, key detail: if MEMREMAP_WB is specified and the requested remap region is RAM, memremap will bypass establishing a new mapping and instead just return a pointer into the direct map. no new mapping, no problem πŸ’«
  • MEMREMAP_WT β€” establishes a mapping where writes either bypass the cache or are written through to memory, and never exist in a cache-dirty state with respect to program visibility. very "clean hands" of it honestly. ⚠️ but attempts to map System RAM with this mapping type will fail. no cap.
  • MEMREMAP_WC β€” establishes a writecombine mapping, where writes may be coalesced together (e.g. in the CPU's write buffers), but is otherwise uncached. also ⚠️ attempts to map System RAM with this mapping type will fail. it's giving picky, and we respect it.
lowkey important: MEMREMAP_ENC and MEMREMAP_DEC are listed up in the flags, but the description only breaks down the three above. don't come for me, I'm just telling you what the page says πŸ™ˆ

🌈 SEE ALSO 🌈

  • Kernel file ./kernel/iomem.c β€” go read it, it's right there πŸ‘‘

and that's the whole page, bestie! no notes, go map something cacheable πŸ¦‹βœ¨

this lil masterpiece came from the ./kernel source, dated October 2026 β€” mwah, sending you love from the Kernel API Manual πŸ’–πŸŽ€πŸ«Ά

πŸ“¦ where this page comes from