All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sean Christopherson <seanjc@google.com>
To: Paolo Bonzini <pbonzini@redhat.com>
Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org,
	Sean Christopherson <seanjc@google.com>,
	Jim Mattson <jmattson@google.com>
Subject: [PATCH v2 05/42] KVM: selftests: Use kvm_cpu_has() for nested SVM checks
Date: Tue, 14 Jun 2022 20:06:30 +0000	[thread overview]
Message-ID: <20220614200707.3315957-6-seanjc@google.com> (raw)
In-Reply-To: <20220614200707.3315957-1-seanjc@google.com>

Use kvm_cpu_has() to check for nested SVM support, and drop the helpers
now that their functionality is trivial to implement.

No functional change intended.

Signed-off-by: Sean Christopherson <seanjc@google.com>
---
 .../testing/selftests/kvm/include/x86_64/svm_util.h |  2 --
 tools/testing/selftests/kvm/lib/x86_64/svm.c        | 13 -------------
 .../testing/selftests/kvm/x86_64/hyperv_svm_test.c  |  2 +-
 tools/testing/selftests/kvm/x86_64/smm_test.c       |  2 +-
 tools/testing/selftests/kvm/x86_64/state_test.c     |  2 +-
 .../testing/selftests/kvm/x86_64/svm_int_ctl_test.c |  2 +-
 .../kvm/x86_64/svm_nested_soft_inject_test.c        |  2 +-
 .../testing/selftests/kvm/x86_64/svm_vmcall_test.c  |  2 +-
 8 files changed, 6 insertions(+), 21 deletions(-)

diff --git a/tools/testing/selftests/kvm/include/x86_64/svm_util.h b/tools/testing/selftests/kvm/include/x86_64/svm_util.h
index 136ba6a5d027..f48806d26989 100644
--- a/tools/testing/selftests/kvm/include/x86_64/svm_util.h
+++ b/tools/testing/selftests/kvm/include/x86_64/svm_util.h
@@ -51,8 +51,6 @@ struct svm_test_data {
 struct svm_test_data *vcpu_alloc_svm(struct kvm_vm *vm, vm_vaddr_t *p_svm_gva);
 void generic_svm_setup(struct svm_test_data *svm, void *guest_rip, void *guest_rsp);
 void run_guest(struct vmcb *vmcb, uint64_t vmcb_gpa);
-bool nested_svm_supported(void);
-void nested_svm_check_supported(void);
 
 static inline bool cpu_has_svm(void)
 {
diff --git a/tools/testing/selftests/kvm/lib/x86_64/svm.c b/tools/testing/selftests/kvm/lib/x86_64/svm.c
index 37e9c0a923e0..6d445886e16c 100644
--- a/tools/testing/selftests/kvm/lib/x86_64/svm.c
+++ b/tools/testing/selftests/kvm/lib/x86_64/svm.c
@@ -164,19 +164,6 @@ void run_guest(struct vmcb *vmcb, uint64_t vmcb_gpa)
 		: "r15", "memory");
 }
 
-bool nested_svm_supported(void)
-{
-	struct kvm_cpuid_entry2 *entry =
-		kvm_get_supported_cpuid_entry(0x80000001);
-
-	return entry->ecx & CPUID_SVM;
-}
-
-void nested_svm_check_supported(void)
-{
-	TEST_REQUIRE(nested_svm_supported());
-}
-
 /*
  * Open SEV_DEV_PATH if available, otherwise exit the entire program.
  *
diff --git a/tools/testing/selftests/kvm/x86_64/hyperv_svm_test.c b/tools/testing/selftests/kvm/x86_64/hyperv_svm_test.c
index c5cd9835dbd6..ea507510a62f 100644
--- a/tools/testing/selftests/kvm/x86_64/hyperv_svm_test.c
+++ b/tools/testing/selftests/kvm/x86_64/hyperv_svm_test.c
@@ -127,7 +127,7 @@ int main(int argc, char *argv[])
 	struct ucall uc;
 	int stage;
 
-	TEST_REQUIRE(nested_svm_supported());
+	TEST_REQUIRE(kvm_cpu_has(X86_FEATURE_SVM));
 
 	/* Create VM */
 	vm = vm_create_with_one_vcpu(&vcpu, guest_code);
