]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
KVM: selftests: Drop manual XCR0 configuration from SEV smoke test
authorSean Christopherson <seanjc@google.com>
Thu, 3 Oct 2024 23:43:36 +0000 (16:43 -0700)
committerSean Christopherson <seanjc@google.com>
Fri, 1 Nov 2024 16:26:36 +0000 (09:26 -0700)
Now that CR4.OSXSAVE and XCR0 are setup by default, drop the manual
enabling from the SEV smoke test that validates FPU state can be
transferred into the VMSA.

In guest_code_xsave(), explicitly set the Requested-Feature Bitmask (RFBM)
to exactly XFEATURE_MASK_X87_AVX instead of relying on the host side of
things to enable only X87_AVX features in guest XCR0.  I.e. match the RFBM
for the host XSAVE.

Link: https://lore.kernel.org/r/20241003234337.273364-11-seanjc@google.com
Signed-off-by: Sean Christopherson <seanjc@google.com>
tools/testing/selftests/kvm/x86_64/sev_smoke_test.c

index 2e9197eb16525136858a7a399e591d19ba19fccf..965fc362dee3df9bd954fae9abbaf5e910205182 100644 (file)
@@ -41,8 +41,8 @@ static void guest_sev_code(void)
 /* Stash state passed via VMSA before any compiled code runs.  */
 extern void guest_code_xsave(void);
 asm("guest_code_xsave:\n"
-    "mov $-1, %eax\n"
-    "mov $-1, %edx\n"
+    "mov $" __stringify(XFEATURE_MASK_X87_AVX) ", %eax\n"
+    "xor %edx, %edx\n"
     "xsave (%rdi)\n"
     "jmp guest_sev_es_code");
 
@@ -70,12 +70,6 @@ static void test_sync_vmsa(uint32_t policy)
 
        double x87val = M_PI;
        struct kvm_xsave __attribute__((aligned(64))) xsave = { 0 };
-       struct kvm_sregs sregs;
-       struct kvm_xcrs xcrs = {
-               .nr_xcrs = 1,
-               .xcrs[0].xcr = 0,
-               .xcrs[0].value = XFEATURE_MASK_X87_AVX,
-       };
 
        vm = vm_sev_create_with_one_vcpu(KVM_X86_SEV_ES_VM, guest_code_xsave, &vcpu);
        gva = vm_vaddr_alloc_shared(vm, PAGE_SIZE, KVM_UTIL_MIN_VADDR,
@@ -84,11 +78,6 @@ static void test_sync_vmsa(uint32_t policy)
 
        vcpu_args_set(vcpu, 1, gva);
 
-       vcpu_sregs_get(vcpu, &sregs);
-       sregs.cr4 |= X86_CR4_OSFXSR | X86_CR4_OSXSAVE;
-       vcpu_sregs_set(vcpu, &sregs);
-
-       vcpu_xcrs_set(vcpu, &xcrs);
        asm("fninit\n"
            "vpcmpeqb %%ymm4, %%ymm4, %%ymm4\n"
            "fldl %3\n"