0
votes

Virtual memory map with 4 level page tables:

0000000000000000 - 00007fffffffffff (=47 bits) user space, different per mm
ffff800000000000 - ffff80ffffffffff (=40 bits) guard hole
ffff880000000000 - ffffc7ffffffffff (=64 TB) direct mapping of all phys. memory
ffffc80000000000 - ffffc8ffffffffff (=40 bits) hole
ffffc90000000000 - ffffe8ffffffffff (=45 bits) vmalloc/ioremap space
ffffe90000000000 - ffffe9ffffffffff (=40 bits) hole
ffffea0000000000 - ffffeaffffffffff (=40 bits) virtual memory map (1TB)
ffffffff80000000 - ffffffffa0000000 (=512 MB)  kernel text mapping, from phys 0
ffffffffa0000000 - fffffffffff00000 (=1536 MB) module mapping space

I know that the kernel tries to map directly physical addresses to virtual addresses starting from PAGE_OFFSET for the direct mapping region

ffff880000000000 - ffffc7ffffffffff (=64 TB) direct mapping of all phys. memory

but I do not know where the code in kernel keeps the page tables to manage this direct mapping region and how to print out all the page table entries of 4 level page tables in this direct mapping region. Do you know how to print them?

1

1 Answers

0
votes

The kernel maintains a task_struct(sched.h) for each running process, and every task_struct has a mm_struct (mm_types.h) which maintains all of the process' virtual memory addresses. For more on how page tables are implemented, check the generic header files (generic and x86-64, and the implementation (arch/x86/mm/).

It is going to take a lot of digging to get your head around it; good luck.