Skip to content

x86/svm: Add testing for L1 intercept bug

Kevin Cheng kvm 4 versions – New

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v4 Latest2 patches 0 repliesNew
  2. v32 patches 4 repliesSuperseded
  3. v22 patches 2 repliesSuperseded
Earlier versions · 1
VersionPostedPatchesRepliesStatus
v12 patches3 repliesSuperseded

Changes in v4 from the cover letter

- Fixed incorrect intercept handling introduced by the svm intercept refactoring in TEST_BITMAP_ADDR
- Switched to using vmcb_save_intercepts() in handle_exception_in_l1
- Fixed incorrect reference to saved_intercept instead of saved_intercepts in test_msrpm_iopm_bitmap_addrs

Patches in v4 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/2x86/svm: Add missing svm interceptsx86/svm.c x86/svm.h x86/svm_tests.c+163 -800 replies
2/2x86/svm: Add unsupported instruction intercept testlib/x86/processor.h x86/svm.h x86/svm_tests.c +1 more+103 -20 replies

Reviews trailers per patch

1 of 2 patches has a Reviewed-by or Acked-by.

PatchYosry Ahmed
1/2R-b
2/2

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 0/2] x86/svm: Add testing for L1 intercept bug

If a feature is not advertised to L1, L1 intercepts for instructions controlled by this feature should be ignored. Currently, the added test fails due to a bug in nested vm exit handling where vmcb12 intercepts are checked before vmcb02 intercepts, causing the #UD exception to never be injected into L2 if the L1 intercept is set. This is fixed in [0]

The first patch just adds the missing intercepts needed for testing and restructures the vmcb_control_area struct to make adding the missing intercepts less ugly. The second patch adds the test which disables all relevant features that have available instruction intercepts, and checks that the #UD exception is correctly delivered despite the L1 intercept being set.

[0] https://lore.kernel.org/all/[email protected]/

v3 -> v4:
- Fixed incorrect intercept handling introduced by the svm intercept refactoring in TEST_BITMAP_ADDR
- Switched to using vmcb_save_intercepts() in handle_exception_in_l1
- Fixed incorrect reference to saved_intercept instead of saved_intercepts in test_msrpm_iopm_bitmap_addrs

v3: https://lore.kernel.org/all/[email protected]/

v2 -> v3:
- Added assertions to unsupported instructions test to verify that CPU does not support features enabling tested instructions [Yosry Ahmed]
- Added some comments [Yosry Ahmed]
- Changed insn_invpcid() into assembly [Yosry Ahmed]
- Added a check to the unsupported instruction test to ensure that L1's vmcb is not modified by KVM [Yosry Ahmed]
- Redacted reviewed-by tag for 2nd patch in series. I mistakingly added that

v2: https://lore.kernel.org/all/[email protected]/

v1 -> v2:
- Added save/restore helpers for all intercepts as suggested by Yosry
- Reuse invpcid_safe() for added test as suggested by Yosry
- Include '-skinit' in unittests.cfg for added test target as pointed out by Yosry

v1: https://lore.kernel.org/all/[email protected]/

Kevin Cheng (2):
x86/svm: Add missing svm intercepts x86/svm: Add unsupported instruction intercept test

 lib/x86/processor.h |   1 +
 x86/svm.c           |  18 +++-
 x86/svm.h           |  89 +++++++++++++++--
 x86/svm_tests.c     | 229 +++++++++++++++++++++++++++++++-------------
 x86/unittests.cfg   |  11 ++-
 5 files changed, 266 insertions(+), 82 deletions(-)

--
2.53.0.851.ga537e3e6e9-goog