Skip to content

Commit 0c7a6b2

Browse files
Robin GetzBryan Wu
authored andcommitted
Blackfin arch: add supporting for double fault debug handling
Signed-off-by: Robin Getz <rgetz@blackfin.uclinux.org> Signed-off-by: Mike Frysinger <vapier.adi@gmail.com> Signed-off-by: Bryan Wu <cooloney@kernel.org>
1 parent f4585a0 commit 0c7a6b2

5 files changed

Lines changed: 255 additions & 76 deletions

File tree

‎arch/blackfin/Kconfig.debug‎

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,44 @@ config DEBUG_HWERR
2222
hardware error interrupts and need to know where they are coming
2323
from.
2424

25+
config DEBUG_DOUBLEFAULT
26+
bool "Debug Double Faults"
27+
default n
28+
help
29+
If an exception is caused while executing code within the exception
30+
handler, the NMI handler, the reset vector, or in emulator mode,
31+
a double fault occurs. On the Blackfin, this is a unrecoverable
32+
event. You have two options:
33+
- RESET exactly when double fault occurs. The excepting
34+
instruction address is stored in RETX, where the next kernel
35+
boot will print it out.
36+
- Print debug message. This is much more error prone, although
37+
easier to handle. It is error prone since:
38+
- The excepting instruction is not committed.
39+
- All writebacks from the instruction are prevented.
40+
- The generated exception is not taken.
41+
- The EXCAUSE field is updated with an unrecoverable event
42+
The only way to check this is to see if EXCAUSE contains the
43+
unrecoverable event value at every exception return. By selecting
44+
this option, you are skipping over the faulting instruction, and
45+
hoping things stay together enough to print out a debug message.
46+
47+
This does add a little kernel code, but is the only method to debug
48+
double faults - if unsure say "Y"
49+
50+
choice
51+
prompt "Double Fault Failure Method"
52+
default DEBUG_DOUBLEFAULT_PRINT
53+
depends on DEBUG_DOUBLEFAULT
54+
55+
config DEBUG_DOUBLEFAULT_PRINT
56+
bool "Print"
57+
58+
config DEBUG_DOUBLEFAULT_RESET
59+
bool "Reset"
60+
61+
endchoice
62+
2563
config DEBUG_ICACHE_CHECK
2664
bool "Check Instruction cache coherency"
2765
depends on DEBUG_KERNEL

‎arch/blackfin/kernel/setup.c‎

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,8 @@ EXPORT_SYMBOL(mtd_size);
5252
#endif
5353

5454
char __initdata command_line[COMMAND_LINE_SIZE];
55-
unsigned int __initdata *__retx;
55+
void __initdata *init_retx, *init_saved_retx, *init_saved_seqstat,
56+
*init_saved_icplb_fault_addr, *init_saved_dcplb_fault_addr;
5657

5758
/* boot memmap, for parsing "memmap=" */
5859
#define BFIN_MEMMAP_MAX 128 /* number of entries in bfin_memmap */
@@ -782,16 +783,25 @@ void __init setup_arch(char **cmdline_p)
782783

783784
_bfin_swrst = bfin_read_SWRST();
784785

785-
/* If we double fault, reset the system - otherwise we hang forever */
786-
bfin_write_SWRST(DOUBLE_FAULT);
786+
#ifdef CONFIG_DEBUG_DOUBLEFAULT_PRINT
787+
bfin_write_SWRST(_bfin_swrst & ~DOUBLE_FAULT);
788+
#endif
789+
#ifdef CONFIG_DEBUG_DOUBLEFAULT_RESET
790+
bfin_write_SWRST(_bfin_swrst | DOUBLE_FAULT);
791+
#endif
787792

788-
if (_bfin_swrst & RESET_DOUBLE)
789-
/*
790-
* don't decode the address, since you don't know if this
791-
* kernel's symbol map is the same as the crashing kernel
792-
*/
793-
printk(KERN_INFO "Recovering from Double Fault event at %pF\n", __retx);
794-
else if (_bfin_swrst & RESET_WDOG)
793+
if (_bfin_swrst & RESET_DOUBLE) {
794+
printk(KERN_EMERG "Recovering from DOUBLE FAULT event\n");
795+
#ifdef CONFIG_DEBUG_DOUBLEFAULT
796+
/* We assume the crashing kernel, and the current symbol table match */
797+
printk(KERN_EMERG " While handling exception (EXCAUSE = 0x%x) at %pF\n",
798+
(int)init_saved_seqstat & SEQSTAT_EXCAUSE, init_saved_retx);
799+
printk(KERN_NOTICE " DCPLB_FAULT_ADDR: %pF\n", init_saved_dcplb_fault_addr);
800+
printk(KERN_NOTICE " ICPLB_FAULT_ADDR: %pF\n", init_saved_icplb_fault_addr);
801+
#endif
802+
printk(KERN_NOTICE " The instruction at %pF caused a double exception\n",
803+
init_retx);
804+
} else if (_bfin_swrst & RESET_WDOG)
795805
printk(KERN_INFO "Recovering from Watchdog event\n");
796806
else if (_bfin_swrst & RESET_SOFTWARE)
797807
printk(KERN_NOTICE "Reset caused by Software reset\n");

‎arch/blackfin/kernel/traps.c‎

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,15 @@ void __init trap_init(void)
6868
CSYNC();
6969
}
7070

71-
unsigned long saved_icplb_fault_addr, saved_dcplb_fault_addr;
71+
/*
72+
* Used to save the RETX, SEQSTAT, I/D CPLB FAULT ADDR
73+
* values across the transition from exception to IRQ5.
74+
* We put these in L1, so they are going to be in a valid
75+
* location during exception context
76+
*/
77+
__attribute__((l1_data))
78+
unsigned long saved_retx, saved_seqstat,
79+
saved_icplb_fault_addr, saved_dcplb_fault_addr;
7280

7381
static void decode_address(char *buf, unsigned long address)
7482
{
@@ -186,9 +194,27 @@ asmlinkage void double_fault_c(struct pt_regs *fp)
186194
console_verbose();
187195
oops_in_progress = 1;
188196
printk(KERN_EMERG "\n" KERN_EMERG "Double Fault\n");
189-
dump_bfin_process(fp);
190-
dump_bfin_mem(fp);
191-
show_regs(fp);
197+
#ifdef CONFIG_DEBUG_DOUBLEFAULT_PRINT
198+
if (((long)fp->seqstat & SEQSTAT_EXCAUSE) == VEC_UNCOV) {
199+
char buf[150];
200+
decode_address(buf, saved_retx);
201+
printk(KERN_EMERG "While handling exception (EXCAUSE = 0x%x) at %s:\n",
202+
(int)saved_seqstat & SEQSTAT_EXCAUSE, buf);
203+
decode_address(buf, saved_dcplb_fault_addr);
204+
printk(KERN_NOTICE " DCPLB_FAULT_ADDR: %s\n", buf);
205+
decode_address(buf, saved_icplb_fault_addr);
206+
printk(KERN_NOTICE " ICPLB_FAULT_ADDR: %s\n", buf);
207+
208+
decode_address(buf, fp->retx);
209+
printk(KERN_NOTICE "The instruction at %s caused a double exception\n",
210+
buf);
211+
} else
212+
#endif
213+
{
214+
dump_bfin_process(fp);
215+
dump_bfin_mem(fp);
216+
show_regs(fp);
217+
}
192218
panic("Double Fault - unrecoverable event\n");
193219

194220
}

0 commit comments

Comments
 (0)