[X86] Add Indirect Thunk Support to X86 to mitigate Load Value Injection (LVI)
authorScott Constable <scott.d.constable@intel.com>
Fri, 3 Apr 2020 04:59:47 +0000 (21:59 -0700)
committerCraig Topper <craig.topper@gmail.com>
Fri, 3 Apr 2020 07:34:39 +0000 (00:34 -0700)
commit5b519cf1fc6737054cf90b53667e7ddd3a51225f
tree46f4c746af6508b7a89391bcb3f6a5a103fe43db
parent0a3845b70f4fc36b4656aba9a568a00fdaf5bab4
[X86] Add Indirect Thunk Support to X86 to mitigate Load Value Injection (LVI)

This pass replaces each indirect call/jump with a direct call to a thunk that looks like:

lfence
jmpq *%r11

This ensures that if the value in register %r11 was loaded from memory, then
the value in %r11 is (architecturally) correct prior to the jump.
Also adds a new target feature to X86: +lvi-cfi
("cfi" meaning control-flow integrity)
The feature can be added via clang CLI using -mlvi-cfi.

This is an alternate implementation to https://reviews.llvm.org/D75934 That merges the thunk insertion functionality with the existing X86 retpoline code.

Differential Revision: https://reviews.llvm.org/D76812
clang/docs/ClangCommandLineReference.rst
clang/include/clang/Driver/Options.td
clang/lib/Driver/ToolChains/Arch/X86.cpp
clang/test/Driver/x86-target-features.c
llvm/lib/Target/X86/X86.td
llvm/lib/Target/X86/X86ISelLowering.cpp
llvm/lib/Target/X86/X86IndirectThunks.cpp
llvm/lib/Target/X86/X86Subtarget.h
llvm/test/CodeGen/X86/lvi-hardening-indirectbr.ll [new file with mode: 0644]