mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Sean Christopherson <seanjc@google.com>
To: Sean Christopherson <seanjc@google.com>,
	Paolo Bonzini <pbonzini@redhat.com>
Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org,
	 Vitaly Kuznetsov <vkuznets@redhat.com>
Subject: [PATCH 10/11] KVM: selftests: Drop manual XCR0 configuration from SEV smoke test
Date: Thu,  3 Oct 2024 16:43:36 -0700	[thread overview]
Message-ID: <20241003234337.273364-11-seanjc@google.com> (raw)
In-Reply-To: <20241003234337.273364-1-seanjc@google.com>

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.

Signed-off-by: Sean Christopherson <seanjc@google.com>
---
 .../testing/selftests/kvm/x86_64/sev_smoke_test.c | 15 ++-------------
 1 file changed, 2 insertions(+), 13 deletions(-)

diff --git a/tools/testing/selftests/kvm/x86_64/sev_smoke_test.c b/tools/testing/selftests/kvm/x86_64/sev_smoke_test.c
index 2e9197eb1652..965fc362dee3 100644
--- a/tools/testing/selftests/kvm/x86_64/sev_smoke_test.c
+++ b/tools/testing/selftests/kvm/x86_64/sev_smoke_test.c
@@ -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"
-- 
2.47.0.rc0.187.ge670bccf7e-goog


  parent reply	other threads:[~2024-10-03 23:43 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-10-03 23:43 [PATCH 00/11] KVM: selftests: AVX support + fixes Sean Christopherson
2024-10-03 23:43 ` [PATCH 01/11] KVM: selftests: Fix out-of-bounds reads in CPUID test's array lookups Sean Christopherson
2024-10-04  8:22   ` Vitaly Kuznetsov
2024-10-03 23:43 ` [PATCH 02/11] KVM: selftests: Precisely mask off dynamic fields in CPUID test Sean Christopherson
2024-10-04  9:02   ` Vitaly Kuznetsov
2024-10-03 23:43 ` [PATCH 03/11] KVM: selftests: Mask off OSPKE and OSXSAVE when comparing CPUID entries Sean Christopherson
2024-10-04  9:02   ` Vitaly Kuznetsov
2024-10-03 23:43 ` [PATCH 04/11] KVM: selftests: Rework OSXSAVE CR4=>CPUID test to play nice with AVX insns Sean Christopherson
2024-10-04  9:02   ` Vitaly Kuznetsov
2024-10-03 23:43 ` [PATCH 05/11] KVM: selftests: Configure XCR0 to max supported value by default Sean Christopherson
2024-10-04  9:01   ` Vitaly Kuznetsov
2024-10-04 13:35     ` Sean Christopherson
2024-10-03 23:43 ` [PATCH 06/11] KVM: selftests: Verify XCR0 can be "downgraded" and "upgraded" Sean Christopherson
2024-10-04  9:04   ` Vitaly Kuznetsov
2024-10-03 23:43 ` [PATCH 07/11] KVM: selftests: Drop manual CR4.OSXSAVE enabling from CR4/CPUID sync test Sean Christopherson
2024-10-04  9:05   ` Vitaly Kuznetsov
2024-10-03 23:43 ` [PATCH 08/11] KVM: selftests: Drop manual XCR0 configuration from AMX test Sean Christopherson
2024-10-04  9:09   ` Vitaly Kuznetsov
2024-10-03 23:43 ` [PATCH 09/11] KVM: selftests: Drop manual XCR0 configuration from state test Sean Christopherson
2024-10-04  9:10   ` Vitaly Kuznetsov
2024-10-03 23:43 ` Sean Christopherson [this message]
2024-10-03 23:43 ` [PATCH 11/11] KVM: selftests: Ensure KVM supports AVX for SEV-ES VMSA FPU test Sean Christopherson
2024-10-04  9:14   ` Vitaly Kuznetsov
2024-10-20 11:28 ` [PATCH 00/11] KVM: selftests: AVX support + fixes Paolo Bonzini
2024-10-31 19:51 ` Sean Christopherson
2024-11-01 19:31   ` Sean Christopherson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20241003234337.273364-11-seanjc@google.com \
    --to=seanjc@google.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pbonzini@redhat.com \
    --cc=vkuznets@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®