[PATCH v3 00/14] Improvements for (nested) SVM testing

Yosry Ahmed posted 14 patches 2 months, 4 weeks ago
lib/x86/desc.h       |   8 +
scripts/runtime.bash |   4 +-
x86/svm.c            |  12 +-
x86/svm.h            |   7 +-
x86/svm_tests.c      | 402 +++++++++++++++++++++++++++++--------------
x86/vmx_tests.c      |   5 +-
6 files changed, 303 insertions(+), 135 deletions(-)
[PATCH v3 00/14] Improvements for (nested) SVM testing
Posted by Yosry Ahmed 2 months, 4 weeks ago
This is a combined v2/v3 of the patch series in [1] and [2], with a
couple of extra changes.

The series mostly includes fixups and cleanups, and more importantly new
tests for selective CR0  write intercepts and LBRV, which cover bugs
recently fixed by [3] and [4].

Patches 1-2 are unrelated fixups outside of SVM that I just included
here instead of submitting separately out of pure laziness.

Patches 3-8 are cleanups and refactoring.

Patch 9 deflakes svm_tsc_scale_test in a not-so-sophisticated way.

Patches 10-11 generalize the existing selective CR0 intercept tests and
extend them with new test cases.

Patches 12-13 cleanup the existing LBRV tests and extend them with new
test cases.

Patch 14 is a rename to some of VMCB fields to match recent renames in
KVM [5]. This is the last patch is in the series also due to laziness.

I realize that the patch ordering is a mess, and I can rebase and
reorder if it actually matters to anyone.

[1]https://lore.kernel.org/kvm/20251028221213.1937120-1-yosry.ahmed@linux.dev/
[2]https://lore.kernel.org/kvm/20251104193016.3408754-1-yosry.ahmed@linux.dev/
[3]https://lore.kernel.org/kvm/20251024192918.3191141-1-yosry.ahmed@linux.dev/
[4]https://lore.kernel.org/kvm/20251108004524.1600006-1-yosry.ahmed@linux.dev/
[5]https://lore.kernel.org/kvm/20251110222922.613224-1-yosry.ahmed@linux.dev/

Yosry Ahmed (14):
  scripts: Always return '2' when skipping tests
  x86/vmx: Skip vmx_pf_exception_test_fep early if FEP is not available
  x86/svm: Cleanup selective cr0 write intercept test
  x86/svm: Move CR0 selective write intercept test near CR3 intercept
  x86/svm: Add FEP helpers for SVM tests
  x86/svm: Report unsupported SVM tests
  x86/svm: Move report_svm_guest() to the top of svm_tests.c
  x86/svm: Print SVM test names before running tests
  x86/svm: Deflake svm_tsc_scale_test
  x86/svm: Generalize and improve selective CR0 write intercept test
  x86/svm: Add more selective CR0 write and LMSW test cases
  x86/svm: Cleanup LBRV tests
  x86/svm: Add more LBRV test cases
  x86/svm: Rename VMCB fields to match KVM

 lib/x86/desc.h       |   8 +
 scripts/runtime.bash |   4 +-
 x86/svm.c            |  12 +-
 x86/svm.h            |   7 +-
 x86/svm_tests.c      | 402 +++++++++++++++++++++++++++++--------------
 x86/vmx_tests.c      |   5 +-
 6 files changed, 303 insertions(+), 135 deletions(-)

-- 
2.51.2.1041.gc1ab5b90ca-goog
Re: [PATCH v3 00/14] Improvements for (nested) SVM testing
Posted by Sean Christopherson 2 months, 4 weeks ago
Nit, in the future, please label the patches with "kvm-unit-tests" so that it's
super obvious what they're for, e.g. [kvm-unit-tests PATCH ...].
Re: [PATCH v3 00/14] Improvements for (nested) SVM testing
Posted by Yosry Ahmed 2 months, 4 weeks ago
On Mon, Nov 10, 2025 at 04:52:37PM -0800, Sean Christopherson wrote:
> Nit, in the future, please label the patches with "kvm-unit-tests" so that it's
> super obvious what they're for, e.g. [kvm-unit-tests PATCH ...].

Ugh not a nit, it's actually annoying, even for me, because I use these
labels to search for my patches. Sorry about that, I had the correct
prefix in previous versions but forgot to add it this time around.

