]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blame - releases/4.19.51/arm-prevent-tracing-ipi_cpu_backtrace.patch
Linux 4.19.51
[thirdparty/kernel/stable-queue.git] / releases / 4.19.51 / arm-prevent-tracing-ipi_cpu_backtrace.patch
CommitLineData
37554d48
SL
1From 3d51b868c6a0d2acaaf2dc2eac9c38597e9d3aad Mon Sep 17 00:00:00 2001
2From: Arnd Bergmann <arnd@arndb.de>
3Date: Tue, 14 May 2019 15:41:48 -0700
4Subject: ARM: prevent tracing IPI_CPU_BACKTRACE
5
6[ Upstream commit be167862ae7dd85c56d385209a4890678e1b0488 ]
7
8Patch series "compiler: allow all arches to enable
9CONFIG_OPTIMIZE_INLINING", v3.
10
11This patch (of 11):
12
13When function tracing for IPIs is enabled, we get a warning for an
14overflow of the ipi_types array with the IPI_CPU_BACKTRACE type as
15triggered by raise_nmi():
16
17 arch/arm/kernel/smp.c: In function 'raise_nmi':
18 arch/arm/kernel/smp.c:489:2: error: array subscript is above array bounds [-Werror=array-bounds]
19 trace_ipi_raise(target, ipi_types[ipinr]);
20
21This is a correct warning as we actually overflow the array here.
22
23This patch raise_nmi() to call __smp_cross_call() instead of
24smp_cross_call(), to avoid calling into ftrace. For clarification, I'm
25also adding a two new code comments describing how this one is special.
26
27The warning appears to have shown up after commit e7273ff49acf ("ARM:
288488/1: Make IPI_CPU_BACKTRACE a "non-secure" SGI"), which changed the
29number assignment from '15' to '8', but as far as I can tell has existed
30since the IPI tracepoints were first introduced. If we decide to
31backport this patch to stable kernels, we probably need to backport
32e7273ff49acf as well.
33
34[yamada.masahiro@socionext.com: rebase on v5.1-rc1]
35Link: http://lkml.kernel.org/r/20190423034959.13525-2-yamada.masahiro@socionext.com
36Fixes: e7273ff49acf ("ARM: 8488/1: Make IPI_CPU_BACKTRACE a "non-secure" SGI")
37Fixes: 365ec7b17327 ("ARM: add IPI tracepoints") # v3.17
38Signed-off-by: Arnd Bergmann <arnd@arndb.de>
39Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
40Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
41Cc: Arnd Bergmann <arnd@arndb.de>
42Cc: Ingo Molnar <mingo@redhat.com>
43Cc: Christophe Leroy <christophe.leroy@c-s.fr>
44Cc: Mathieu Malaterre <malat@debian.org>
45Cc: "H. Peter Anvin" <hpa@zytor.com>
46Cc: Thomas Gleixner <tglx@linutronix.de>
47Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
48Cc: Paul Mackerras <paulus@samba.org>
49Cc: Ralf Baechle <ralf@linux-mips.org>
50Cc: Stefan Agner <stefan@agner.ch>
51Cc: Boris Brezillon <bbrezillon@kernel.org>
52Cc: Miquel Raynal <miquel.raynal@bootlin.com>
53Cc: Richard Weinberger <richard@nod.at>
54Cc: David Woodhouse <dwmw2@infradead.org>
55Cc: Brian Norris <computersforpeace@gmail.com>
56Cc: Marek Vasut <marek.vasut@gmail.com>
57Cc: Russell King <rmk+kernel@arm.linux.org.uk>
58Cc: Borislav Petkov <bp@suse.de>
59Cc: Mark Rutland <mark.rutland@arm.com>
60Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
61Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
62Signed-off-by: Sasha Levin <sashal@kernel.org>
63---
64 arch/arm/include/asm/hardirq.h | 1 +
65 arch/arm/kernel/smp.c | 6 +++++-
66 2 files changed, 6 insertions(+), 1 deletion(-)
67
68diff --git a/arch/arm/include/asm/hardirq.h b/arch/arm/include/asm/hardirq.h
69index cba23eaa6072..7a88f160b1fb 100644
70--- a/arch/arm/include/asm/hardirq.h
71+++ b/arch/arm/include/asm/hardirq.h
72@@ -6,6 +6,7 @@
73 #include <linux/threads.h>
74 #include <asm/irq.h>
75
76+/* number of IPIS _not_ including IPI_CPU_BACKTRACE */
77 #define NR_IPI 7
78
79 typedef struct {
80diff --git a/arch/arm/kernel/smp.c b/arch/arm/kernel/smp.c
81index a3ce7c5365fa..bada66ef4419 100644
82--- a/arch/arm/kernel/smp.c
83+++ b/arch/arm/kernel/smp.c
84@@ -76,6 +76,10 @@ enum ipi_msg_type {
85 IPI_CPU_STOP,
86 IPI_IRQ_WORK,
87 IPI_COMPLETION,
88+ /*
89+ * CPU_BACKTRACE is special and not included in NR_IPI
90+ * or tracable with trace_ipi_*
91+ */
92 IPI_CPU_BACKTRACE,
93 /*
94 * SGI8-15 can be reserved by secure firmware, and thus may
95@@ -803,7 +807,7 @@ core_initcall(register_cpufreq_notifier);
96
97 static void raise_nmi(cpumask_t *mask)
98 {
99- smp_cross_call(mask, IPI_CPU_BACKTRACE);
100+ __smp_cross_call(mask, IPI_CPU_BACKTRACE);
101 }
102
103 void arch_trigger_cpumask_backtrace(const cpumask_t *mask, bool exclude_self)
104--
1052.20.1
106