Question

I'm a bit confused about the addresses that kmalloc is returning to me. According to the virtual memory map, the addresses I'm getting are in the ffff880000000000 - ffffc7ffffffffff range, so the "direct mapping of all phys. memory". How does this mapping work? I'm pretty certain that kmalloc doesn't simply return a physical address.

Was it helpful?

Solution

You're right, kmalloc is returning a virtual address, not a physical one. The memory map you linked to is describing the virtual memory map, not the physical memory map.

A virtual address typically is translated to a physical address by the MMU when you access data at the address. What the virtual address translates to depends on the memory map specified by the kernel.

The memory map you linked to shows how Linux does the mapping. It is saying, if you have a virtual address between 0xffff880000000000 and 0xffffc7ffffffffff, it is mapped to somewhere in physical memory (we don't know where exactly nor do we care unless we're doing DMA).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top