[PATCH] PPC64: Recursive xmon call due to bad stack

Linas Vepstas linas at austin.ibm.com
Tue Dec 14 08:37:45 EST 2004




Hi,

I had a recursive call to xmon in linux-2.6.10-rc2 after a crash 
to firmware.  I beleive the patch below should fix this, although
I was not able to test it, cause I can't reproduce the crash.  
Based on what I can tell about how xmon works, I *think* this 
patch should fix the recursion.   Please apply if it looks 
reasonable.

--linas

Signed-off-by: Linas Vepstas <linas at linas.org>


--- arch/ppc64/xmon/xmon.c.modified	2004-11-19 14:33:50.000000000 -0600
+++ arch/ppc64/xmon/xmon.c	2004-12-13 15:30:49.000000000 -0600
@@ -349,6 +349,17 @@ int xmon_core(struct pt_regs *regs, int 
 		printf("cpu 0x%x: Exception %lx %s in xmon, "
 		       "returning to main loop\n",
 		       cpu, regs->trap, getvecname(TRAP(regs)));
+
+		/* If crash occured in firmware, then saved stack pointer
+		 * is bad, and we get recursive fault. Switch to using
+		 * emergency stack in this case. 
+		 */
+		unsigned long *sp = ((unsigned long *) xmon_fault_jmp[cpu]) + 1;
+ 		if (*sp < 0xc000000000000000)
+		{
+			printf("Bad stack %lx in xmon, using emergency stack\n", *sp);
+			*sp = (unsigned long ) (get_paca()->emergency_sp);
+		}
 		longjmp(xmon_fault_jmp[cpu], 1);
 	}
 

p.s.

Here's the output I saw (before it scrolled off the screen, thank goodness
for slow serial lines!)  Note msr, pc and lr: crash was in firmware.

cpu 0x3: Vector: 700 (Program Check) at [c00000005c8838c0]
    pc: 00000000077d9374
    lr: 000000000000ddf8
    sp: c00000005c883b40
   msr: 81002
  current = 0xc000000055304030
  paca    = 0xc00000000052b680
    pid   = 12148, comm = errinjct
cpu 0x3: Vector: 700 (Program Check) at [c00000005c882e20]
    pc: 00000000077d9374
    lr: 000000000000ddf8
    sp: c00000005c8830a0
   msr: 81002
  current = 0xc000000055304030
  paca    = 0xc00000000052b680
    pid   = 12148, comm = errinjct
cpu 0x3: Exception 700 (Program Check) in xmon, returning to main loop
Bad kernel stack pointer 22022424 at c00000000004c1fc
cpu 0x3: Vector: 0  at [c0000000077c5d40]
    pc: c00000000004c1fc: .xmon_longjmp+0x84/0x8c
    lr: c00000000004a1f0: .xmon_core+0xfc/0x848
    sp: 22022424
   msr: 8000000000001032
  current = 0xc000000055304030
  paca    = 0xc00000000052b680
    pid   = 12148, comm = errinjct
cpu 0x3: Exception 0  in xmon, returning to main loop
Bad kernel stack pointer 22022424 at c00000000004c1fc
cpu 0x3: Vector: 0  at [c0000000077c5d40]
    pc: c00000000004c1fc: .xmon_longjmp+0x84/0x8c
    lr: c00000000004a1f0: .xmon_core+0xfc/0x848
    sp: 22022424
   msr: 8000000000001032
  current = 0xc000000055304030
  paca    = 0xc00000000052b680
    pid   = 12148, comm = errinjct
cpu 0x3: Exception 0  in xmon, returning to main loop
Bad kernel stack pointer 22022424 at c00000000004c1fc
cpu 0x3: Vector: 0  at [c0000000077c5d40]
    pc: c00000000004c1fc: .xmon_longjmp+0x84/0x8c
    lr: c00000000004a1f0: .xmon_core+0xfc/0x848

and etc repeating after here.




More information about the Linuxppc64-dev mailing list