]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blame - releases/6.8.6/perf-x86-amd-lbr-discard-erroneous-branch-entries.patch
Linux 6.8.6
[thirdparty/kernel/stable-queue.git] / releases / 6.8.6 / perf-x86-amd-lbr-discard-erroneous-branch-entries.patch
CommitLineData
335f7cc0
SL
1From 42e0501037d90654302fe74c07b413b78760dfeb Mon Sep 17 00:00:00 2001
2From: Sasha Levin <sashal@kernel.org>
3Date: Mon, 29 Jan 2024 16:36:25 +0530
4Subject: perf/x86/amd/lbr: Discard erroneous branch entries
5
6From: Sandipan Das <sandipan.das@amd.com>
7
8[ Upstream commit 29297ffffb0bf388778bd4b581a43cee6929ae65 ]
9
10The Revision Guide for AMD Family 19h Model 10-1Fh processors declares
11Erratum 1452 which states that non-branch entries may erroneously be
12recorded in the Last Branch Record (LBR) stack with the valid and
13spec bits set.
14
15Such entries can be recognized by inspecting bit 61 of the corresponding
16LastBranchStackToIp register. This bit is currently reserved but if found
17to be set, the associated branch entry should be discarded.
18
19Signed-off-by: Sandipan Das <sandipan.das@amd.com>
20Signed-off-by: Ingo Molnar <mingo@kernel.org>
21Cc: Peter Zijlstra <peterz@infradead.org>
22Link: https://bugzilla.kernel.org/attachment.cgi?id=305518
23Link: https://lore.kernel.org/r/3ad2aa305f7396d41a40e3f054f740d464b16b7f.1706526029.git.sandipan.das@amd.com
24Signed-off-by: Sasha Levin <sashal@kernel.org>
25---
26 arch/x86/events/amd/lbr.c | 6 ++++--
27 1 file changed, 4 insertions(+), 2 deletions(-)
28
29diff --git a/arch/x86/events/amd/lbr.c b/arch/x86/events/amd/lbr.c
30index eb31f850841a8..4a1e600314d5d 100644
31--- a/arch/x86/events/amd/lbr.c
32+++ b/arch/x86/events/amd/lbr.c
33@@ -173,9 +173,11 @@ void amd_pmu_lbr_read(void)
34
35 /*
36 * Check if a branch has been logged; if valid = 0, spec = 0
37- * then no branch was recorded
38+ * then no branch was recorded; if reserved = 1 then an
39+ * erroneous branch was recorded (see Erratum 1452)
40 */
41- if (!entry.to.split.valid && !entry.to.split.spec)
42+ if ((!entry.to.split.valid && !entry.to.split.spec) ||
43+ entry.to.split.reserved)
44 continue;
45
46 perf_clear_branch_entry_bitfields(br + out);
47--
482.43.0
49