]> git.baikalelectronics.ru Git - kernel.git/commitdiff
KVM: selftests: Use kvm_cpu_has() to query PDCM in PMU selftest
authorSean Christopherson <seanjc@google.com>
Tue, 14 Jun 2022 20:06:32 +0000 (20:06 +0000)
committerSean Christopherson <seanjc@google.com>
Thu, 14 Jul 2022 01:14:10 +0000 (18:14 -0700)
Use kvm_cpu_has() in the PMU test to query PDCM support instead of open
coding equivalent functionality using kvm_get_supported_cpuid_index().

No functional change intended.

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

index 57fefd9e8ae97153e223b2cca740b82315f410f7..ad10c87878922ef951e1476c91207ba1fb193535 100644 (file)
@@ -81,6 +81,7 @@ struct kvm_x86_cpu_feature {
 #define        X86_FEATURE_MWAIT               KVM_X86_CPU_FEATURE(0x1, 0, ECX, 3)
 #define        X86_FEATURE_VMX                 KVM_X86_CPU_FEATURE(0x1, 0, ECX, 5)
 #define        X86_FEATURE_SMX                 KVM_X86_CPU_FEATURE(0x1, 0, ECX, 6)
+#define        X86_FEATURE_PDCM                KVM_X86_CPU_FEATURE(0x1, 0, ECX, 15)
 #define        X86_FEATURE_PCID                KVM_X86_CPU_FEATURE(0x1, 0, ECX, 17)
 #define        X86_FEATURE_MOVBE               KVM_X86_CPU_FEATURE(0x1, 0, ECX, 22)
 #define        X86_FEATURE_TSC_DEADLINE_TIMER  KVM_X86_CPU_FEATURE(0x1, 0, ECX, 24)
index eb592fae44efe549909bd174aa3596a9d143b54b..667d48e8c1e0fd690ea0bbad0b1ef30af910e720 100644 (file)
@@ -17,7 +17,6 @@
 #include "kvm_util.h"
 #include "vmx.h"
 
-#define X86_FEATURE_PDCM       (1<<15)
 #define PMU_CAP_FW_WRITES      (1ULL << 13)
 #define PMU_CAP_LBR_FMT                0x3f
 
@@ -55,7 +54,6 @@ static void guest_code(void)
 int main(int argc, char *argv[])
 {
        struct kvm_cpuid2 *cpuid;
-       struct kvm_cpuid_entry2 *entry_1_0;
        struct kvm_cpuid_entry2 *entry_a_0;
        struct kvm_vm *vm;
        struct kvm_vcpu *vcpu;
@@ -70,11 +68,10 @@ int main(int argc, char *argv[])
        vm = vm_create_with_one_vcpu(&vcpu, guest_code);
        cpuid = kvm_get_supported_cpuid();
 
-       TEST_REQUIRE(kvm_get_cpuid_max_basic() >= 0xa);
+       TEST_REQUIRE(kvm_cpu_has(X86_FEATURE_PDCM));
 
-       entry_1_0 = kvm_get_supported_cpuid_index(1, 0);
+       TEST_REQUIRE(kvm_get_cpuid_max_basic() >= 0xa);
        entry_a_0 = kvm_get_supported_cpuid_index(0xa, 0);
-       TEST_REQUIRE(entry_1_0->ecx & X86_FEATURE_PDCM);
 
        eax.full = entry_a_0->eax;
        __TEST_REQUIRE(eax.split.version_id, "PMU is not supported by the vCPU");