]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
KVM: x86: Explicitly zero EAX and EBX when PERFMON_V2 isn't supported by KVM
authorXiaoyao Li <xiaoyao.li@intel.com>
Tue, 4 Mar 2025 08:23:14 +0000 (03:23 -0500)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 13 Mar 2025 12:02:14 +0000 (13:02 +0100)
commitb33b35b8bb676cb40eff1d1ee9516a7773301dc6
treedbd9b1661151fccd1ab591424ae193ac9b852af5
parent9eb6f272a6382c18b78983e0f50b5ae2a02646d6
KVM: x86: Explicitly zero EAX and EBX when PERFMON_V2 isn't supported by KVM

commit f9dc8fb3afc968042bdaf4b6e445a9272071c9f3 upstream.

Fix a goof where KVM sets CPUID.0x80000022.EAX to CPUID.0x80000022.EBX
instead of zeroing both when PERFMON_V2 isn't supported by KVM.  In
practice, barring a buggy CPU (or vCPU model when running nested) only the
!enable_pmu case is affected, as KVM always supports PERFMON_V2 if it's
available in hardware, i.e. CPUID.0x80000022.EBX will be '0' if PERFMON_V2
is unsupported.

For the !enable_pmu case, the bug is relatively benign as KVM will refuse
to enable PMU capabilities, but a VMM that reflects KVM's supported CPUID
into the guest could inadvertently induce #GPs in the guest due to
advertising support for MSRs that KVM refuses to emulate.

Fixes: 94cdeebd8211 ("KVM: x86/cpuid: Add AMD CPUID ExtPerfMonAndDbg leaf 0x80000022")
Signed-off-by: Xiaoyao Li <xiaoyao.li@intel.com>
Link: https://lore.kernel.org/r/20250304082314.472202-3-xiaoyao.li@intel.com
[sean: massage shortlog and changelog, tag for stable]
Cc: stable@vger.kernel.org
Signed-off-by: Sean Christopherson <seanjc@google.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
arch/x86/kvm/cpuid.c