[PATCH} PPC64: revised patch for recursive xmon entry

Linas Vepstas linas at austin.ibm.com
Wed Dec 15 08:22:12 EST 2004




Hi,

I had a recursive call to xmon in linux-2.6.10-rc2 after a crash 
to firmware.  The resursion was due to a scrambled value in r1 
inherited from firmware.  The following patch prevents the recursion
and sets up a usable stack. Unfortunately, it still doesn't get us
to an xmon prompt; xmon thinks some other cpu is in control.  
I'll see if I can fix that next, if I manage to reproduce.

This patch obsoletes the one I sent yesterday.

--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-14 15:13:06.000000000 -0600
@@ -349,6 +349,25 @@ 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 pointer %lx in xmon, using emergency stack\n", *sp);
+			*sp = (unsigned long ) (get_paca()->emergency_sp);
+			sp = (unsigned long *) *sp;
+			*sp = (unsigned long ) (get_paca()->emergency_sp);
+		}
+		sp = (unsigned long *) *sp;
+ 		if (*sp < 0xc000000000000000)
+		{
+			printf("Bad stack frame %lx in xmon, using emergency stack\n", *sp);
+			*sp = (unsigned long ) (get_paca()->emergency_sp);
+		}
 		longjmp(xmon_fault_jmp[cpu], 1);
 	}
 



More information about the Linuxppc64-dev mailing list