Enable IBT(Indirect Branch Tracking) in JIT with CET(Control-flow Enforcement Technology)
authorXiang1 Zhang <xiang1.zhang@intel.com>
Fri, 3 Apr 2020 03:25:38 +0000 (11:25 +0800)
committerXiang1 Zhang <xiang1.zhang@intel.com>
Fri, 3 Apr 2020 03:44:07 +0000 (11:44 +0800)
commit43f031d31264d20cfb8f1ebd606c66e57c231d4d
tree86c8aa41a446f2303298ee9097cf583ff2084ed2
parentbe0a4fef6e789a8f25316af988b2d312d83d0d1c
Enable IBT(Indirect Branch Tracking) in JIT with CET(Control-flow Enforcement Technology)

Summary:
This patch comes from H.J.'s https://github.com/hjl-tools/llvm-project/commit/2bd54ce7fa9e94fcd1118b948e14d1b6fc54dfd2

**This patch fix the failed llvm unit tests which running on CET machine. **(e.g. ExecutionEngine/MCJIT/MCJITTests)

The reason we enable IBT at "JIT compiled with CET" is mainly that:  the JIT don't know the its caller program is CET enable or not.
If JIT's caller program is non-CET, it is no problem JIT generate CET code or not.
But if JIT's caller program is CET enabled,  JIT must generate CET code or it will cause Control protection exceptions.

I have test the patch at llvm-unit-test and llvm-test-suite at CET machine. It passed.
and H.J. also test it at building and running VNCserver(Virtual Network Console), it works too.
(if not apply this patch, VNCserver will crash at CET machine.)

Reviewers: hjl.tools, craig.topper, LuoYuanke, annita.zhang, pengfei

Subscribers: tstellar, efriedma, hiraditya, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D76900
llvm/lib/Target/X86/X86IndirectBranchTracking.cpp
llvm/lib/Target/X86/X86TargetMachine.cpp
llvm/lib/Target/X86/X86TargetMachine.h
llvm/test/CodeGen/X86/indirect-branch-tracking-cm-lager.ll [new file with mode: 0644]
llvm/test/ExecutionEngine/MCJIT/cet-code-model-lager.ll [new file with mode: 0644]