Skip to content

Commit 89f8869

Browse files
committed
KVM: selftests: Ensure KVM supports AVX for SEV-ES VMSA FPU test
Verify that KVM's supported XCR0 includes AVX (and earlier features) when running the SEV-ES VMSA XSAVE test. In practice, the issue will likely never pop up, since KVM support for AVX predates KVM support for SEV-ES, but checking for KVM support makes the requirement more obvious. Reviewed-by: Vitaly Kuznetsov <vkuznets@redhat.com> Link: https://lore.kernel.org/r/20241003234337.273364-12-seanjc@google.com Signed-off-by: Sean Christopherson <seanjc@google.com>
1 parent 3c4c128 commit 89f8869

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

tools/testing/selftests/kvm/x86_64/sev_smoke_test.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,8 @@ static void test_sev_es_shutdown(void)
181181

182182
int main(int argc, char *argv[])
183183
{
184+
const u64 xf_mask = XFEATURE_MASK_X87_AVX;
185+
184186
TEST_REQUIRE(kvm_cpu_has(X86_FEATURE_SEV));
185187

186188
test_sev(guest_sev_code, SEV_POLICY_NO_DBG);
@@ -193,7 +195,7 @@ int main(int argc, char *argv[])
193195
test_sev_es_shutdown();
194196

195197
if (kvm_has_cap(KVM_CAP_XCRS) &&
196-
(xgetbv(0) & XFEATURE_MASK_X87_AVX) == XFEATURE_MASK_X87_AVX) {
198+
(xgetbv(0) & kvm_cpu_supported_xcr0() & xf_mask) == xf_mask) {
197199
test_sync_vmsa(0);
198200
test_sync_vmsa(SEV_POLICY_NO_DBG);
199201
}

0 commit comments

Comments
 (0)