KVM: x86/pmu: Fix available_event_types check for REF_CPU_CYCLES event
authorLike Xu <likexu@tencent.com>
Wed, 5 Jan 2022 05:15:09 +0000 (13:15 +0800)
committerPaolo Bonzini <pbonzini@redhat.com>
Mon, 17 Jan 2022 17:19:41 +0000 (12:19 -0500)
commita21864486f7e220bd5938c6fb637613d9635739a
treee5f73ec1ed5c738060b0835adbe2980128667550
parentc862dcd199759d4a45e65dab47b03e3e8a144e3a
KVM: x86/pmu: Fix available_event_types check for REF_CPU_CYCLES event

According to CPUID 0x0A.EBX bit vector, the event [7] should be the
unrealized event "Topdown Slots" instead of the *kernel* generalized
common hardware event "REF_CPU_CYCLES", so we need to skip the cpuid
unavaliblity check in the intel_pmc_perf_hw_id() for the last
REF_CPU_CYCLES event and update the confusing comment.

If the event is marked as unavailable in the Intel guest CPUID
0AH.EBX leaf, we need to avoid any perf_event creation, whether
it's a gp or fixed counter. To distinguish whether it is a rejected
event or an event that needs to be programmed with PERF_TYPE_RAW type,
a new special returned value of "PERF_COUNT_HW_MAX + 1" is introduced.

Fixes: 62079d8a43128 ("KVM: PMU: add proper support for fixed counter 2")
Signed-off-by: Like Xu <likexu@tencent.com>
Message-Id: <20220105051509.69437-1-likexu@tencent.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
arch/x86/kvm/pmu.c
arch/x86/kvm/vmx/pmu_intel.c