Let me know if you want me to resend to make things easier for you
(assuming you'll be the one to apply this if/when the time comes :) ).
Re: [PATCH v3 00/14] Improvements for (nested) SVM testing
Posted by Sean Christopherson 2 months, 3 weeks ago
On Mon, 10 Nov 2025 23:26:28 +0000, Yosry Ahmed wrote:
> This is a combined v2/v3 of the patch series in [1] and [2], with a
> couple of extra changes.
> 
> The series mostly includes fixups and cleanups, and more importantly new
> tests for selective CR0  write intercepts and LBRV, which cover bugs
> recently fixed by [3] and [4].
> 
> [...]

Applied to kvm-x86 next.  In the future, please only bundle related and/or
dependent patches, especially for one-off patches.  It's a lot easier on my
end (and likely for most maintainers and reviewers) to deal separate series.

E.g. if you need to spin a new version, then you aren't spamming everyone
with 10+ patches just to rev one patch that might not even be realted to the
rest.  And having separate series makes it easier to select exactly what I
want to apply.

Concretely, at a glance, this could/should be 7 different patches/series:

   1, 2, 3-5 + 7 + 10-11, 6, 8, 9, 12-13, 14

[01/14] scripts: Always return '2' when skipping tests
        https://github.com/kvm-x86/kvm-unit-tests/commit/1825b2d46c1a
[02/14] x86/vmx: Skip vmx_pf_exception_test_fep early if FEP is not available
        https://github.com/kvm-x86/kvm-unit-tests/commit/cab22b23b676
[03/14] x86/svm: Cleanup selective cr0 write intercept test
        https://github.com/kvm-x86/kvm-unit-tests/commit/5f57e54c42e6
[04/14] x86/svm: Move CR0 selective write intercept test near CR3 intercept
        https://github.com/kvm-x86/kvm-unit-tests/commit/0fa8b9beffba
[05/14] x86/svm: Add FEP helpers for SVM tests
        https://github.com/kvm-x86/kvm-unit-tests/commit/1c5e0e1c75aa
[06/14] x86/svm: Report unsupported SVM tests
        https://github.com/kvm-x86/kvm-unit-tests/commit/d7e64b50d0e3
[07/14] x86/svm: Move report_svm_guest() to the top of svm_tests.c
        https://github.com/kvm-x86/kvm-unit-tests/commit/9af8f8e09dff
[08/14] x86/svm: Print SVM test names before running tests
        https://github.com/kvm-x86/kvm-unit-tests/commit/044c33c54661
[09/14] x86/svm: Deflake svm_tsc_scale_test
        [ DROP ]
[10/14] x86/svm: Generalize and improve selective CR0 write intercept test
        https://github.com/kvm-x86/kvm-unit-tests/commit/cc34f04ac665
[11/14] x86/svm: Add more selective CR0 write and LMSW test cases
        https://github.com/kvm-x86/kvm-unit-tests/commit/09e2c95edefd
[12/14] x86/svm: Cleanup LBRV tests
        https://github.com/kvm-x86/kvm-unit-tests/commit/114a564310f6
[13/14] x86/svm: Add more LBRV test cases
        https://github.com/kvm-x86/kvm-unit-tests/commit/ffd01c54af99
[14/14] x86/svm: Rename VMCB fields to match KVM
        [ WAIT ]

--
https://github.com/kvm-x86/kvm-unit-tests/tree/next
Re: [PATCH v3 00/14] Improvements for (nested) SVM testing
Posted by Yosry Ahmed 2 months, 3 weeks ago
On Thu, Nov 13, 2025 at 04:46:13PM -0800, Sean Christopherson wrote:
> On Mon, 10 Nov 2025 23:26:28 +0000, Yosry Ahmed wrote:
> > This is a combined v2/v3 of the patch series in [1] and [2], with a
> > couple of extra changes.
> > 
> > The series mostly includes fixups and cleanups, and more importantly new
> > tests for selective CR0  write intercepts and LBRV, which cover bugs
> > recently fixed by [3] and [4].
> > 
> > [...]
> 
> Applied to kvm-x86 next.  In the future, please only bundle related and/or
> dependent patches, especially for one-off patches.  It's a lot easier on my
> end (and likely for most maintainers and reviewers) to deal separate series.
> 
> E.g. if you need to spin a new version, then you aren't spamming everyone
> with 10+ patches just to rev one patch that might not even be realted to the
> rest.  And having separate series makes it easier to select exactly what I
> want to apply.

Noted. I thought that I was going to end up sending a handful of
scattered patches and it will actually end up being difficult for you to
keep track of them. To be honest, it was also easier for me :P

Anyway, will separate such changes going forward!

> 
> Concretely, at a glance, this could/should be 7 different patches/series:
> 
>    1, 2, 3-5 + 7 + 10-11, 6, 8, 9, 12-13, 14

3-5 + 7 + 10-11 is more-or-less what was in v1. I piled the rest on the
series :)

> 
> [01/14] scripts: Always return '2' when skipping tests
>         https://github.com/kvm-x86/kvm-unit-tests/commit/1825b2d46c1a
> [02/14] x86/vmx: Skip vmx_pf_exception_test_fep early if FEP is not available
>         https://github.com/kvm-x86/kvm-unit-tests/commit/cab22b23b676
> [03/14] x86/svm: Cleanup selective cr0 write intercept test
>         https://github.com/kvm-x86/kvm-unit-tests/commit/5f57e54c42e6
> [04/14] x86/svm: Move CR0 selective write intercept test near CR3 intercept
>         https://github.com/kvm-x86/kvm-unit-tests/commit/0fa8b9beffba
> [05/14] x86/svm: Add FEP helpers for SVM tests
>         https://github.com/kvm-x86/kvm-unit-tests/commit/1c5e0e1c75aa
> [06/14] x86/svm: Report unsupported SVM tests
>         https://github.com/kvm-x86/kvm-unit-tests/commit/d7e64b50d0e3
> [07/14] x86/svm: Move report_svm_guest() to the top of svm_tests.c
>         https://github.com/kvm-x86/kvm-unit-tests/commit/9af8f8e09dff
> [08/14] x86/svm: Print SVM test names before running tests
>         https://github.com/kvm-x86/kvm-unit-tests/commit/044c33c54661
> [09/14] x86/svm: Deflake svm_tsc_scale_test
>         [ DROP ]
> [10/14] x86/svm: Generalize and improve selective CR0 write intercept test
>         https://github.com/kvm-x86/kvm-unit-tests/commit/cc34f04ac665
> [11/14] x86/svm: Add more selective CR0 write and LMSW test cases
>         https://github.com/kvm-x86/kvm-unit-tests/commit/09e2c95edefd
> [12/14] x86/svm: Cleanup LBRV tests
>         https://github.com/kvm-x86/kvm-unit-tests/commit/114a564310f6
> [13/14] x86/svm: Add more LBRV test cases
>         https://github.com/kvm-x86/kvm-unit-tests/commit/ffd01c54af99
> [14/14] x86/svm: Rename VMCB fields to match KVM
>         [ WAIT ]
> 
> --
> https://github.com/kvm-x86/kvm-unit-tests/tree/next