]> git.baikalelectronics.ru Git - kernel.git/commitdiff
KVM: selftests: Use kvm_cpu_has() for nested SVM checks
authorSean Christopherson <seanjc@google.com>
Tue, 14 Jun 2022 20:06:30 +0000 (20:06 +0000)
committerSean Christopherson <seanjc@google.com>
Thu, 14 Jul 2022 01:14:10 +0000 (18:14 -0700)
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>
Link: https://lore.kernel.org/r/20220614200707.3315957-6-seanjc@google.com
tools/testing/selftests/kvm/include/x86_64/svm_util.h
tools/testing/selftests/kvm/lib/x86_64/svm.c
tools/testing/selftests/kvm/x86_64/hyperv_svm_test.c
tools/testing/selftests/kvm/x86_64/smm_test.c
tools/testing/selftests/kvm/x86_64/state_test.c
tools/testing/selftests/kvm/x86_64/svm_int_ctl_test.c
tools/testing/selftests/kvm/x86_64/svm_nested_soft_inject_test.c
tools/testing/selftests/kvm/x86_64/svm_vmcall_test.c

index 136ba6a5d0275cd4b8d7fda014b81b55bc5cde54..f48806d2698920ea6fa7d00697773360eb576627 100644 (file)
@@ -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)
 {
index 37e9c0a923e08de8e823ab46f65fed3cf2e15b45..6d445886e16c58a5771a8ba4ac0af2e62baf3731 100644 (file)
@@ -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.
  *
index b7dc243ab8d59b21f5b736da65c7928f2575e237..a380ad7bb9b345bec765f71979250245cc3a57be 100644 (file)
@@ -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);
index d29aefb4d7d32ab2a4c37d35c939d2dbccf2703d..fde3fe925686fbe0041e901ff4f3eac4fb2eefa5 100644 (file)
@@ -154,7 +154,7 @@ int main(int argc, char *argv[])
        vcpu_set_msr(vcpu, MSR_IA32_SMBASE, SMRAM_GPA);
 
        if (kvm_has_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);
index 3f1a13f28115aa2678354b93701125ca5021ab58..ae01d32624ecfae14f1bb94adc3dcf3f3f8ed612 100644 (file)
@@ -170,7 +170,7 @@ int main(int argc, char *argv[])
        vcpu_regs_get(vcpu, &regs1);
 
        if (kvm_has_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);
index d978d1697f5a3f8a1757cc3287100768fba46440..4a07ba227b9954cbe99dc10b84bea96e78e80f22 100644 (file)
@@ -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);
 
index bf7eda7722fe0571b5816ec3981d7e94c7684760..2cc09ab41570ef1d639da0a42adddc6f9e00435d 100644 (file)
@@ -199,7 +199,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,
index d53b1f7abb56a22c509948a853db390df975c25a..c3ac45df748325151aae1f7c27e994be924c171c 100644 (file)
@@ -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);