]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - queue-4.19/arm-prevent-tracing-ipi_cpu_backtrace.patch
Linux 5.1.10
[thirdparty/kernel/stable-queue.git] / queue-4.19 / arm-prevent-tracing-ipi_cpu_backtrace.patch
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
5
6 [ Upstream commit be167862ae7dd85c56d385209a4890678e1b0488 ]
7
8 Patch series "compiler: allow all arches to enable
9 CONFIG_OPTIMIZE_INLINING", v3.
10
11 This patch (of 11):
12
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():
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
21 This is a correct warning as we actually overflow the array here.
22
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.
26
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
32 e7273ff49acf as well.
33
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>
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
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
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 {
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 {
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 --
105 2.20.1
106