KVM: x86/pmu: Get eventsel for fixed counters from perf
authorSean Christopherson <seanjc@google.com>
Tue, 9 Jan 2024 23:02:25 +0000 (15:02 -0800)
committerSean Christopherson <seanjc@google.com>
Tue, 30 Jan 2024 23:28:02 +0000 (15:28 -0800)
commit7a277c22412cf72cf6376f21c6d826e8f4a44cc3
treed20f225cba67594d2ec3e3cfd698438d65805ee1
parent61bb2ad795a72a7a75add3ffc257660fd6c7cfea
KVM: x86/pmu: Get eventsel for fixed counters from perf

Get the event selectors used to effectively request fixed counters for
perf events from perf itself instead of hardcoding them in KVM and hoping
that they match the underlying hardware.  While fixed counters 0 and 1 use
architectural events, as of ffbe4ab0beda ("perf/x86/intel: Extend the
ref-cycles event to GP counters") fixed counter 2 (reference TSC cycles)
may use a software-defined pseudo-encoding or a real hardware-defined
encoding.

Reported-by: Kan Liang <kan.liang@linux.intel.com>
Closes: https://lkml.kernel.org/r/4281eee7-6423-4ec8-bb18-c6aeee1faf2c%40linux.intel.com
Reviewed-by: Kan Liang <kan.liang@linux.intel.com>
Tested-by: Dapeng Mi <dapeng1.mi@linux.intel.com>
Link: https://lore.kernel.org/r/20240109230250.424295-6-seanjc@google.com
Signed-off-by: Sean Christopherson <seanjc@google.com>
arch/x86/kvm/vmx/pmu_intel.c