Skip to contentSkip to conversation

mips: Fix crash registers on non-crashing CPUs

PATCH In review [email protected] 3 participants 4 messages Apr 11, 2016 – Apr 20, 2016 MIPS

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mips: Fix crash registers on non-crashing CPUs

From: Corey Minyard <[email protected]>

As part of handling a crash on an SMP system, an IPI is send to all other CPUs to save their current registers and stop. It was using task_pt_regs(current) to get the registers, but that will only be accurate if the CPU was interrupted running in userland. Instead allow the architecture to pass in the registers (all pass NULL now, but allow for the future) and then use get_irq_regs() which should be accurate as we are in an interrupt. Fall back to task_pt_regs(current) if nothing else is available.

---
 arch/mips/kernel/crash.c | 16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)
arch/mips/kernel/crash.c +13 -3
index d434d5d..610f0f3 100644
@@ -14,12 +14,22 @@ static int crashing_cpu = -1;
 static cpumask_t cpus_in_crash = CPU_MASK_NONE;
 
 #ifdef CONFIG_SMP
-static void crash_shutdown_secondary(void *ignore)
+static void crash_shutdown_secondary(void *passed_regs)
 {
-	struct pt_regs *regs;
+	struct pt_regs *regs = passed_regs;
 	int cpu = smp_processor_id();
 
-	regs = task_pt_regs(current);
+	/*
+	 * If we are passed registers, use those.  Otherwise get the
+	 * regs from the last interrupt, which should be correct, as
+	 * we are in an interrupt.  But if the regs are not there,
+	 * pull them from the top of the stack.  They are probably
+	 * wrong, but we need something to keep from crashing again.
+	 */
+	if (!regs)
+		regs = get_irq_regs();
+	if (!regs)
+		regs = task_pt_regs(current);
 
 	if (!cpu_online(cpu))
 		return;
Signature · 1 line
2.5.0
#1 lore raw

Anything on this?

-corey

Quoted 46 lines · On 04/11/2016 09:10 AM, [email protected] wrote:

From: Corey Minyard <[email protected]>

As part of handling a crash on an SMP system, an IPI is send to all other CPUs to save their current registers and stop. It was using task_pt_regs(current) to get the registers, but that will only be accurate if the CPU was interrupted running in userland. Instead allow the architecture to pass in the registers (all pass NULL now, but allow for the future) and then use get_irq_regs() which should be accurate as we are in an interrupt. Fall back to task_pt_regs(current) if nothing else is available.

---
  arch/mips/kernel/crash.c | 16 +++++++++++++---
  1 file changed, 13 insertions(+), 3 deletions(-)
arch/mips/kernel/crash.c +13 -3
index d434d5d..610f0f3 100644
@@ -14,12 +14,22 @@ static int crashing_cpu = -1;
  static cpumask_t cpus_in_crash = CPU_MASK_NONE;
 
  #ifdef CONFIG_SMP
-static void crash_shutdown_secondary(void *ignore)
+static void crash_shutdown_secondary(void *passed_regs)
  {
-	struct pt_regs *regs;
+	struct pt_regs *regs = passed_regs;
  	int cpu = smp_processor_id();
 
-	regs = task_pt_regs(current);
+	/*
+	 * If we are passed registers, use those.  Otherwise get the
+	 * regs from the last interrupt, which should be correct, as
+	 * we are in an interrupt.  But if the regs are not there,
+	 * pull them from the top of the stack.  They are probably
+	 * wrong, but we need something to keep from crashing again.
+	 */
+	if (!regs)
+		regs = get_irq_regs();
+	if (!regs)
+		regs = task_pt_regs(current);
 
  	if (!cpu_online(cpu))
  		return;
#2 lore raw
Quoted 1 line · Corey Minyard

Anything on this?

Applied a few days ago and waiting to be pulled by Linus.

Ralf

#3 lore raw
Quoted 6 lines · Ralf Baechle
Quoted 1 line · Corey Minyard

Anything on this?

Applied a few days ago and waiting to be pulled by Linus.

Ralf

Thanks a bunch.

-corey