Skip to content

RFC x86: Disabling PTI in compatibility mode

Nadav Amit lkml 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v2 RFC Latest6 patches 33 repliesIn review

Changes in v2 from the cover letter

- Handling the use of CS64 in compatibility mode (Andy)
- Holding the PTI disable indication per mm and not task (Andy)
- No PTI disabling if SMEP is unsupported (Dave, Ingo)
- Self-test and cleanup
- Enabling global pages while running in compatibility mode

Patches in v2 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/6x86: Skip PTI when disable indication is setarch/x86/entry/calling.h arch/x86/include/asm/tlbflush.h arch/x86/kernel/asm-offsets.c+49 -24 replies
2/6x86: Save pti_disable for each mm_contextarch/x86/include/asm/mmu.h arch/x86/include/asm/pti.h arch/x86/mm/pgtable.c +1 more+22 -30 replies
3/6x86: Switching page-table isolationarch/x86/include/asm/pti.h arch/x86/include/asm/tlbflush.h arch/x86/mm/tlb.c+59 -00 replies
4/6x86: Disable PTI on compatibility modearch/x86/include/asm/pti.h arch/x86/kernel/process_64.c arch/x86/kernel/traps.c +1 more+201 -414 replies
5/6x86: Use global pages when PTI is disabledarch/x86/include/asm/tlbflush.h arch/x86/mm/init.c arch/x86/mm/tlb.c+14 -97 replies
6/6selftest: x86: test using CS64 on compatibility-modetools/testing/selftests/x86/ldt_gdt.c+41 -00 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v2 yet.

Read the v2 thread

Cover letter [PATCH RFC v2 0/6] x86: Disabling PTI in compatibility mode

Compatibility mode should be safe of Meltdown, since the pointers are only 32-bit long. This can allow us to disable PTI selectively as long as x86-32 processes are running and to enable global pages throughout this time. These patches may also be a basis for later disabling PTI selectively for "trusted" processes.

The patches are marked as an RFC since they (specifically the last one) do not coexist with Dave Hansen's enabling of global pages, and might have conflicts with Joerg's work on 32-bit (although in this case, it should be easily resolvable). They are also based on Linux 4.15.

I removed the PTI disabling while SMEP is unsupported, although I must admit I did not fully understand why it is required. IIUC, Intel's indirect branch prediction only predicts the low 32-bits of the target, which would still not allow to manipulate the kernel to jump to userspace code through Spectre v2.

RFC v1 -> RFC v2:
- Handling the use of CS64 in compatibility mode (Andy)
- Holding the PTI disable indication per mm and not task (Andy)
- No PTI disabling if SMEP is unsupported (Dave, Ingo)
- Self-test and cleanup
- Enabling global pages while running in compatibility mode

Nadav Amit (6):
x86: Skip PTI when disable indication is set
x86: Save pti_disable for each mm_context
x86: Switching page-table isolation
x86: Disable PTI on compatibility mode
x86: Use global pages when PTI is disabled
selftest: x86: test using CS64 on compatibility-mode

 arch/x86/entry/calling.h              |  33 ++++++++
 arch/x86/include/asm/mmu.h            |   3 +
 arch/x86/include/asm/pti.h            |  70 +++++++++++++++++
 arch/x86/include/asm/tlbflush.h       |  35 ++++++++-
 arch/x86/kernel/asm-offsets.c         |   1 +
 arch/x86/kernel/process_64.c          |  13 +++-
 arch/x86/kernel/traps.c               |  23 +++++-
 arch/x86/mm/init.c                    |  14 ++--
 arch/x86/mm/pgtable.c                 |   4 +-
 arch/x86/mm/pti.c                     | 139 +++++++++++++++++++++++++++++++++-
 arch/x86/mm/tlb.c                     |  28 ++++++-
 tools/testing/selftests/x86/ldt_gdt.c |  41 ++++++++++
 12 files changed, 386 insertions(+), 18 deletions(-)
Signature · 1 line
2.14.1