Kernel Virtual Memory – Inside 64-bit Linux Processes

64bitkernelmemoryprocessvirtual-memory

I came upon this question :

What's the use of having a kernel part in the virtual memory space of Linux processes?

and based on the answer and the comments on the answer :

the kernel memory map includes a direct mapping of all physical memory, so everything in memory appears there; it also includes separate mappings for the kernel, modules etc., so the physical addresses containing the kernel appear in at least two different mappings

Is this true? I couldn't find any source or reference for this, and why would it include a map of the entire physical memory and then again have a separate mapping of kernel modules? Isn't that redundant?

Can someone explain in a simple manner what is inside the kernel part of virtual memory of processes in 64-bit Linux? and please provide a source for the answer! because I couldn't find anything related to this in any book or paper.

Best Answer

The kernel’s memory map on x86-64 is documented in the kernel itself. The kernel maps

  • user-space (for the current process)
  • PTI data structures
  • all the physical memory
  • the kernel’s data structures, in various blocks, with holes for ASLR
  • the kernel itself
  • its modules

Having a full mapping of physical memory is convenient, but its relevance is debated compared to the security risks it creates, and its address-space burden (since physical memory is effectively limited to half the address space as a result; this prompted the recent expansion to five-level page tables with 56-bit addresses).

Related Question