summaryrefslogtreecommitdiff
path: root/tools/lib/python
diff options
context:
space:
mode:
authorJiwoo Kim <arpe1618@gmail.com>2026-11-14 15:22:49 +0900
committerPeter Zijlstra <peterz@infradead.org>2026-11-27 10:35:05 +0100
commitd630454310b39d33be6757d7784418cf44ab0601 (patch)
tree8261c6aaf472924df50a9d8ef6f4e509e079b0b1 /tools/lib/python
parent34dc983cc1628dea5054baa8687477cbb8683e28 (diff)
perf/x86/intel: Don't allow extended register sampling for BTS events
x86_pmu_hw_config() accepts extended (XMM) register sampling in REGS_USER for events without precise_ip, and the same goes for the SIMD register fields. The BTS event is such an event, and intel_pmu_bts_config() does not reject it. For a sample taken in the PMI handler, x86_pmu_update_perf_regs() copies the user registers into the per-CPU x86_user_regs, which is a struct x86_perf_regs. That is what perf_reg_value() and perf_simd_reg_value() expect: they use container_of() on the sampled struct pt_regs to reach the fields that follow it. intel_pmu_drain_bts_buffer() does not call x86_pmu_update_perf_regs(). It passes zeroed on-stack registers to perf_prepare_sample(), so the generic perf_sample_regs_user() takes the user registers from perf_get_regs_user(). That returns task_pt_regs(current), or on x86_64, when the buffer is drained from the PMI handler, a copy in the per-CPU nmi_user_regs, and neither is embedded in a struct x86_perf_regs. For a BTS event that requests these registers in REGS_USER, perf_reg_value() and perf_simd_reg_value() therefore read past the end of the struct pt_regs they are given, and use the words found there as pointers. REGS_INTR is not affected: BTS events must set exclude_kernel, and perf_sample_regs_intr() then reports no registers, as the zeroed ones are not user mode. BTS samples are built from the BTS buffer when it is drained, not from the registers of an interrupted context, so there is nothing meaningful to report in these registers for them. Reject extended and SIMD register sampling for BTS events in intel_pmu_bts_config(), as was the case before these registers could be sampled for events without precise_ip. This was found with an AI coding assistant, which also drafted this patch and its changelog. It has not been reproduced, and the change has only been compile-tested. Fixes: edd9aec51213 ("perf/x86: Enable XMM register sampling for REGS_USER case") Signed-off-by: Jiwoo Kim <arpe1618@gmail.com> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Reviewed-by: Dapeng Mi <dapeng1.mi@linux.intel.com> Link: https://patch.msgid.link/20261114062249.1301-1-arpe1618@gmail.com
Diffstat (limited to 'tools/lib/python')
0 files changed, 0 insertions, 0 deletions