[PATCH v2 0/2] perf/x86: Limit branch snapshots to valid entries
From: Sandipan Das
Date: Thu Oct 15 2026 - 07:50:58 EST
Sashiko reported that the vendor-specific branch snapshot callbacks
used by bpf_get_branch_snapshot() copy up to x86_pmu.lbr_nr entries
from cpuc->lbr_entries[], regardless of how many valid entries the
last LBR read produced. This makes BPF programs read stale or invalid
branch records. Patch 1 addresses AMD and patch 2 addresses Intel.
Previous version(s) can be found at
v1: https://lore.kernel.org/all/20261007181002.4005262-1-sandipan.das@xxxxxxx/
Changes in v2:
* Include a fix for Intel LBR.
* Add Tested-by from Dapeng to the Intel fix.
https://lore.kernel.org/all/eb6c7bda-0dcf-4fac-ad69-9f5b24abc21b@xxxxxxxxxxxxxxx/
Sandipan Das (2):
perf/x86/amd/lbr: Limit branch snapshots to valid entries
perf/x86/intel/lbr: Limit branch snapshots to valid entries
arch/x86/events/amd/core.c | 2 +-
arch/x86/events/amd/lbr.c | 4 +++-
arch/x86/events/intel/core.c | 2 +-
arch/x86/events/intel/lbr.c | 4 +++-
4 files changed, 8 insertions(+), 4 deletions(-)
--
2.53.0