KVM: selftests: Test consistency of CPUID with num of gp counters
authorJinrong Liang <cloudliang@tencent.com>
Tue, 9 Jan 2024 23:02:38 +0000 (15:02 -0800)
committerSean Christopherson <seanjc@google.com>
Tue, 30 Jan 2024 23:29:38 +0000 (15:29 -0800)
commit7137cf751b9b14662adad61e35c236e141430aed
treef28bb1481a38693980097d7a053483887356ce5f
parent3e26b825f87ddfa610e069ff3f668b942d8642bb
KVM: selftests: Test consistency of CPUID with num of gp counters

Add a test to verify that KVM correctly emulates MSR-based accesses to
general purpose counters based on guest CPUID, e.g. that accesses to
non-existent counters #GP and accesses to existent counters succeed.

Note, for compatibility reasons, KVM does not emulate #GP when
MSR_P6_PERFCTR[0|1] is not present (writes should be dropped).

Co-developed-by: Like Xu <likexu@tencent.com>
Signed-off-by: Like Xu <likexu@tencent.com>
Signed-off-by: Jinrong Liang <cloudliang@tencent.com>
Co-developed-by: Sean Christopherson <seanjc@google.com>
Tested-by: Dapeng Mi <dapeng1.mi@linux.intel.com>
Link: https://lore.kernel.org/r/20240109230250.424295-19-seanjc@google.com
Signed-off-by: Sean Christopherson <seanjc@google.com>
tools/testing/selftests/kvm/x86_64/pmu_counters_test.c