[xtensa-cvscommit] linux/arch/xtensa/kernel setup.c,1.5,1.6
Brought to you by:
zankel
|
From: <ma...@us...> - 2003-02-11 07:20:53
|
Update of /cvsroot/xtensa/linux/arch/xtensa/kernel
In directory sc8-pr-cvs1:/tmp/cvs-serv17715
Modified Files:
setup.c
Log Message:
Make kernel traceback on panic more robust against corrupt/unclean stacks.
Index: setup.c
===================================================================
RCS file: /cvsroot/xtensa/linux/arch/xtensa/kernel/setup.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** setup.c 7 Feb 2003 02:03:35 -0000 1.5
--- setup.c 11 Feb 2003 07:20:50 -0000 1.6
***************
*** 247,258 ****
register unsigned current_retpc asm ("a0"); /* return address */
register unsigned *current_sp asm ("a1"); /* current stack pointer */
! unsigned retpc, next_retpc, *sp;
int i;
printk( "Call traceback:\n" );
xthal_window_spill(); /* save any live caller windows to stack */
sp = current_sp; /* start with current stack frame */
retpc = current_retpc; /* and current return address */
for( i = 0; i < MAX_TRACEBACK; i++ ) {
next_retpc = sp[-4]; /* a0 of caller */
sp = (unsigned*) sp[-3]; /* a1 of caller -- go to next caller */
--- 247,265 ----
register unsigned current_retpc asm ("a0"); /* return address */
register unsigned *current_sp asm ("a1"); /* current stack pointer */
! unsigned retpc, next_retpc, upperpc, *sp, *prevsp;
int i;
printk( "Call traceback:\n" );
xthal_window_spill(); /* save any live caller windows to stack */
+ upperpc = ((unsigned)&xtensa_panic_event) & 0xC0000000; /* upper 2 bits of PC */
sp = current_sp; /* start with current stack frame */
+ prevsp = sp - 1;
retpc = current_retpc; /* and current return address */
for( i = 0; i < MAX_TRACEBACK; i++ ) {
+ if( ((unsigned)sp & 3) != 0 || sp <= prevsp || sp > __KSTK_TOS(current) ) {
+ printk( " (stack pointer out of range or unaligned)\n" );
+ break;
+ }
+ prevsp = sp;
next_retpc = sp[-4]; /* a0 of caller */
sp = (unsigned*) sp[-3]; /* a1 of caller -- go to next caller */
***************
*** 261,265 ****
break;
}
! printk( " SP=%08X PC=%08X\n", (unsigned) sp, retpc );
retpc = next_retpc;
}
--- 268,273 ----
break;
}
! printk( " SP=%08X PC=%08X\n",
! (unsigned) sp, ((retpc & 0x3FFFFFFF) | upperpc) );
retpc = next_retpc;
}
|