]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
perf/x86/amd: Support PERF_PMU_CAP_MEDIATED_VPMU for AMD host
authorSandipan Das <sandipan.das@amd.com>
Sat, 6 Dec 2025 00:16:49 +0000 (16:16 -0800)
committerPeter Zijlstra <peterz@infradead.org>
Wed, 17 Dec 2025 12:31:07 +0000 (13:31 +0100)
Apply the PERF_PMU_CAP_MEDIATED_VPMU flag for version 2 and later
implementations of the core PMU. Aside from having Global Control and
Status registers, virtualizing the PMU using the mediated model requires
an interface to set or clear the overflow bits in the Global Status MSRs
while restoring or saving the PMU context of a vCPU.

PerfMonV2-capable hardware has additional MSRs for this purpose, namely
PerfCntrGlobalStatusSet and PerfCntrGlobalStatusClr, thereby making it
suitable for use with mediated vPMU.

Signed-off-by: Sandipan Das <sandipan.das@amd.com>
Signed-off-by: Mingwei Zhang <mizhang@google.com>
Signed-off-by: Sean Christopherson <seanjc@google.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Tested-by: Xudong Hao <xudong.hao@intel.com>
Link: https://patch.msgid.link/20251206001720.468579-14-seanjc@google.com
arch/x86/events/amd/core.c

index 44656d2fb555024b0e76c88644098e99e1b6968f..0c92ed5f464b1c7f56860b864b491da23cecaf35 100644 (file)
@@ -1439,6 +1439,8 @@ static int __init amd_core_pmu_init(void)
 
                amd_pmu_global_cntr_mask = x86_pmu.cntr_mask64;
 
+               x86_get_pmu(smp_processor_id())->capabilities |= PERF_PMU_CAP_MEDIATED_VPMU;
+
                /* Update PMC handling functions */
                x86_pmu.enable_all = amd_pmu_v2_enable_all;
                x86_pmu.disable_all = amd_pmu_v2_disable_all;