]> git.baikalelectronics.ru Git - kernel.git/commitdiff
KVM: selftests: Use this_cpu_has() to detect SVM support in L1
authorSean Christopherson <seanjc@google.com>
Tue, 14 Jun 2022 20:06:59 +0000 (20:06 +0000)
committerSean Christopherson <seanjc@google.com>
Thu, 14 Jul 2022 01:14:22 +0000 (18:14 -0700)
Replace an evil open coded instance of querying CPUID from L1 with
this_cpu_has(X86_FEATURE_SVM).

No functional change intended.

Signed-off-by: Sean Christopherson <seanjc@google.com>
Link: https://lore.kernel.org/r/20220614200707.3315957-35-seanjc@google.com
tools/testing/selftests/kvm/include/x86_64/svm_util.h
tools/testing/selftests/kvm/x86_64/smm_test.c
tools/testing/selftests/kvm/x86_64/state_test.c

index f48806d2698920ea6fa7d00697773360eb576627..a339b537a57581f6d7364e81bd6e8bd2e4c787af 100644 (file)
@@ -13,9 +13,6 @@
 #include "svm.h"
 #include "processor.h"
 
-#define CPUID_SVM_BIT          2
-#define CPUID_SVM              BIT_ULL(CPUID_SVM_BIT)
-
 #define SVM_EXIT_EXCP_BASE     0x040
 #define SVM_EXIT_HLT           0x078
 #define SVM_EXIT_MSR           0x07c
@@ -52,16 +49,6 @@ 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);
 
-static inline bool cpu_has_svm(void)
-{
-       u32 eax = 0x80000001, ecx;
-
-       asm("cpuid" :
-           "=a" (eax), "=c" (ecx) : "0" (eax) : "ebx", "edx");
-
-       return ecx & CPUID_SVM;
-}
-
 int open_sev_dev_path_or_exit(void);
 
 #endif /* SELFTEST_KVM_SVM_UTILS_H */
index 17bb2397ea383355cf5ea384857e0abd16173d1a..1f136a81858e5df0903865d8364869edbaf9ba39 100644 (file)
@@ -83,7 +83,7 @@ static void guest_code(void *arg)
        sync_with_host(4);
 
        if (arg) {
-               if (cpu_has_svm()) {
+               if (this_cpu_has(X86_FEATURE_SVM)) {
                        generic_svm_setup(svm, l2_guest_code,
                                          &l2_guest_stack[L2_GUEST_STACK_SIZE]);
                } else {
@@ -99,7 +99,7 @@ static void guest_code(void *arg)
 
                sync_with_host(7);
 
-               if (cpu_has_svm()) {
+               if (this_cpu_has(X86_FEATURE_SVM)) {
                        run_guest(svm->vmcb, svm->vmcb_gpa);
                        run_guest(svm->vmcb, svm->vmcb_gpa);
                } else {
index 8ab81a3b561f58c708bc5737a8bd1bdd380b5ca0..ea578971fb9f9278893ed115a63dbfa417979727 100644 (file)
@@ -142,7 +142,7 @@ static void __attribute__((__flatten__)) guest_code(void *arg)
        GUEST_SYNC(2);
 
        if (arg) {
-               if (cpu_has_svm())
+               if (this_cpu_has(X86_FEATURE_SVM))
                        svm_l1_guest_code(arg);
                else
                        vmx_l1_guest_code(arg);