perf already applies model-specific errata (e.g. RPL018 on RPL/MTL) and sanitizes contradictory values (e.g. clearing pebs_baseline when the PEBS format is < 4). Reading the MSR directly in KVM bypasses all of that. Add perf_capabilities to struct x86_pmu_capability, next to the counter counts, bit widths and event masks it already exports, so that KVM can use the validated value. Signed-off-by: Zide Chen Cc: Peter Zijlstra --- v10: New patch. --- arch/x86/events/core.c | 1 + arch/x86/include/asm/perf_event.h | 1 + 2 files changed, 2 insertions(+) diff --git a/arch/x86/events/core.c b/arch/x86/events/core.c index 8b3ea0adb965..770ca960fa6e 100644 --- a/arch/x86/events/core.c +++ b/arch/x86/events/core.c @@ -3164,6 +3164,7 @@ void perf_get_x86_pmu_capability(struct x86_pmu_capability *cap) cap->events_mask_len = x86_pmu.events_mask_len; cap->pebs_ept = x86_pmu.pebs_ept; cap->mediated = !!(pmu.capabilities & PERF_PMU_CAP_MEDIATED_VPMU); + cap->perf_capabilities = x86_pmu.intel_cap.capabilities; } EXPORT_SYMBOL_FOR_KVM(perf_get_x86_pmu_capability); diff --git a/arch/x86/include/asm/perf_event.h b/arch/x86/include/asm/perf_event.h index ca630bc282fb..a68cb7c79d8b 100644 --- a/arch/x86/include/asm/perf_event.h +++ b/arch/x86/include/asm/perf_event.h @@ -308,6 +308,7 @@ struct x86_pmu_capability { int events_mask_len; unsigned int pebs_ept :1; unsigned int mediated :1; + u64 perf_capabilities; }; /* -- 2.56.1