x86: Add test cases for user-mode CET validation
This unit test is intended to test user-mode CET support of KVM, it's tested on Intel new platform. Two CET features: Shadow Stack Protection(SHSTK) and Indirect-Branch Tracking(IBT) are enclosed. In SHSTK test, if the function return-address in normal stack is tampered with a value not equal to the one on shadow-stack, #CP (Control Protection Exception)will generated on function returning. This feature is supported by processor itself, no compiler/link option is required. However, to enabled IBT, we need to add -fcf-protection=full in compiler options, this makes the compiler insert endbr64 at the very beginning of each jmp/call target given the binary is for x86_64. To get PASS results, the following conditions must be met: 1) The processor is powered with CET feature. 2) The kernel is patched with the latest CET kernel patches. 3) The KVM and QEMU are patched with the latest CET patches. 4) Use CET-enabled gcc to compile the test app. v2: - Removed extra dependency on test framework for user/kernel mode switch. - Directly set #CP handler instead of through TSS. Signed-off-by:Yang Weijiang <weijiang.yang@intel.com> Message-Id: <20200506082110.25441-12-weijiang.yang@intel.com> Signed-off-by:
Paolo Bonzini <pbonzini@redhat.com>
Loading
Please register or sign in to comment