From: Frank Zhu KVM allows userspace to query MSR_IA32_PERF_CAPABILITIES through KVM_GET_MSRS even when PDCM is not exposed in KVM_GET_SUPPORTED_CPUID. However, vCPU accesses to the MSR fail without PDCM. Keep the feature MSR query, but skip its checks when KVM does not expose PDCM, allowing feature_msrs_test to continue checking the remaining feature MSRs. Signed-off-by: Frank Zhu Signed-off-by: Ewan Hai --- tools/testing/selftests/kvm/x86/feature_msrs_test.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/tools/testing/selftests/kvm/x86/feature_msrs_test.c b/tools/testing/selftests/kvm/x86/feature_msrs_test.c index 158550701771..9602e29bf9cc 100644 --- a/tools/testing/selftests/kvm/x86/feature_msrs_test.c +++ b/tools/testing/selftests/kvm/x86/feature_msrs_test.c @@ -54,6 +54,19 @@ static void test_feature_msr(u32 msr) if (is_kvm_controlled_msr(msr)) return; + /* + * KVM allows userspace to query MSR_IA32_PERF_CAPABILITIES as a + * feature MSR even if KVM doesn't expose PDCM, but vCPU accesses to + * the MSR will fail in that case. Skip the vCPU checks so that the + * remaining feature MSRs can be tested. + */ + if (msr == MSR_IA32_PERF_CAPABILITIES && + !kvm_cpu_has(X86_FEATURE_PDCM)) { + printf("KVM does not expose PDCM, skipping vCPU checks for " + "MSR_IA32_PERF_CAPABILITIES (0x%x).\n", msr); + return; + } + /* * More goofy behavior. KVM reports the host CPU's actual revision ID, * but initializes the vCPU's revision ID to an arbitrary value. -- 2.34.1