Introduce PERF_PMU_CAP_VIRTUALIZED_VPMU as an extension to the existing PERF_PMU_CAP_MEDIATED_VPMU to indicate support for hardware virtualized PMU where the guest counter states are automatically saved and restored during world switches. Pass on the new capability through x86_pmu_cap so that any other entity, such as KVM, can enquire if the host has hardware PMU virtualization. Signed-off-by: Sandipan Das --- arch/x86/events/core.c | 1 + arch/x86/include/asm/perf_event.h | 1 + include/linux/perf_event.h | 1 + 3 files changed, 3 insertions(+) diff --git a/arch/x86/events/core.c b/arch/x86/events/core.c index d58aa316b65a..8a8111762cc5 100644 --- a/arch/x86/events/core.c +++ b/arch/x86/events/core.c @@ -3131,6 +3131,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->virtualized = !!(pmu.capabilities & PERF_PMU_CAP_VIRTUALIZED_VPMU); } EXPORT_SYMBOL_GPL(perf_get_x86_pmu_capability); diff --git a/arch/x86/include/asm/perf_event.h b/arch/x86/include/asm/perf_event.h index 74db361a53d3..6c7d3b7623ad 100644 --- a/arch/x86/include/asm/perf_event.h +++ b/arch/x86/include/asm/perf_event.h @@ -293,6 +293,7 @@ struct x86_pmu_capability { int events_mask_len; unsigned int pebs_ept :1; unsigned int mediated :1; + unsigned int virtualized :1; }; /* diff --git a/include/linux/perf_event.h b/include/linux/perf_event.h index 3a9bd9c4c90e..3d7bec2b918d 100644 --- a/include/linux/perf_event.h +++ b/include/linux/perf_event.h @@ -306,6 +306,7 @@ struct perf_event_pmu_context; #define PERF_PMU_CAP_AUX_PAUSE 0x0200 #define PERF_PMU_CAP_AUX_PREFER_LARGE 0x0400 #define PERF_PMU_CAP_MEDIATED_VPMU 0x0800 +#define PERF_PMU_CAP_VIRTUALIZED_VPMU 0x1000 /** * pmu::scope -- 2.43.0