Skip to content

KVM: selftests: AVX support + fixes

Sean Christopherson kvm lkml 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest11 patches 14 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/11KVM: selftests: Fix out-of-bounds reads in CPUID test's array lookupstools/testing/selftests/kvm/x86_64/cpuid_test.c+1 -11 reply
2/11KVM: selftests: Precisely mask off dynamic fields in CPUID testtools/testing/selftests/kvm/x86_64/cpuid_test.c+36 -251 reply
3/11KVM: selftests: Mask off OSPKE and OSXSAVE when comparing CPUID entriestools/testing/selftests/kvm/x86_64/cpuid_test.c+6 -01 reply
4/11KVM: selftests: Rework OSXSAVE CR4=>CPUID test to play nice with AVX insnstools/testing/selftests/kvm/x86_64/cr4_cpuid_sync_test.c+32 -141 reply
5/11KVM: selftests: Configure XCR0 to max supported value by defaulttools/testing/selftests/kvm/include/x86_64/processor.h tools/testing/selftests/kvm/lib/x86_64/processor.c tools/testing/selftests/kvm/x86_64/xcr0_cpuid_test.c+32 -32 replies
6/11KVM: selftests: Verify XCR0 can be "downgraded" and "upgraded"tools/testing/selftests/kvm/x86_64/xcr0_cpuid_test.c+5 -01 reply
7/11KVM: selftests: Drop manual CR4.OSXSAVE enabling from CR4/CPUID sync testtools/testing/selftests/kvm/x86_64/cr4_cpuid_sync_test.c+2 -51 reply
8/11KVM: selftests: Drop manual XCR0 configuration from AMX testtools/testing/selftests/kvm/x86_64/amx_test.c+4 -191 reply
9/11KVM: selftests: Drop manual XCR0 configuration from state testtools/testing/selftests/kvm/x86_64/state_test.c+0 -51 reply
10/11KVM: selftests: Drop manual XCR0 configuration from SEV smoke testtools/testing/selftests/kvm/x86_64/sev_smoke_test.c+2 -130 replies
11/11KVM: selftests: Ensure KVM supports AVX for SEV-ES VMSA FPU testtools/testing/selftests/kvm/x86_64/sev_smoke_test.c+3 -11 reply

Reviews trailers per patch

9 of 11 patches have a Reviewed-by or Acked-by.

PatchVitaly Kuznetsov
1/11R-b
2/11R-b
3/11R-b
4/11R-b
5/11Reviewed-and-tested-by
6/11R-b
7/11R-b
8/11R-b
9/11R-b
10/11
11/11R-b

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

Read the v1 thread

Cover letter [PATCH 00/11] KVM: selftests: AVX support + fixes

Enable CR4.OSXSAVE and XCR0.AVX by default when creating selftests vCPUs in order to play nice with compilers that have been configured to enable -march=x86-64-v3 by default.

While it would be easier to force v2 (or earlier), there are enough tests that want XCR0 configured that it will (hopefully) be a net postive to enable all XCR0 features by default.

The only real hiccup is the CR4/CPUID sync test, which disables CR4.OSXSAVE to verify KVM toggles the associated CPUID bit. And if it calls memset() while OSXAVE is disabled, kablooie. Fixing that requires a bit of assembly, but overall I think it's worth carrying a few lines of assembly in order to gain test coverage for running AVX instructions in guests, and boy are compilers good at abusing AVX :-)

Fix a few bugs/warts found along the way. Notably, the CPUID test has an array out-of-bounds bug that can result in false passes (I only noticed because it was getting a false pass on gcc).

Sean Christopherson (11):
KVM: selftests: Fix out-of-bounds reads in CPUID test's array lookups
KVM: selftests: Precisely mask off dynamic fields in CPUID test
KVM: selftests: Mask off OSPKE and OSXSAVE when comparing CPUID
entries
KVM: selftests: Rework OSXSAVE CR4=>CPUID test to play nice with AVX
insns
KVM: selftests: Configure XCR0 to max supported value by default
KVM: selftests: Verify XCR0 can be "downgraded" and "upgraded"
KVM: selftests: Drop manual CR4.OSXSAVE enabling from CR4/CPUID sync
test
KVM: selftests: Drop manual XCR0 configuration from AMX test
KVM: selftests: Drop manual XCR0 configuration from state test
KVM: selftests: Drop manual XCR0 configuration from SEV smoke test
KVM: selftests: Ensure KVM supports AVX for SEV-ES VMSA FPU test

 .../selftests/kvm/include/x86_64/processor.h  |  5 ++
 .../selftests/kvm/lib/x86_64/processor.c      | 24 +++++++
 tools/testing/selftests/kvm/x86_64/amx_test.c | 23 ++-----
 .../testing/selftests/kvm/x86_64/cpuid_test.c | 67 ++++++++++++-------
 .../kvm/x86_64/cr4_cpuid_sync_test.c          | 53 +++++++++------
 .../selftests/kvm/x86_64/sev_smoke_test.c     | 19 ++----
 .../testing/selftests/kvm/x86_64/state_test.c |  5 --
 .../selftests/kvm/x86_64/xcr0_cpuid_test.c    | 11 ++-
 8 files changed, 122 insertions(+), 85 deletions(-)

base-commit: efbc6bd090f48ccf64f7a8dd5daea775821d57ec

Signature · 1 line
2.47.0.rc0.187.ge670bccf7e-goog