11

The Linux Programming Interface shows the layout of a virtual address space of a process:

enter image description here

Is the kernel in the physical memory completely or partially mapped to the part "Kernel" on the top from 0xC0000000 to 0XFFFFFFFF in the virtual address space of each process?

If partially, which part of the kernel in the physical memory is mapped to the "Kernel" part in the virtual address space of each process, and which part isn't?

Does the "Kernel" part in the virtual address space of a process store exactly the part of the kernel code which is accessible to the process when it is running in kernel mode, not the part of the kernel code which isn't?

Do the virtual address spaces of all the processes have the same content in their "Kernel" parts?

1 Answer 1

10

The answer depends on whether kernel page-table isolation is enabled (which depends on the architecture and whether it supports KPTI).

Without KPTI, the kernel is fully mapped in each process’ address space, but as mentioned in the diagram, those mappings are inaccessible from user space (barring side-channel leaks).

With KPTI, the kernel page tables are separate from the userspace page tables, and only a minimal set of mappings are left in each process’ address space, as required to allow user space to call into the kernel, and to enable the processor to give control to the kernel when dealing with interrupts or exceptions.

In both cases, all processes have the same mappings for the kernel.

See also LWN’s article on KAISER.

2
  • Thanks. Does the "Kernel" part in the virtual address space of a process store exactly the part of the kernel code which is accessible to the process when it is running in kernel mode, not the part of the kernel code which isn't?
    – Tim
    Sep 14, 2018 at 11:27
  • 1
    I’m not sure I understand the question. Anything which isn’t mapped in the address space isn’t accessible, by definition, regardless of the mode in which the CPU is running. Sep 14, 2018 at 11:29

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .