Skip to content

Commit 4e949e9

Browse files
Kan LiangKAGA-KOKO
authored andcommitted
perf/x86/intel: Don't enable freeze-on-smi for PerfMon V1
The SMM freeze feature was introduced since PerfMon V2. But the current code unconditionally enables the feature for all platforms. It can generate #GP exception, if the related FREEZE_WHILE_SMM bit is set for the machine with PerfMon V1. To disable the feature for PerfMon V1, perf needs to - Remove the freeze_on_smi sysfs entry by moving intel_pmu_attrs to intel_pmu, which is only applied to PerfMon V2 and later. - Check the PerfMon version before flipping the SMM bit when starting CPU Fixes: 6089327 ("perf/x86: Add sysfs entry to freeze counters on SMI") Signed-off-by: Kan Liang <[email protected]> Signed-off-by: Thomas Gleixner <[email protected]> Acked-by: Peter Zijlstra (Intel) <[email protected]> Cc: [email protected] Cc: [email protected] Cc: [email protected] Link: https://lkml.kernel.org/r/[email protected]
1 parent 6d08b06 commit 4e949e9

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

arch/x86/events/intel/core.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3339,7 +3339,8 @@ static void intel_pmu_cpu_starting(int cpu)
33393339

33403340
cpuc->lbr_sel = NULL;
33413341

3342-
flip_smm_bit(&x86_pmu.attr_freeze_on_smi);
3342+
if (x86_pmu.version > 1)
3343+
flip_smm_bit(&x86_pmu.attr_freeze_on_smi);
33433344

33443345
if (!cpuc->shared_regs)
33453346
return;
@@ -3502,6 +3503,8 @@ static __initconst const struct x86_pmu core_pmu = {
35023503
.cpu_dying = intel_pmu_cpu_dying,
35033504
};
35043505

3506+
static struct attribute *intel_pmu_attrs[];
3507+
35053508
static __initconst const struct x86_pmu intel_pmu = {
35063509
.name = "Intel",
35073510
.handle_irq = intel_pmu_handle_irq,
@@ -3533,6 +3536,8 @@ static __initconst const struct x86_pmu intel_pmu = {
35333536
.format_attrs = intel_arch3_formats_attr,
35343537
.events_sysfs_show = intel_event_sysfs_show,
35353538

3539+
.attrs = intel_pmu_attrs,
3540+
35363541
.cpu_prepare = intel_pmu_cpu_prepare,
35373542
.cpu_starting = intel_pmu_cpu_starting,
35383543
.cpu_dying = intel_pmu_cpu_dying,
@@ -3911,8 +3916,6 @@ __init int intel_pmu_init(void)
39113916

39123917
x86_pmu.max_pebs_events = min_t(unsigned, MAX_PEBS_EVENTS, x86_pmu.num_counters);
39133918

3914-
3915-
x86_pmu.attrs = intel_pmu_attrs;
39163919
/*
39173920
* Quirk: v2 perfmon does not report fixed-purpose events, so
39183921
* assume at least 3 events, when not running in a hypervisor:

0 commit comments

Comments
 (0)