Search code examples
page-tables

Where is page table located?


I've been studying about paging and page tables. I don't see to understand where page tables are located. In one of the answers from stack exchange(https://unix.stackexchange.com/questions/487052/where-is-page-table-stored-in-linux), it is said that page tables are in kernel address space, which is in virtual memory(from what I understood). However in lecture slides from University of Illinois(https://courses.engr.illinois.edu/cs241/sp2014/lecture/09-VirtualMemory_II_sol.pdf), page tables seem to be in RAM, which is physical memory. Can anyone tell me clearly where the page tables are stored?

Thank you in advance.


Solution

  • The answer to this question is too broad, and I think it belongs to super-user stack exchange.

    In x86 systems, page tables are structures used by the CPU, but they are too large to be hold in registers, so they are kept in RAM.

    Any process has a memory map in which there is two big zones: user space and kernel space. Kernel space is the same space for all process. User space is private to that process. On 32 bit X86 based Linux systems, any logical address equal or greater than 0xC0000000 belongs to kernel. Below that address, it's user space.

    The page table of the process is held in the kernel space. The kernel may have several page tables in RAM, but only one is the active page table. In x86 CPUs, it's the page table pointed by register CR3.

    There is a more detailed explanation of how it works here: https://stackoverflow.com/a/20792205/3011009