Kernel page-table isolation

Also known as: KPTI

On this page 7

Kernel page-table isolation (KPTI) is an operating system defense that gives each process two separate sets of page tables, one for user mode that maps almost no kernel memory and one for kernel mode that maps everything. In OS security, it is the principal software mitigation for Meltdown (CVE-2017-5754), a processor flaw that let ordinary programs read kernel memory through speculative execution.

Linux adopted the technique in early 2018 under the name KPTI, after it was developed as KAISER to protect KASLR. Microsoft shipped the equivalent KVA Shadow in Windows, and Apple added a comparable separation to macOS and iOS. The protection works, but it costs extra work on every transition between user and kernel mode.

How kernel page-table isolation separates address spaces

KPTI works by ensuring that kernel memory is not mapped at all while user code runs. Before the mitigation, mainstream kernels mapped themselves into the upper half of every process address space and relied on the supervisor bit in page-table entries to block user access. Meltdown showed that some processors performed the load speculatively before the permission check failed, leaving the secret value detectable in the CPU cache.

With KPTI, the kernel keeps a full page-table tree for itself and a shadow user page-table tree for each process. The user copy maps the program memory plus a minimal trampoline: entry and exit code, interrupt descriptor tables, per-CPU entry stacks and a few data structures the hardware needs during a mode switch. On every system call, interrupt or exception, the entry code switches the CR3 register to the kernel tree, and it switches back before returning to user mode.

The following table lists what each page-table set contains on a typical x86-64 Linux system.

MappingUser-mode page tablesKernel-mode page tables
Process code and dataMappedMapped
Kernel text and dataNot mappedMapped
Entry and exit trampolineMappedMapped
Interrupt descriptor tableMappedMapped
Direct map of physical memoryNot mappedMapped
Contents of the two page-table sets

Performance cost and the role of PCID

The main drawback of KPTI is translation lookaside buffer (TLB) pressure. Writing CR3 normally flushes non-global TLB entries, so each kernel entry and exit would discard cached address translations. Workloads with frequent system calls, such as databases, network servers, storage stacks and build systems, therefore suffer most, while compute-bound code barely notices.

Kernels reduce the penalty with Process-Context Identifiers (PCID), an x86-64 feature that tags TLB entries with an address-space identifier. Linux assigns distinct PCIDs to the kernel and user copies, so a CR3 switch can preserve TLB entries for both. The INVPCID instruction further helps by invalidating selected entries efficiently. Reported overheads vary widely with hardware generation and workload, as the table below shows.

Workload typeTypical overheadMain reason
Compute-bound tasksNear zeroFew kernel transitions
Desktop and office useBarely measurableModerate system-call rate
Databases and file serversSeveral percent to about 20%High system-call and I/O rate
Synthetic system-call loopsCan exceed 30% without PCIDTransition cost dominates
Typical KPTI overhead by workload

These figures are ranges, not guarantees. Older CPUs without PCID pay noticeably more, and virtualized guests can add further cost because CR3 writes may involve the hypervisor.

How KPTI relates to other kernel memory protections

KPTI addresses a hardware information leak, which makes it different from mitigations aimed at software bugs. It complements rather than replaces protections such as KASLR, SMEP and SMAP. In fact, KAISER was first proposed to stop side-channel attacks that defeated KASLR, because a kernel that is not mapped cannot reveal its randomized location.

The comparison below places KPTI among neighboring defenses in the same layer of the operating system.

MitigationThreat addressedEnforced byOverhead
KPTISpeculative reads of kernel memorySeparate page tablesLow to moderate
KASLRPredictable kernel addressesRandomized load baseNegligible
SMEPKernel executing user pagesCPU featureNegligible
SMAPKernel reading user pages by accidentCPU featureNegligible
Retpoline and IBRSBranch target injection (Spectre v2)Compiler and microcodeLow to moderate
KPTI compared with related mitigations

An important distinction is that KPTI does not stop Spectre variants, which abuse branch prediction to leak data within or across contexts. Those require separate measures such as retpolines, indirect branch controls and array index masking.

When kernel page-table isolation is enabled

Modern kernels enable KPTI only on vulnerable processors. Linux checks the CPU vendor and the RDCL_NO bit in the IA32_ARCH_CAPABILITIES register, which newer Intel processors set to declare immunity to Meltdown. AMD processors were not affected by Meltdown, so Linux leaves KPTI off on them by default, and most Intel parts released from about 2019 onward also run without it.

Administrators can inspect and control the mitigation as follows.

PlatformHow to check statusHow to change it
Linux/sys/devices/system/cpu/vulnerabilities/meltdownBoot parameter pti=on, pti=off or nopti
WindowsGet-SpeculationControlSettings in PowerShellRegistry FeatureSettingsOverride values
Arm64 LinuxKernel log and vulnerability filesBoot parameter kpti=0 or kpti=1
Checking and configuring KPTI

Disabling KPTI on vulnerable hardware is rarely justified. It may be acceptable on isolated single-tenant systems that run only trusted code, but it reopens a reliable kernel memory disclosure path for any local process.

Limitations and common misconceptions

KPTI narrows one attack surface but leaves several related risks in place. Practitioners regularly encounter the following misunderstandings.

  • KPTI is not a general sandbox. It hides kernel memory from speculative reads but does nothing against ordinary kernel exploits that abuse bugs in drivers or system calls.
  • The trampoline remains visible. The small set of mapped entry structures could still leak limited information, which is why kernels keep it minimal.
  • Microcode updates do not replace it. On affected processors, Meltdown is fixed only in silicon or by page-table separation.
  • It is not needed everywhere. Running KPTI on immune CPUs wastes performance without adding protection, which is why kernels detect immunity automatically.

Later research, including Microarchitectural Data Sampling (MDS) and L1 Terminal Fault, showed that page-table separation alone cannot close every transient-execution leak. KPTI is therefore best understood as one layer in a defense-in-depth strategy alongside buffer clearing, core scheduling and hardware fixes.

In plain words

Imagine a building where staff offices sit behind a glass wall that visitors cannot open. A clever visitor discovered a trick to read documents through the glass. KPTI replaces the glass with a solid wall: while visitors are inside, the offices simply are not there.

When a visitor needs help, the building quickly swaps in the office floor plan, does the work and swaps back. That swapping takes a little time, so security improves at a small cost in speed, mostly noticeable for programs that ask the system for help many times per second.

A real-world example

In January 2018, a hosting provider running shared Linux servers on Intel Xeon processors from 2015 faced a direct risk: any customer process could read kernel memory, including data from neighboring tenants. Its operations team installed kernels with KPTI enabled across the fleet within two weeks.

Monitoring showed that web front ends lost almost no throughput, while a busy PostgreSQL cluster handling many small queries saw CPU usage rise by roughly 10%. Because the processors supported PCID, the cost stayed moderate. The team accepted it, scheduled hardware replacement with Meltdown-immune processors, and later confirmed that the new nodes reported “Not affected” and ran with KPTI automatically disabled.