How is kernel virtual memory mapped to physical memory

linux, linux-kernel, memory-management

Solution

Here's a partial answer, maybe it will help.

Linux divides the kernel virtual address space to two parts - lowmem and vmalloc.

Lowmem uses a 1-1 mapping between virtual and physical addresses. I.e. virtual address X is mapped to physical address X-C (where C is some constant, e.g. 3GB). This mapping is built during boot, and is never changed.

Vmalloc uses a dynamic mapping, on demand. On each allocation, a bunch of physical pages are found, and a virtual address range, and the paging tables are modified to create the mapping.

Two two are separated by virtual addresses. Different virtual address ranges are used by each. The lowmem range is always mapped, the vmalloc range is mapped when allocated.

Problem

How do I find out the memory mappings for kernel space? VA -> PA I'm aware of the `proc` file system `/proc/pid/maps` & `/proc/pid/mappings` which gives us the mappings of user space applications. Anything similar to find kernel space mappings? Thanks!

Original source