Skip to content

x86: Improve CET tests

Sean Christopherson kvm 2 versions Applied

Status from this message: Applied to kvm-x86 next, with fixups for the goofs reported by Mathias.

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v4 Latest18 patches 5 repliesApplied
  2. v317 patches 7 repliesSuperseded

Changes in v4 from the cover letter

- Fixup the argumentes for the vmx_cet_test. [Mathias]
- Drop "_test" from the vmx_cet config to match the other VMX testcases.
- Enable NOTRACK instead of dodging jmp tables in exception_mnemonic() [Mathias].
- Reset IBT state after (intentional) #CP. [Mathias]
- Fix a changelog typo. [Mathias]
- Document that ljmpq isn't supported on AMD. [Mathias]
- Use ljmpl to make the 32-bit JMP FAR more obvious. [Mathias]

Patches in v4 Applied

#Subject and filesSizeRepliesApplied
1/18x86: cet: Pass virtual addresses to invlpgx86/cet.c+1 -10 replies
2/18x86: cet: Remove unnecessary memory zeroing for shadow stackx86/cet.c+7 -120 replies
3/18x86: cet: Directly check for #CP exception in run_in_user()x86/cet.c+4 -190 replies
4/18x86: cet: Validate #CP error codelib/x86/usermode.c x86/cet.c+6 -20 replies
5/18x86: cet: Use report_skip()x86/cet.c+2 -20 replies
6/18x86: cet: Drop unnecessary castingx86/cet.c+4 -40 replies
7/18x86: cet: Validate writing unaligned values to SSP MSR causes #GPx86/cet.c+5 -00 replies
8/18x86: cet: Validate CET states during VMX transitionslib/x86/msr.h x86/unittests.cfg x86/vmx.h +1 more+96 -20 replies
9/18x86: cet: Make shadow stack less fragilex86/cet.c+4 -40 replies
10/18x86: cet: Simplify IBT testx86/cet.c+5 -60 replies
11/18x86: cet: Use symbolic values for the #CP error codesx86/cet.c+12 -30 replies
12/18x86: cet: Test far returns toox86/cet.c+32 -00 replies
13/18x86: Avoid top-most page for vmalloc on x86-64lib/x86/vm.c x86/lam.c+7 -50 replies
14/18x86: cet: Run SHSTK and IBT tests as appropriate if either feature is supportedx86/cet.c+33 -170 replies
15/18x86: cet: Drop the "intel_" prefix from the CET testcasex86/unittests.cfg+1 -10 replies
16/18x86: cet: Enable NOTRACK handling for IBT testsx86/cet.c+6 -51 reply
17/18x86: cet: Reset IBT tracker state on #CP violationslib/x86/usermode.c lib/x86/usermode.h x86/cet.c+46 -101 reply
18/18x86: cet: Add testcases to verify KVM rejects emulation of CET instructionsx86/cet.c+124 -12 replies

Reviews trailers per patch

3 of 18 patches have a Reviewed-by or Acked-by.

PatchChao GaoMathias Krause
1/18
2/18
3/18
4/18
5/18
6/18
7/18
8/18
9/18
10/18
11/18
12/18T-b
13/18R-b
14/18R-b T-b
15/18
16/18
17/18
18/18R-b T-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v4 thread

Cover letter [kvm-unit-tests PATCH v4 00/18] x86: Improve CET tests

Hopefully the last version of this particular CET series. Mathias, I owe you like five beers for root causing and fixing all the gnarly edge cases.

v4:
- Fixup the argumentes for the vmx_cet_test. [Mathias]
- Drop "_test" from the vmx_cet config to match the other VMX testcases.
- Enable NOTRACK instead of dodging jmp tables in exception_mnemonic() [Mathias].
- Reset IBT state after (intentional) #CP. [Mathias]
- Fix a changelog typo. [Mathias]
- Document that ljmpq isn't supported on AMD. [Mathias]
- Use ljmpl to make the 32-bit JMP FAR more obvious. [Mathias]

v3:
- https://lore.kernel.org/all/[email protected]
- Run the test if only one of SHSTK or IBT is supported (e.g. to test SHSTK on AMD).
- Rename the test from "intel_cet" to just "cet".
- Add an endbr64 in the user_mode trampoline (the test was getting false passes without ever reaching cet_shstk_far_ret() due to getting the expected #CP).
- Add testcases to verify KVM rejects emulation as expected.
- Add a comment explaining the SHSTK PTE magic (I forgot about the magic and spent a long time trying to figure out how the user_mode trampoline was succeeding if the SHSTK wasn't writable, *sigh*)

Chao Gao (7):
x86: cet: Remove unnecessary memory zeroing for shadow stack
x86: cet: Directly check for #CP exception in run_in_user()
x86: cet: Validate #CP error code
x86: cet: Use report_skip()
x86: cet: Drop unnecessary casting
x86: cet: Validate writing unaligned values to SSP MSR causes #GP
x86: cet: Validate CET states during VMX transitions

Mathias Krause (5):
x86: cet: Make shadow stack less fragile
x86: cet: Simplify IBT test
x86: cet: Use symbolic values for the #CP error codes
x86: cet: Test far returns too
x86: Avoid top-most page for vmalloc on x86-64

Sean Christopherson (5):
x86: cet: Run SHSTK and IBT tests as appropriate if either feature is
supported
x86: cet: Drop the "intel_" prefix from the CET testcase
x86: cet: Enable NOTRACK handling for IBT tests
x86: cet: Reset IBT tracker state on #CP violations
x86: cet: Add testcases to verify KVM rejects emulation of CET
instructions

Yang Weijiang (1):
x86: cet: Pass virtual addresses to invlpg

 lib/x86/msr.h      |   1 +
 lib/x86/usermode.c |  16 ++-
 lib/x86/usermode.h |  13 +-
 lib/x86/vm.c       |   2 +
 x86/cet.c          | 308 ++++++++++++++++++++++++++++++++++++---------
 x86/lam.c          |  10 +-
 x86/unittests.cfg  |  10 +-
 x86/vmx.h          |   8 +-
 x86/vmx_tests.c    |  81 ++++++++++++
 9 files changed, 375 insertions(+), 74 deletions(-)

base-commit: c885c94f523eb4518dc30408fb5199fd23d4aa0a

Signature · 1 line
2.52.0.rc1.455.g30608eb744-goog