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