]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - releases/3.18.52/mips-fix-crash-registers-on-non-crashing-cpus.patch
Linux 4.14.119
[thirdparty/kernel/stable-queue.git] / releases / 3.18.52 / mips-fix-crash-registers-on-non-crashing-cpus.patch
1 From c80e1b62ffca52e2d1d865ee58bc79c4c0c55005 Mon Sep 17 00:00:00 2001
2 From: Corey Minyard <cminyard@mvista.com>
3 Date: Mon, 11 Apr 2016 09:10:19 -0500
4 Subject: MIPS: Fix crash registers on non-crashing CPUs
5
6 From: Corey Minyard <cminyard@mvista.com>
7
8 commit c80e1b62ffca52e2d1d865ee58bc79c4c0c55005 upstream.
9
10 As part of handling a crash on an SMP system, an IPI is send to
11 all other CPUs to save their current registers and stop. It was
12 using task_pt_regs(current) to get the registers, but that will
13 only be accurate if the CPU was interrupted running in userland.
14 Instead allow the architecture to pass in the registers (all
15 pass NULL now, but allow for the future) and then use get_irq_regs()
16 which should be accurate as we are in an interrupt. Fall back to
17 task_pt_regs(current) if nothing else is available.
18
19 Signed-off-by: Corey Minyard <cminyard@mvista.com>
20 Cc: David Daney <ddaney@caviumnetworks.com>
21 Cc: linux-mips@linux-mips.org
22 Patchwork: https://patchwork.linux-mips.org/patch/13050/
23 Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
24 Cc: Julia Lawall <julia.lawall@lip6.fr>
25 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
26
27 ---
28 arch/mips/kernel/crash.c | 16 +++++++++++++---
29 1 file changed, 13 insertions(+), 3 deletions(-)
30
31 --- a/arch/mips/kernel/crash.c
32 +++ b/arch/mips/kernel/crash.c
33 @@ -14,12 +14,22 @@ static int crashing_cpu = -1;
34 static cpumask_t cpus_in_crash = CPU_MASK_NONE;
35
36 #ifdef CONFIG_SMP
37 -static void crash_shutdown_secondary(void *ignore)
38 +static void crash_shutdown_secondary(void *passed_regs)
39 {
40 - struct pt_regs *regs;
41 + struct pt_regs *regs = passed_regs;
42 int cpu = smp_processor_id();
43
44 - regs = task_pt_regs(current);
45 + /*
46 + * If we are passed registers, use those. Otherwise get the
47 + * regs from the last interrupt, which should be correct, as
48 + * we are in an interrupt. But if the regs are not there,
49 + * pull them from the top of the stack. They are probably
50 + * wrong, but we need something to keep from crashing again.
51 + */
52 + if (!regs)
53 + regs = get_irq_regs();
54 + if (!regs)
55 + regs = task_pt_regs(current);
56
57 if (!cpu_online(cpu))
58 return;