Commit ea129d22 authored by Sean Christopherson's avatar Sean Christopherson

KVM: selftests: Use kvm_cpu_has() to query PDCM in PMU selftest

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: default avatarSean Christopherson <seanjc@google.com>
Link: https://lore.kernel.org/r/20220614200707.3315957-8-seanjc@google.com
parent 1ecbb337
......@@ -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)
......
......@@ -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");
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment