[PATCH 2/3] perf/x86: Move MSR_CORE_PERF_GLOBAL_* dump to vendor code
From: Sandipan Das
Date: Thu Aug 06 2026 - 06:17:11 EST
MSR_CORE_PERF_GLOBAL_{CTRL,STATUS} and MSR_ARCH_PERFMON_FIXED_CTR_CTRL
are Intel Architectural PerfMon registers that are not available on AMD
processors.
Since commit 21d59e3e2c40 ("perf/x86/amd/core: Detect PerfMonV2
support"), x86_pmu.version is also set to 2 on AMD processors that
support PerfMonV2, which makes perf_event_print_debug() attempt to read
these non-existent MSRs. The resulting #GP is caught by the exception
fixup, but as the reads are unchecked, SysRq-P logs an "unchecked MSR
access error" for each one and then prints zeroes as if they were valid
register contents.
Implement x86_pmu::print_debug for the Intel and Zhaoxin PMUs, which do
have these registers, and drop the reads from common code. Both are
wired up through PMU descriptors that are selected only when the PMU
version is at least 2, so the version check is no longer needed.
MSR_CORE_PERF_GLOBAL_OVF_CTRL is also dropped from the dump since it is
write-to-clear and does not read back the overflow state.
Fixes: 21d59e3e2c40 ("perf/x86/amd/core: Detect PerfMonV2 support")
Reported-by: Petr Tesarik <ptesarik@xxxxxxxx>
Closes: https://lore.kernel.org/all/20260717150315.2868314-1-ptesarik@xxxxxxxx/
Cc: stable@xxxxxxxxxxxxxxx
Signed-off-by: Sandipan Das <sandipan.das@xxxxxxx>
---
arch/x86/events/core.c | 29 +++--------------------------
arch/x86/events/intel/core.c | 32 ++++++++++++++++++++++++++++++++
arch/x86/events/zhaoxin/core.c | 18 ++++++++++++++++++
3 files changed, 53 insertions(+), 26 deletions(-)
diff --git a/arch/x86/events/core.c b/arch/x86/events/core.c
index 17dc53a62378..7511197579fd 100644
--- a/arch/x86/events/core.c
+++ b/arch/x86/events/core.c
@@ -1559,38 +1559,15 @@ static void x86_pmu_start(struct perf_event *event, int flags)
void x86_pmu_print_debug(int cpu)
{
- u64 ctrl, status, overflow, pmc_ctrl, pmc_count, prev_left, fixed;
unsigned long *cntr_mask, *fixed_cntr_mask;
- struct event_constraint *pebs_constraints;
+ u64 pmc_ctrl, pmc_count, prev_left;
struct cpu_hw_events *cpuc;
- u64 pebs, debugctl;
- int cpu, idx;
+ int idx;
cpuc = &per_cpu(cpu_hw_events, cpu);
cntr_mask = hybrid(cpuc->pmu, cntr_mask);
fixed_cntr_mask = hybrid(cpuc->pmu, fixed_cntr_mask);
- pebs_constraints = hybrid(cpuc->pmu, pebs_constraints);
-
- if (x86_pmu.version >= 2) {
- rdmsrq(MSR_CORE_PERF_GLOBAL_CTRL, ctrl);
- rdmsrq(MSR_CORE_PERF_GLOBAL_STATUS, status);
- rdmsrq(MSR_CORE_PERF_GLOBAL_OVF_CTRL, overflow);
- rdmsrq(MSR_ARCH_PERFMON_FIXED_CTR_CTRL, fixed);
-
- pr_info("\n");
- pr_info("CPU#%d: ctrl: %016llx\n", cpu, ctrl);
- pr_info("CPU#%d: status: %016llx\n", cpu, status);
- pr_info("CPU#%d: overflow: %016llx\n", cpu, overflow);
- pr_info("CPU#%d: fixed: %016llx\n", cpu, fixed);
- if (pebs_constraints) {
- rdmsrq(MSR_IA32_PEBS_ENABLE, pebs);
- pr_info("CPU#%d: pebs: %016llx\n", cpu, pebs);
- }
- if (x86_pmu.lbr_nr) {
- rdmsrq(MSR_IA32_DEBUGCTLMSR, debugctl);
- pr_info("CPU#%d: debugctl: %016llx\n", cpu, debugctl);
- }
- }
+
pr_info("CPU#%d: active: %016llx\n", cpu, *(u64 *)cpuc->active_mask);
for_each_set_bit(idx, cntr_mask, X86_PMC_IDX_MAX) {
diff --git a/arch/x86/events/intel/core.c b/arch/x86/events/intel/core.c
index b39c6ce0efb5..e1ed0e173d0c 100644
--- a/arch/x86/events/intel/core.c
+++ b/arch/x86/events/intel/core.c
@@ -3736,6 +3736,36 @@ static void intel_pmu_reset(void)
local_irq_restore(flags);
}
+static void intel_pmu_print_debug(int cpu)
+{
+ struct event_constraint *pebs_constraints;
+ struct cpu_hw_events *cpuc;
+ u64 ctrl, status, fixed;
+ u64 pebs, debugctl;
+
+ cpuc = &per_cpu(cpu_hw_events, cpu);
+ pebs_constraints = hybrid(cpuc->pmu, pebs_constraints);
+
+ rdmsrq(MSR_CORE_PERF_GLOBAL_CTRL, ctrl);
+ rdmsrq(MSR_CORE_PERF_GLOBAL_STATUS, status);
+ rdmsrq(MSR_ARCH_PERFMON_FIXED_CTR_CTRL, fixed);
+
+ pr_info("\n");
+ pr_info("CPU#%d: ctrl: %016llx\n", cpu, ctrl);
+ pr_info("CPU#%d: status: %016llx\n", cpu, status);
+ pr_info("CPU#%d: fixed: %016llx\n", cpu, fixed);
+ if (pebs_constraints) {
+ rdmsrq(MSR_IA32_PEBS_ENABLE, pebs);
+ pr_info("CPU#%d: pebs: %016llx\n", cpu, pebs);
+ }
+ if (x86_pmu.lbr_nr) {
+ rdmsrq(MSR_IA32_DEBUGCTLMSR, debugctl);
+ pr_info("CPU#%d: debugctl: %016llx\n", cpu, debugctl);
+ }
+
+ x86_pmu_print_debug(cpu);
+}
+
/*
* We may be running with guest PEBS events created by KVM, and the
* PEBS records are logged into the guest's DS and invisible to host.
@@ -6680,6 +6710,8 @@ static __initconst const struct x86_pmu intel_pmu = {
* counting SMM by default.
*/
.attr_freeze_on_smi = 1,
+
+ .print_debug = intel_pmu_print_debug,
};
static __init void intel_clovertown_quirk(void)
diff --git a/arch/x86/events/zhaoxin/core.c b/arch/x86/events/zhaoxin/core.c
index e506f677db57..cc447e228efb 100644
--- a/arch/x86/events/zhaoxin/core.c
+++ b/arch/x86/events/zhaoxin/core.c
@@ -288,6 +288,22 @@ static inline void zxc_pmu_ack_status(u64 ack)
zhaoxin_pmu_disable_all();
}
+static void zhaoxin_pmu_print_debug(int cpu)
+{
+ u64 ctrl, status, fixed;
+
+ rdmsrq(MSR_CORE_PERF_GLOBAL_CTRL, ctrl);
+ rdmsrq(MSR_CORE_PERF_GLOBAL_STATUS, status);
+ rdmsrq(MSR_ARCH_PERFMON_FIXED_CTR_CTRL, fixed);
+
+ pr_info("\n");
+ pr_info("CPU#%d: ctrl: %016llx\n", cpu, ctrl);
+ pr_info("CPU#%d: status: %016llx\n", cpu, status);
+ pr_info("CPU#%d: fixed: %016llx\n", cpu, fixed);
+
+ x86_pmu_print_debug(cpu);
+}
+
static void zhaoxin_pmu_disable_fixed(struct hw_perf_event *hwc)
{
int idx = hwc->idx - INTEL_PMC_IDX_FIXED;
@@ -479,6 +495,8 @@ static const struct x86_pmu zhaoxin_pmu __initconst = {
.format_attrs = zx_arch_formats_attr,
.events_sysfs_show = zhaoxin_event_sysfs_show,
+
+ .print_debug = zhaoxin_pmu_print_debug,
};
static const struct { int id; char *name; } zx_arch_events_map[] __initconst = {
--
2.53.0