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!
To map virtual memory addresses to physical memory addresses, page tables are used. A page table consists of numerous page table entries (PTE). One memory page in a PTE contains data structures consisting of different sizes of 'words'.
The physical memory can only be directly accessed in kernel-mode debugging.
In physical memory the kernel usually resides at a random offset above 0x1000000 .
Another important reason why we say kernel is in the process address space is that kernel can access the user code/data of the CURRENT process, i.e. the virtual address space 0~3G.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With