Skip to content

Commit 034417c

Browse files
Dapeng Misean-jc
authored andcommitted
KVM: x86/pmu: Don't try to get perf capabilities for hybrid CPUs
Explicitly zero kvm_host_pmu instead of attempting to get the perf PMU capabilities when running on a hybrid CPU to avoid running afoul of perf's sanity check. ------------[ cut here ]------------ WARNING: arch/x86/events/core.c:3089 at perf_get_x86_pmu_capability+0xd/0xc0, Call Trace: <TASK> kvm_x86_vendor_init+0x1b0/0x1a40 [kvm] vmx_init+0xdb/0x260 [kvm_intel] vt_init+0x12/0x9d0 [kvm_intel] do_one_initcall+0x60/0x3f0 do_init_module+0x97/0x2b0 load_module+0x2d08/0x2e30 init_module_from_file+0x96/0xe0 idempotent_init_module+0x117/0x330 __x64_sys_finit_module+0x73/0xe0 Always read the capabilities for non-hybrid CPUs, i.e. don't entirely revert to reading capabilities if and only if KVM wants to use a PMU, as it may be useful to have the host PMU capabilities available, e.g. if only or debug. Reported-by: Chaitanya Kumar Borah <chaitanya.kumar.borah@intel.com> Closes: https://lore.kernel.org/all/70b64347-2aca-4511-af78-a767d5fa8226@intel.com/ Fixes: 51f34b1 ("KVM: x86/pmu: Snapshot host (i.e. perf's) reported PMU capabilities") Suggested-by: Sean Christopherson <seanjc@google.com> Signed-off-by: Dapeng Mi <dapeng1.mi@linux.intel.com> Link: https://lore.kernel.org/r/20251010005239.146953-1-dapeng1.mi@linux.intel.com [sean: rework changelog, call out hybrid CPUs in shortlog] Signed-off-by: Sean Christopherson <seanjc@google.com>
1 parent 1bcc3f8 commit 034417c

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

arch/x86/kvm/pmu.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,16 +108,18 @@ void kvm_init_pmu_capability(const struct kvm_pmu_ops *pmu_ops)
108108
bool is_intel = boot_cpu_data.x86_vendor == X86_VENDOR_INTEL;
109109
int min_nr_gp_ctrs = pmu_ops->MIN_NR_GP_COUNTERS;
110110

111-
perf_get_x86_pmu_capability(&kvm_host_pmu);
112-
113111
/*
114112
* Hybrid PMUs don't play nice with virtualization without careful
115113
* configuration by userspace, and KVM's APIs for reporting supported
116114
* vPMU features do not account for hybrid PMUs. Disable vPMU support
117115
* for hybrid PMUs until KVM gains a way to let userspace opt-in.
118116
*/
119-
if (cpu_feature_enabled(X86_FEATURE_HYBRID_CPU))
117+
if (cpu_feature_enabled(X86_FEATURE_HYBRID_CPU)) {
120118
enable_pmu = false;
119+
memset(&kvm_host_pmu, 0, sizeof(kvm_host_pmu));
120+
} else {
121+
perf_get_x86_pmu_capability(&kvm_host_pmu);
122+
}
121123

122124
if (enable_pmu) {
123125
/*

0 commit comments

Comments
 (0)