From: Sean Christopherson <seanjc@google.com>
To: Paolo Bonzini <pbonzini@redhat.com>
Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org,
Lei Wang <lei4.wang@intel.com>,
Sean Christopherson <seanjc@google.com>
Subject: [PATCH v2 4/4] KVM: selftests: Do kvm_cpu_has() checks before creating VM+vCPU
Date: Mon, 28 Nov 2022 22:57:35 +0000 [thread overview]
Message-ID: <20221128225735.3291648-5-seanjc@google.com> (raw)
In-Reply-To: <20221128225735.3291648-1-seanjc@google.com>
Move the AMX test's kvm_cpu_has() checks before creating the VM+vCPU,
there are no dependencies between the two operations. Opportunistically
add a comment to call out that enabling off-by-default XSAVE-managed
features must be done before KVM_GET_SUPPORTED_CPUID is cached.
Signed-off-by: Sean Christopherson <seanjc@google.com>
---
tools/testing/selftests/kvm/x86_64/amx_test.c | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/tools/testing/selftests/kvm/x86_64/amx_test.c b/tools/testing/selftests/kvm/x86_64/amx_test.c
index 1256c7faadd3..bd72c6eb3b67 100644
--- a/tools/testing/selftests/kvm/x86_64/amx_test.c
+++ b/tools/testing/selftests/kvm/x86_64/amx_test.c
@@ -249,17 +249,21 @@ int main(int argc, char *argv[])
u32 amx_offset;
int stage, ret;
+ /*
+ * Note, all off-by-default features must be enabled before anything
+ * caches KVM_GET_SUPPORTED_CPUID, e.g. before using kvm_cpu_has().
+ */
vm_xsave_require_permission(XSTATE_XTILE_DATA_BIT);
- /* Create VM */
- vm = vm_create_with_one_vcpu(&vcpu, guest_code);
-
TEST_REQUIRE(kvm_cpu_has(X86_FEATURE_XFD));
TEST_REQUIRE(kvm_cpu_has(X86_FEATURE_XSAVE));
TEST_REQUIRE(kvm_cpu_has(X86_FEATURE_AMX_TILE));
TEST_REQUIRE(kvm_cpu_has(X86_FEATURE_XTILECFG));
TEST_REQUIRE(kvm_cpu_has(X86_FEATURE_XTILEDATA));
+ /* Create VM */
+ vm = vm_create_with_one_vcpu(&vcpu, guest_code);
+
TEST_ASSERT(kvm_cpu_has_p(X86_PROPERTY_XSTATE_MAX_SIZE),
"KVM should enumerate max XSAVE size when XSAVE is supported");
xsave_restore_size = kvm_cpu_property(X86_PROPERTY_XSTATE_MAX_SIZE);
--
2.38.1.584.g0f3c55d4c2-goog
next prev parent reply other threads:[~2022-11-28 22:58 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-28 22:57 [PATCH v2 0/4] KVM: selftests: AMX test fix and cleanups Sean Christopherson
2022-11-28 22:57 ` [PATCH v2 1/4] KVM: selftests: Move XFD CPUID checking out of __vm_xsave_require_permission() Sean Christopherson
2022-11-28 22:57 ` [PATCH v2 2/4] KVM: selftests: Move __vm_xsave_require_permission() below CPUID helpers Sean Christopherson
2022-11-28 22:57 ` [PATCH v2 3/4] KVM: selftests: Disallow "get supported CPUID" before REQ_XCOMP_GUEST_PERM Sean Christopherson
2022-11-28 22:57 ` Sean Christopherson [this message]
2022-11-29 1:58 ` [PATCH v2 0/4] KVM: selftests: AMX test fix and cleanups Wang, Lei
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=20221128225735.3291648-5-seanjc@google.com \
--to=seanjc@google.com \
--cc=kvm@vger.kernel.org \
--cc=lei4.wang@intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=pbonzini@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®