Where is page table stored in Linux?

7,933

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.

Share:
7,933

Related videos on Youtube

Kindred
Author by

Kindred

Updated on September 18, 2022

Comments

  • Kindred
    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
    Johan Myréen over 5 years
    Yes, 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
    Kindred over 5 years
    Thanks 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
    ninjalj over 5 years
    Note 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.