What is Kernel page-table isolation (KPTI)?

An OS countermeasure to Meltdown that removes most kernel memory from the page tables while user programs run.

Field: Hardware Security

Japanese name: KPTI

Why KPTI became necessary

Without KPTI, many operating systems map the kernel's region into each user process's page tables as well, marking kernel pages as inaccessible from user mode. This avoids switching page tables when entering the kernel for a system call or interrupt, keeping those paths fast. But Meltdown showed that on affected CPUs kernel data could be read speculatively before this permission check completed, and its value inferred from traces left in the cache. Kernel page-table isolation (KPTI) is an OS countermeasure that blocks such reads through the way page tables are set up.

Two sets of page tables

KPTI gives each process two sets of page tables. The one used while the kernel runs maps both user and kernel regions. The one used while a user program runs maps the user region plus only the small part of the kernel needed by the entry code for system calls and interrupts. Without an address translation, kernel data cannot be read even speculatively. On entering the kernel, the entry code switches to the kernel page tables, and it switches back to the user tables on returning to user mode. Linux adopted it; in its research stage it was called KAISER.

Performance impact and PCID

KPTI switches page tables on every system call, interrupt and exception, which takes time. On CPUs that cannot use PCID, each switch also invalidates the TLB contents, and the resulting TLB misses further reduce performance. The impact varies greatly with the workload: it is barely noticeable for compute-bound programs but tends to be large for databases with many system calls and I/O-heavy work. Using the x86 PCID (process-context identifier), the user and kernel page tables get different numbers and can be switched without flushing the TLB, which reduces the loss.

When KPTI is not needed

KPTI is a countermeasure for CPUs affected by Meltdown and is unnecessary on unaffected CPUs. Many CPUs designed after Meltdown was disclosed are fixed in hardware so that unauthorized data is not passed to subsequent instructions, and Linux decides whether a CPU is affected from information the CPU reports, among other things, and does not enable KPTI when it is not needed. Some CPUs, such as AMD's x86 CPUs, are considered never to have been affected by Meltdown. Windows introduced a similar countermeasure called KVA Shadow. Note that KPTI targets Meltdown; Spectre, which abuses branch prediction, requires different countermeasures.

Try it: questions about Kernel page-table isolation (KPTI)

What is the idea behind KPTI (kernel page-table isolation), introduced as a software countermeasure to Meltdown?

  1. AWhile user programs run, most kernel memory is removed from the page tables so it cannot be read even speculatively
  2. BEncrypt the entire kernel and store it on disk
  3. CForbid user programs from running
Show answer and explanation

Answer: A. While user programs run, most kernel memory is removed from the page tables so it cannot be read even speculatively

For fast switching, OSes without KPTI map kernel memory into each user process's page tables, marked as inaccessible. Meltdown read it speculatively before that mark was checked, so KPTI removes kernel pages from the mapping altogether while user code runs. Without an address translation, the data cannot be read even speculatively. Switching page tables on every system call, however, costs performance.

FAQ

What is KPTI?

Short for kernel page-table isolation, it is an OS countermeasure that removes most kernel memory from the page tables while user programs run, preventing reads via Meltdown.

Why does KPTI reduce performance?

Because the page tables are switched every time a system call or interrupt enters or leaves the kernel, time is spent on the switch and on the TLB misses that follow. On CPUs that can use PCID, the TLB need not be flushed, which reduces the loss.

Is it safe to disable KPTI?

It is unnecessary on CPUs unaffected by Meltdown or fixed in hardware, and the OS generally disables it automatically on those. Disabling it on an affected CPU leaves kernel memory at risk of being read.

Questions that mention Kernel page-table isolation (KPTI) (2)

Kernel page-table isolation (KPTI) appears in 3 practice questions across 2 topics, including Hardware Security: Advanced Topics and Trends, Hardware Security.

  1. Regarding hardware features that support control-flow integrity, which correctly pairs what protects returns from functions with what protects indirect calls and jumps such as those through function pointers?
  2. A task took 10 seconds before mitigations for speculative execution were applied and made 5 million system calls during that time. Assume that the mitigations increase the processing time per system call from 0.4 µs to 0.6 µs and leave the time of everything else unchanged. By what proportion does the total time of the task increase?

Books on Hardware Security Ad

As an Amazon Associate I earn from qualifying purchases.

This page was drafted with AI and fact-checked by a separate AI review before publication. Our Editorial policy explains how we write and check content. If you spot an error, please tell us on our Contact page.

Back to the glossary