Where is page table stored in Linux?
Yes, the page tables are stored in the kernel address space. Each process has its own page table structure, which is set up so that the kernel portion of the address space is shared between processes. The kernel address space is not accessible from user space, however. The user space code communicates with the kernel in a controlled manner using system calls. After a successful system call the processor enters a privileged state in which the kernel address space is available.
Related videos on Youtube
![Kindred](https://i.stack.imgur.com/KCFCA.png?s=256&g=1)
Kindred
Updated on September 18, 2022Comments
-
Kindred almost 2 years
I want know where Linux stores page tables. Is it in kernel virtual memory?
It seems like this has to do with virtual memory system. but I'm new to it, so if I'm in the wrong direction please let me know. And in order to answer the question myself I read some lines from a book says:
(23.2 page 8)
... Linux virtual address space consists of user portion and kernel portion...
... the kernel portion is the same across processes.
So the address space provided by kernel is in a sense a space for processes to share something? So if the page tables are put in kernel virtual memory would this mean processes can share their page tables?
The book I read: http://www.ostep.org
-
Johan Myréen over 5 yearsYes, all processes share the kernel's address space, but only kernel code can access that part of memory. The kernel is free to do what it wants with it, but the memory is not shared between processes in the sense that user level code in one process could freely write to it and another read it. The kernel can set up memory pages to be shared between processes, but then non-kernel addresses are used, since kernel addresses are always off limit for non-kernel code.
-
Kindred over 5 yearsThanks for your kindness and time, now I understand it! Since my question is ask about Linux, but can I take this as a general understand for other OS? (Or it's not recommend?)
-
ninjalj over 5 yearsNote that with KPTI (Kernel Page Table Isolation), there are different page tables when a process runs in userspace vs when it runs in kernelspace. This has a performance cost, but for Intel CPUs with the Meltdown vulnerability avoids some trouble.