Skip to content

Commit 3c4c128

Browse files
committed
KVM: selftests: Drop manual XCR0 configuration from SEV smoke test
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>
1 parent 2843909 commit 3c4c128

File tree

1 file changed

+2
-13
lines changed

1 file changed

+2
-13
lines changed

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

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ static void guest_sev_code(void)
4141
/* Stash state passed via VMSA before any compiled code runs. */
4242
extern void guest_code_xsave(void);
4343
asm("guest_code_xsave:\n"
44-
"mov $-1, %eax\n"
45-
"mov $-1, %edx\n"
44+
"mov $" __stringify(XFEATURE_MASK_X87_AVX) ", %eax\n"
45+
"xor %edx, %edx\n"
4646
"xsave (%rdi)\n"
4747
"jmp guest_sev_es_code");
4848

@@ -70,12 +70,6 @@ static void test_sync_vmsa(uint32_t policy)
7070

7171
double x87val = M_PI;
7272
struct kvm_xsave __attribute__((aligned(64))) xsave = { 0 };
73-
struct kvm_sregs sregs;
74-
struct kvm_xcrs xcrs = {
75-
.nr_xcrs = 1,
76-
.xcrs[0].xcr = 0,
77-
.xcrs[0].value = XFEATURE_MASK_X87_AVX,
78-
};
7973

8074
vm = vm_sev_create_with_one_vcpu(KVM_X86_SEV_ES_VM, guest_code_xsave, &vcpu);
8175
gva = vm_vaddr_alloc_shared(vm, PAGE_SIZE, KVM_UTIL_MIN_VADDR,
@@ -84,11 +78,6 @@ static void test_sync_vmsa(uint32_t policy)
8478

8579
vcpu_args_set(vcpu, 1, gva);
8680

87-
vcpu_sregs_get(vcpu, &sregs);
88-
sregs.cr4 |= X86_CR4_OSFXSR | X86_CR4_OSXSAVE;
89-
vcpu_sregs_set(vcpu, &sregs);
90-
91-
vcpu_xcrs_set(vcpu, &xcrs);
9281
asm("fninit\n"
9382
"vpcmpeqb %%ymm4, %%ymm4, %%ymm4\n"
9483
"fldl %3\n"

0 commit comments

Comments
 (0)