Skip to content

Commit 5a1bde4

Browse files
sandip4nbonzini
authored andcommitted
kvm: x86/cpuid: Only provide CPUID leaf 0xA if host has architectural PMU
On some x86 processors, CPUID leaf 0xA provides information on Architectural Performance Monitoring features. It advertises a PMU version which Qemu uses to determine the availability of additional MSRs to manage the PMCs. Upon receiving a KVM_GET_SUPPORTED_CPUID ioctl request for the same, the kernel constructs return values based on the x86_pmu_capability irrespective of the vendor. This leaf and the additional MSRs are not supported on AMD and Hygon processors. If AMD PerfMonV2 is detected, the PMU version is set to 2 and guest startup breaks because of an attempt to access a non-existent MSR. Return zeros to avoid this. Fixes: a6c06ed ("KVM: Expose the architectural performance monitoring CPUID leaf") Reported-by: Vasant Hegde <vasant.hegde@amd.com> Signed-off-by: Sandipan Das <sandipan.das@amd.com> Message-Id: <3fef83d9c2b2f7516e8ff50d60851f29a4bcb716.1651058600.git.sandipan.das@amd.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
1 parent 5eb8493 commit 5a1bde4

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

arch/x86/kvm/cpuid.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -887,6 +887,11 @@ static inline int __do_cpuid_func(struct kvm_cpuid_array *array, u32 function)
887887
union cpuid10_eax eax;
888888
union cpuid10_edx edx;
889889

890+
if (!static_cpu_has(X86_FEATURE_ARCH_PERFMON)) {
891+
entry->eax = entry->ebx = entry->ecx = entry->edx = 0;
892+
break;
893+
}
894+
890895
perf_get_x86_pmu_capability(&cap);
891896

892897
/*

0 commit comments

Comments
 (0)