diff --git a/tools/testing/selftests/kvm/x86_64/smm_test.c b/tools/testing/selftests/kvm/x86_64/smm_test.c
index e89139ce68dd..6b8108bdcead 100644
--- a/tools/testing/selftests/kvm/x86_64/smm_test.c
+++ b/tools/testing/selftests/kvm/x86_64/smm_test.c
@@ -154,7 +154,7 @@ int main(int argc, char *argv[])
 	vcpu_set_msr(vcpu, MSR_IA32_SMBASE, SMRAM_GPA);
 
 	if (kvm_check_cap(KVM_CAP_NESTED_STATE)) {
-		if (nested_svm_supported())
+		if (kvm_cpu_has(X86_FEATURE_SVM))
 			vcpu_alloc_svm(vm, &nested_gva);
 		else if (nested_vmx_supported())
 			vcpu_alloc_vmx(vm, &nested_gva);
diff --git a/tools/testing/selftests/kvm/x86_64/state_test.c b/tools/testing/selftests/kvm/x86_64/state_test.c
index ea878c963065..fe110ce31106 100644
--- a/tools/testing/selftests/kvm/x86_64/state_test.c
+++ b/tools/testing/selftests/kvm/x86_64/state_test.c
@@ -170,7 +170,7 @@ int main(int argc, char *argv[])
 	vcpu_regs_get(vcpu, &regs1);
 
 	if (kvm_check_cap(KVM_CAP_NESTED_STATE)) {
-		if (nested_svm_supported())
+		if (kvm_cpu_has(X86_FEATURE_SVM))
 			vcpu_alloc_svm(vm, &nested_gva);
 		else if (nested_vmx_supported())
 			vcpu_alloc_vmx(vm, &nested_gva);
diff --git a/tools/testing/selftests/kvm/x86_64/svm_int_ctl_test.c b/tools/testing/selftests/kvm/x86_64/svm_int_ctl_test.c
index 9c68a47b69e1..dc32c347281a 100644
--- a/tools/testing/selftests/kvm/x86_64/svm_int_ctl_test.c
+++ b/tools/testing/selftests/kvm/x86_64/svm_int_ctl_test.c
@@ -90,7 +90,7 @@ int main(int argc, char *argv[])
 	struct kvm_vm *vm;
 	struct ucall uc;
 
-	nested_svm_check_supported();
+	TEST_REQUIRE(kvm_cpu_has(X86_FEATURE_SVM));
 
 	vm = vm_create_with_one_vcpu(&vcpu, l1_guest_code);
 
diff --git a/tools/testing/selftests/kvm/x86_64/svm_nested_soft_inject_test.c b/tools/testing/selftests/kvm/x86_64/svm_nested_soft_inject_test.c
index 051f70167074..3c21b997fe3a 100644
--- a/tools/testing/selftests/kvm/x86_64/svm_nested_soft_inject_test.c
+++ b/tools/testing/selftests/kvm/x86_64/svm_nested_soft_inject_test.c
@@ -200,7 +200,7 @@ int main(int argc, char *argv[])
 	/* Tell stdout not to buffer its content */
 	setbuf(stdout, NULL);
 
-	nested_svm_check_supported();
+	TEST_REQUIRE(kvm_cpu_has(X86_FEATURE_SVM));
 
 	cpuid = kvm_get_supported_cpuid_entry(0x8000000a);
 	TEST_ASSERT(cpuid->edx & CPUID_NRIPS,
diff --git a/tools/testing/selftests/kvm/x86_64/svm_vmcall_test.c b/tools/testing/selftests/kvm/x86_64/svm_vmcall_test.c
index e6d7191866a5..46ce1bda6599 100644
--- a/tools/testing/selftests/kvm/x86_64/svm_vmcall_test.c
+++ b/tools/testing/selftests/kvm/x86_64/svm_vmcall_test.c
@@ -39,7 +39,7 @@ int main(int argc, char *argv[])
 	vm_vaddr_t svm_gva;
 	struct kvm_vm *vm;
 
-	nested_svm_check_supported();
+	TEST_REQUIRE(kvm_cpu_has(X86_FEATURE_SVM));
 
 	vm = vm_create_with_one_vcpu(&vcpu, l1_guest_code);
 
-- 
2.36.1.476.g0c4daa206d-goog


  parent reply	other threads:[~2022-06-14 20:07 UTC|newest]

Thread overview: 43+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-14 20:06 [PATCH v2 00/42] KVM: selftests: Overhaul Part II - CPUID Sean Christopherson
2022-06-14 20:06 ` [PATCH v2 01/42] KVM: selftests: Set KVM's supported CPUID as vCPU's CPUID during recreate Sean Christopherson
2022-06-14 20:06 ` [PATCH v2 02/42] KVM: sefltests: Use CPUID_XSAVE and CPUID_OSXAVE instead of X86_FEATURE_* Sean Christopherson
2022-06-14 20:06 ` [PATCH v2 03/42] KVM: selftests: Add framework to query KVM CPUID bits Sean Christopherson
2022-06-14 20:06 ` [PATCH v2 04/42] KVM: selftests: Use kvm_cpu_has() in the SEV migration test Sean Christopherson
2022-06-14 20:06 ` Sean Christopherson [this message]
2022-06-14 20:06 ` [PATCH v2 06/42] KVM: selftests: Use kvm_cpu_has() for nested VMX checks Sean Christopherson
2022-06-14 20:06 ` [PATCH v2 07/42] KVM: selftests: Use kvm_cpu_has() to query PDCM in PMU selftest Sean Christopherson
2022-06-14 20:06 ` [PATCH v2 08/42] KVM: selftests: Drop redundant vcpu_set_cpuid() from " Sean Christopherson
2022-06-14 20:06 ` [PATCH v2 09/42] KVM: selftests: Use kvm_cpu_has() for XSAVES in XSS MSR test Sean Christopherson
2022-06-14 20:06 ` [PATCH v2 10/42] KVM: selftests: Check for _both_ XTILE data and cfg in AMX test Sean Christopherson
2022-06-14 20:06 ` [PATCH v2 11/42] KVM: selftests: Use kvm_cpu_has() " Sean Christopherson
2022-06-14 20:06 ` [PATCH v2 12/42] KVM: selftests: Use kvm_cpu_has() for XSAVE in cr4_cpuid_sync_test Sean Christopherson
2022-06-14 20:06 ` [PATCH v2 13/42] KVM: selftests: Remove the obsolete/dead MMU role test Sean Christopherson
2022-06-14 20:06 ` [PATCH v2 14/42] KVM: selftests: Use kvm_cpu_has() for KVM's PV steal time Sean Christopherson
2022-06-14 20:06 ` [PATCH v2 15/42] KVM: selftests: Use kvm_cpu_has() for nSVM soft INT injection test Sean Christopherson
2022-06-14 20:06 ` [PATCH v2 16/42] KVM: selftests: Verify that kvm_cpuid2.entries layout is unchanged by KVM Sean Christopherson
2022-06-14 20:06 ` [PATCH v2 17/42] KVM: selftests: Split out kvm_cpuid2_size() from allocate_kvm_cpuid2() Sean Christopherson
2022-06-14 20:06 ` [PATCH v2 18/42] KVM: selftests: Cache CPUID in struct kvm_vcpu Sean Christopherson
2022-06-14 20:06 ` [PATCH v2 19/42] KVM: selftests: Don't use a static local in vcpu_get_supported_hv_cpuid() Sean Christopherson
2022-06-14 20:06 ` [PATCH v2 20/42] KVM: selftests: Rename and tweak get_cpuid() to get_cpuid_entry() Sean Christopherson
2022-06-14 20:06 ` [PATCH v2 21/42] KVM: selftests: Use get_cpuid_entry() in kvm_get_supported_cpuid_index() Sean Christopherson
2022-06-14 20:06 ` [PATCH v2 22/42] KVM: selftests: Add helpers to get and modify a vCPU's CPUID entries Sean Christopherson
2022-06-14 20:06 ` [PATCH v2 23/42] KVM: selftests: Use vm->pa_bits to generate reserved PA bits Sean Christopherson
2022-06-14 20:06 ` [PATCH v2 24/42] KVM: selftests: Add and use helper to set vCPU's CPUID maxphyaddr Sean Christopherson
2022-06-14 20:06 ` [PATCH v2 25/42] KVM: selftests: Use vcpu_get_cpuid_entry() in PV features test (sort of) Sean Christopherson
2022-06-14 20:06 ` [PATCH v2 26/42] KVM: selftests: Use vCPU's CPUID directly in Hyper-V test Sean Christopherson
2022-06-14 20:06 ` [PATCH v2 27/42] KVM: selftests: Use vcpu_get_cpuid_entry() in CPUID test Sean Christopherson
2022-06-14 20:06 ` [PATCH v2 28/42] KVM: selftests: Use vcpu_{set,clear}_cpuid_feature() in nVMX state test Sean Christopherson
2022-06-14 20:06 ` [PATCH v2 29/42] KVM: selftests: Use vcpu_clear_cpuid_feature() to clear x2APIC Sean Christopherson
2022-06-14 20:06 ` [PATCH v2 30/42] KVM: selftests: Make get_supported_cpuid() returns "const" Sean Christopherson
2022-06-14 20:06 ` [PATCH v2 31/42] KVM: selftests: Set input function/index in raw CPUID helper(s) Sean Christopherson
2022-06-14 20:06 ` [PATCH v2 32/42] KVM: selftests: Add this_cpu_has() to query X86_FEATURE_* via cpuid() Sean Christopherson
2022-06-14 20:06 ` [PATCH v2 33/42] KVM: selftests: Use this_cpu_has() in CR4/CPUID sync test Sean Christopherson
2022-06-14 20:06 ` [PATCH v2 34/42] KVM: selftests: Use this_cpu_has() to detect SVM support in L1 Sean Christopherson
2022-06-14 20:07 ` [PATCH v2 35/42] KVM: selftests: Drop unnecessary use of kvm_get_supported_cpuid_index() Sean Christopherson
2022-06-14 20:07 ` [PATCH v2 36/42] KVM: selftests: Rename kvm_get_supported_cpuid_index() to __..._entry() Sean Christopherson
2022-06-14 20:07 ` [PATCH v2 37/42] KVM: selftests: Inline "get max CPUID leaf" helpers Sean Christopherson
2022-06-14 20:07 ` [PATCH v2 38/42] KVM: selftests: Check KVM's supported CPUID, not host CPUID, for XFD Sean Christopherson
2022-06-14 20:07 ` [PATCH v2 39/42] KVM: selftests: Skip AMX test if ARCH_REQ_XCOMP_GUEST_PERM isn't supported Sean Christopherson
2022-06-14 20:07 ` [PATCH v2 40/42] KVM: selftests: Clean up requirements for XFD-aware XSAVE features Sean Christopherson
2022-06-14 20:07 ` [PATCH v2 41/42] KVM: selftests: Use the common cpuid() helper in cpu_vendor_string_is() Sean Christopherson
2022-06-14 20:07 ` [PATCH v2 42/42] KVM: selftests: Drop unused SVM_CPUID_FUNC macro 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=20220614200707.3315957-6-seanjc@google.com \
    --to=seanjc@google.com \
    --cc=jmattson@google.com \
    --cc=kvm@vger.kernel.org \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.