aboutsummaryrefslogtreecommitdiffstats
path: root/arch/blackfin/kernel/traps.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/blackfin/kernel/traps.c')
-rw-r--r--arch/blackfin/kernel/traps.c340
1 files changed, 193 insertions, 147 deletions
diff --git a/arch/blackfin/kernel/traps.c b/arch/blackfin/kernel/traps.c
index afd044e78af6..cfa05436c972 100644
--- a/arch/blackfin/kernel/traps.c
+++ b/arch/blackfin/kernel/traps.c
@@ -37,10 +37,24 @@
37#include <asm/blackfin.h> 37#include <asm/blackfin.h>
38#include <asm/irq_handler.h> 38#include <asm/irq_handler.h>
39#include <asm/trace.h> 39#include <asm/trace.h>
40#include <asm/fixed_code.h>
40 41
41#ifdef CONFIG_KGDB 42#ifdef CONFIG_KGDB
42# include <linux/debugger.h> 43# include <linux/debugger.h>
43# include <linux/kgdb.h> 44# include <linux/kgdb.h>
45
46# define CHK_DEBUGGER_TRAP() \
47 do { \
48 CHK_DEBUGGER(trapnr, sig, info.si_code, fp, ); \
49 } while (0)
50# define CHK_DEBUGGER_TRAP_MAYBE() \
51 do { \
52 if (kgdb_connected) \
53 CHK_DEBUGGER_TRAP(); \
54 } while (0)
55#else
56# define CHK_DEBUGGER_TRAP() do { } while (0)
57# define CHK_DEBUGGER_TRAP_MAYBE() do { } while (0)
44#endif 58#endif
45 59
46/* Initiate the event table handler */ 60/* Initiate the event table handler */
@@ -53,13 +67,13 @@ void __init trap_init(void)
53 67
54int kstack_depth_to_print = 48; 68int kstack_depth_to_print = 48;
55 69
56#ifdef CONFIG_DEBUG_BFIN_HWTRACE_ON 70static void decode_address(char *buf, unsigned long address)
57static int printk_address(unsigned long address)
58{ 71{
59 struct vm_list_struct *vml; 72 struct vm_list_struct *vml;
60 struct task_struct *p; 73 struct task_struct *p;
61 struct mm_struct *mm; 74 struct mm_struct *mm;
62 unsigned long offset; 75 unsigned long flags, offset;
76 unsigned int in_exception = bfin_read_IPEND() & 0x10;
63 77
64#ifdef CONFIG_KALLSYMS 78#ifdef CONFIG_KALLSYMS
65 unsigned long symsize; 79 unsigned long symsize;
@@ -75,20 +89,33 @@ static int printk_address(unsigned long address)
75 /* yeah! kernel space! */ 89 /* yeah! kernel space! */
76 if (!modname) 90 if (!modname)
77 modname = delim = ""; 91 modname = delim = "";
78 return printk("<0x%p> { %s%s%s%s + 0x%lx }", 92 sprintf(buf, "<0x%p> { %s%s%s%s + 0x%lx }",
79 (void *)address, delim, modname, delim, symname, 93 (void *)address, delim, modname, delim, symname,
80 (unsigned long)offset); 94 (unsigned long)offset);
95 return;
81 96
82 } 97 }
83#endif 98#endif
84 99
100 /* Problem in fixed code section? */
101 if (address >= FIXED_CODE_START && address < FIXED_CODE_END) {
102 sprintf(buf, "<0x%p> /* Maybe fixed code section */", (void *)address);
103 return;
104 }
105
106 /* Problem somewhere before the kernel start address */
107 if (address < CONFIG_BOOT_LOAD) {
108 sprintf(buf, "<0x%p> /* Maybe null pointer? */", (void *)address);
109 return;
110 }
111
85 /* looks like we're off in user-land, so let's walk all the 112 /* looks like we're off in user-land, so let's walk all the
86 * mappings of all our processes and see if we can't be a whee 113 * mappings of all our processes and see if we can't be a whee
87 * bit more specific 114 * bit more specific
88 */ 115 */
89 write_lock_irq(&tasklist_lock); 116 write_lock_irqsave(&tasklist_lock, flags);
90 for_each_process(p) { 117 for_each_process(p) {
91 mm = get_task_mm(p); 118 mm = (in_exception ? p->mm : get_task_mm(p));
92 if (!mm) 119 if (!mm)
93 continue; 120 continue;
94 121
@@ -117,25 +144,30 @@ static int printk_address(unsigned long address)
117 else 144 else
118 offset = (address - vma->vm_start) + (vma->vm_pgoff << PAGE_SHIFT); 145 offset = (address - vma->vm_start) + (vma->vm_pgoff << PAGE_SHIFT);
119 146
120 write_unlock_irq(&tasklist_lock); 147 sprintf(buf, "<0x%p> [ %s + 0x%lx ]",
121 mmput(mm); 148 (void *)address, name, offset);
122 return printk("<0x%p> [ %s + 0x%lx ]", 149 if (!in_exception)
123 (void *)address, name, offset); 150 mmput(mm);
151 goto done;
124 } 152 }
125 153
126 vml = vml->next; 154 vml = vml->next;
127 } 155 }
128 mmput(mm); 156 if (!in_exception)
157 mmput(mm);
129 } 158 }
130 write_unlock_irq(&tasklist_lock);
131 159
132 /* we were unable to find this address anywhere */ 160 /* we were unable to find this address anywhere */
133 return printk("[<0x%p>]", (void *)address); 161 sprintf(buf, "[<0x%p>]", (void *)address);
162
163done:
164 write_unlock_irqrestore(&tasklist_lock, flags);
134} 165}
135#endif
136 166
137asmlinkage void double_fault_c(struct pt_regs *fp) 167asmlinkage void double_fault_c(struct pt_regs *fp)
138{ 168{
169 console_verbose();
170 oops_in_progress = 1;
139 printk(KERN_EMERG "\n" KERN_EMERG "Double Fault\n"); 171 printk(KERN_EMERG "\n" KERN_EMERG "Double Fault\n");
140 dump_bfin_regs(fp, (void *)fp->retx); 172 dump_bfin_regs(fp, (void *)fp->retx);
141 panic("Double Fault - unrecoverable event\n"); 173 panic("Double Fault - unrecoverable event\n");
@@ -151,22 +183,29 @@ asmlinkage void trap_c(struct pt_regs *fp)
151 siginfo_t info; 183 siginfo_t info;
152 unsigned long trapnr = fp->seqstat & SEQSTAT_EXCAUSE; 184 unsigned long trapnr = fp->seqstat & SEQSTAT_EXCAUSE;
153 185
186 trace_buffer_save(j);
187
188 /* Important - be very careful dereferncing pointers - will lead to
189 * double faults if the stack has become corrupt
190 */
191
192 /* If the fault was caused by a kernel thread, or interrupt handler
193 * we will kernel panic, so the system reboots.
194 * If KGDB is enabled, don't set this for kernel breakpoints
195 */
196 if ((bfin_read_IPEND() & 0xFFC0)
154#ifdef CONFIG_KGDB 197#ifdef CONFIG_KGDB
155# define CHK_DEBUGGER_TRAP() \ 198 && trapnr != VEC_EXCPT02
156 do { \
157 CHK_DEBUGGER(trapnr, sig, info.si_code, fp, ); \
158 } while (0)
159# define CHK_DEBUGGER_TRAP_MAYBE() \
160 do { \
161 if (kgdb_connected) \
162 CHK_DEBUGGER_TRAP(); \
163 } while (0)
164#else
165# define CHK_DEBUGGER_TRAP() do { } while (0)
166# define CHK_DEBUGGER_TRAP_MAYBE() do { } while (0)
167#endif 199#endif
168 200 ){
169 trace_buffer_save(j); 201 console_verbose();
202 oops_in_progress = 1;
203 } else if (current) {
204 if (current->mm == NULL) {
205 console_verbose();
206 oops_in_progress = 1;
207 }
208 }
170 209
171 /* trap_c() will be called for exceptions. During exceptions 210 /* trap_c() will be called for exceptions. During exceptions
172 * processing, the pc value should be set with retx value. 211 * processing, the pc value should be set with retx value.
@@ -211,7 +250,7 @@ asmlinkage void trap_c(struct pt_regs *fp)
211 case VEC_EXCPT03: 250 case VEC_EXCPT03:
212 info.si_code = SEGV_STACKFLOW; 251 info.si_code = SEGV_STACKFLOW;
213 sig = SIGSEGV; 252 sig = SIGSEGV;
214 printk(KERN_EMERG EXC_0x03); 253 printk(KERN_NOTICE EXC_0x03);
215 CHK_DEBUGGER_TRAP(); 254 CHK_DEBUGGER_TRAP();
216 break; 255 break;
217 /* 0x04 - User Defined, Caught by default */ 256 /* 0x04 - User Defined, Caught by default */
@@ -240,7 +279,7 @@ asmlinkage void trap_c(struct pt_regs *fp)
240 case VEC_OVFLOW: 279 case VEC_OVFLOW:
241 info.si_code = TRAP_TRACEFLOW; 280 info.si_code = TRAP_TRACEFLOW;
242 sig = SIGTRAP; 281 sig = SIGTRAP;
243 printk(KERN_EMERG EXC_0x11); 282 printk(KERN_NOTICE EXC_0x11);
244 CHK_DEBUGGER_TRAP(); 283 CHK_DEBUGGER_TRAP();
245 break; 284 break;
246 /* 0x12 - Reserved, Caught by default */ 285 /* 0x12 - Reserved, Caught by default */
@@ -262,14 +301,14 @@ asmlinkage void trap_c(struct pt_regs *fp)
262 case VEC_UNDEF_I: 301 case VEC_UNDEF_I:
263 info.si_code = ILL_ILLOPC; 302 info.si_code = ILL_ILLOPC;
264 sig = SIGILL; 303 sig = SIGILL;
265 printk(KERN_EMERG EXC_0x21); 304 printk(KERN_NOTICE EXC_0x21);
266 CHK_DEBUGGER_TRAP(); 305 CHK_DEBUGGER_TRAP();
267 break; 306 break;
268 /* 0x22 - Illegal Instruction Combination, handled here */ 307 /* 0x22 - Illegal Instruction Combination, handled here */
269 case VEC_ILGAL_I: 308 case VEC_ILGAL_I:
270 info.si_code = ILL_ILLPARAOP; 309 info.si_code = ILL_ILLPARAOP;
271 sig = SIGILL; 310 sig = SIGILL;
272 printk(KERN_EMERG EXC_0x22); 311 printk(KERN_NOTICE EXC_0x22);
273 CHK_DEBUGGER_TRAP(); 312 CHK_DEBUGGER_TRAP();
274 break; 313 break;
275 /* 0x23 - Data CPLB Protection Violation, 314 /* 0x23 - Data CPLB Protection Violation,
@@ -277,21 +316,21 @@ asmlinkage void trap_c(struct pt_regs *fp)
277 case VEC_CPLB_VL: 316 case VEC_CPLB_VL:
278 info.si_code = ILL_CPLB_VI; 317 info.si_code = ILL_CPLB_VI;
279 sig = SIGILL; 318 sig = SIGILL;
280 printk(KERN_EMERG EXC_0x23); 319 printk(KERN_NOTICE EXC_0x23);
281 CHK_DEBUGGER_TRAP(); 320 CHK_DEBUGGER_TRAP();
282 break; 321 break;
283 /* 0x24 - Data access misaligned, handled here */ 322 /* 0x24 - Data access misaligned, handled here */
284 case VEC_MISALI_D: 323 case VEC_MISALI_D:
285 info.si_code = BUS_ADRALN; 324 info.si_code = BUS_ADRALN;
286 sig = SIGBUS; 325 sig = SIGBUS;
287 printk(KERN_EMERG EXC_0x24); 326 printk(KERN_NOTICE EXC_0x24);
288 CHK_DEBUGGER_TRAP(); 327 CHK_DEBUGGER_TRAP();
289 break; 328 break;
290 /* 0x25 - Unrecoverable Event, handled here */ 329 /* 0x25 - Unrecoverable Event, handled here */
291 case VEC_UNCOV: 330 case VEC_UNCOV:
292 info.si_code = ILL_ILLEXCPT; 331 info.si_code = ILL_ILLEXCPT;
293 sig = SIGILL; 332 sig = SIGILL;
294 printk(KERN_EMERG EXC_0x25); 333 printk(KERN_NOTICE EXC_0x25);
295 CHK_DEBUGGER_TRAP(); 334 CHK_DEBUGGER_TRAP();
296 break; 335 break;
297 /* 0x26 - Data CPLB Miss, normal case is handled in _cplb_hdr, 336 /* 0x26 - Data CPLB Miss, normal case is handled in _cplb_hdr,
@@ -299,7 +338,7 @@ asmlinkage void trap_c(struct pt_regs *fp)
299 case VEC_CPLB_M: 338 case VEC_CPLB_M:
300 info.si_code = BUS_ADRALN; 339 info.si_code = BUS_ADRALN;
301 sig = SIGBUS; 340 sig = SIGBUS;
302 printk(KERN_EMERG EXC_0x26); 341 printk(KERN_NOTICE EXC_0x26);
303 CHK_DEBUGGER_TRAP(); 342 CHK_DEBUGGER_TRAP();
304 break; 343 break;
305 /* 0x27 - Data CPLB Multiple Hits - Linux Trap Zero, handled here */ 344 /* 0x27 - Data CPLB Multiple Hits - Linux Trap Zero, handled here */
@@ -307,11 +346,10 @@ asmlinkage void trap_c(struct pt_regs *fp)
307 info.si_code = ILL_CPLB_MULHIT; 346 info.si_code = ILL_CPLB_MULHIT;
308#ifdef CONFIG_DEBUG_HUNT_FOR_ZERO 347#ifdef CONFIG_DEBUG_HUNT_FOR_ZERO
309 sig = SIGSEGV; 348 sig = SIGSEGV;
310 printk(KERN_EMERG "\n" 349 printk(KERN_NOTICE "NULL pointer access (probably)\n");
311 KERN_EMERG "NULL pointer access (probably)\n");
312#else 350#else
313 sig = SIGILL; 351 sig = SIGILL;
314 printk(KERN_EMERG EXC_0x27); 352 printk(KERN_NOTICE EXC_0x27);
315#endif 353#endif
316 CHK_DEBUGGER_TRAP(); 354 CHK_DEBUGGER_TRAP();
317 break; 355 break;
@@ -331,7 +369,7 @@ asmlinkage void trap_c(struct pt_regs *fp)
331 case VEC_ISTRU_VL: /* ADSP-BF535 only (MH) */ 369 case VEC_ISTRU_VL: /* ADSP-BF535 only (MH) */
332 info.si_code = BUS_OPFETCH; 370 info.si_code = BUS_OPFETCH;
333 sig = SIGBUS; 371 sig = SIGBUS;
334 printk(KERN_EMERG "BF535: VEC_ISTRU_VL\n"); 372 printk(KERN_NOTICE "BF535: VEC_ISTRU_VL\n");
335 CHK_DEBUGGER_TRAP(); 373 CHK_DEBUGGER_TRAP();
336 break; 374 break;
337#else 375#else
@@ -341,7 +379,7 @@ asmlinkage void trap_c(struct pt_regs *fp)
341 case VEC_MISALI_I: 379 case VEC_MISALI_I:
342 info.si_code = BUS_ADRALN; 380 info.si_code = BUS_ADRALN;
343 sig = SIGBUS; 381 sig = SIGBUS;
344 printk(KERN_EMERG EXC_0x2A); 382 printk(KERN_NOTICE EXC_0x2A);
345 CHK_DEBUGGER_TRAP(); 383 CHK_DEBUGGER_TRAP();
346 break; 384 break;
347 /* 0x2B - Instruction CPLB protection Violation, 385 /* 0x2B - Instruction CPLB protection Violation,
@@ -349,14 +387,14 @@ asmlinkage void trap_c(struct pt_regs *fp)
349 case VEC_CPLB_I_VL: 387 case VEC_CPLB_I_VL:
350 info.si_code = ILL_CPLB_VI; 388 info.si_code = ILL_CPLB_VI;
351 sig = SIGILL; 389 sig = SIGILL;
352 printk(KERN_EMERG EXC_0x2B); 390 printk(KERN_NOTICE EXC_0x2B);
353 CHK_DEBUGGER_TRAP(); 391 CHK_DEBUGGER_TRAP();
354 break; 392 break;
355 /* 0x2C - Instruction CPLB miss, handled in _cplb_hdr */ 393 /* 0x2C - Instruction CPLB miss, handled in _cplb_hdr */
356 case VEC_CPLB_I_M: 394 case VEC_CPLB_I_M:
357 info.si_code = ILL_CPLB_MISS; 395 info.si_code = ILL_CPLB_MISS;
358 sig = SIGBUS; 396 sig = SIGBUS;
359 printk(KERN_EMERG EXC_0x2C); 397 printk(KERN_NOTICE EXC_0x2C);
360 CHK_DEBUGGER_TRAP(); 398 CHK_DEBUGGER_TRAP();
361 break; 399 break;
362 /* 0x2D - Instruction CPLB Multiple Hits, handled here */ 400 /* 0x2D - Instruction CPLB Multiple Hits, handled here */
@@ -364,10 +402,10 @@ asmlinkage void trap_c(struct pt_regs *fp)
364 info.si_code = ILL_CPLB_MULHIT; 402 info.si_code = ILL_CPLB_MULHIT;
365#ifdef CONFIG_DEBUG_HUNT_FOR_ZERO 403#ifdef CONFIG_DEBUG_HUNT_FOR_ZERO
366 sig = SIGSEGV; 404 sig = SIGSEGV;
367 printk(KERN_EMERG "\n\nJump to address 0 - 0x0fff\n"); 405 printk(KERN_NOTICE "Jump to address 0 - 0x0fff\n");
368#else 406#else
369 sig = SIGILL; 407 sig = SIGILL;
370 printk(KERN_EMERG EXC_0x2D); 408 printk(KERN_NOTICE EXC_0x2D);
371#endif 409#endif
372 CHK_DEBUGGER_TRAP(); 410 CHK_DEBUGGER_TRAP();
373 break; 411 break;
@@ -375,7 +413,7 @@ asmlinkage void trap_c(struct pt_regs *fp)
375 case VEC_ILL_RES: 413 case VEC_ILL_RES:
376 info.si_code = ILL_PRVOPC; 414 info.si_code = ILL_PRVOPC;
377 sig = SIGILL; 415 sig = SIGILL;
378 printk(KERN_EMERG EXC_0x2E); 416 printk(KERN_NOTICE EXC_0x2E);
379 CHK_DEBUGGER_TRAP(); 417 CHK_DEBUGGER_TRAP();
380 break; 418 break;
381 /* 0x2F - Reserved, Caught by default */ 419 /* 0x2F - Reserved, Caught by default */
@@ -404,38 +442,40 @@ asmlinkage void trap_c(struct pt_regs *fp)
404 break; 442 break;
405 } 443 }
406 444
407 if (sig != 0 && sig != SIGTRAP) { 445 BUG_ON(sig == 0);
446
447 if (sig != SIGTRAP) {
408 unsigned long stack; 448 unsigned long stack;
409 dump_bfin_regs(fp, (void *)fp->retx); 449 dump_bfin_regs(fp, (void *)fp->retx);
410 dump_bfin_trace_buffer(); 450
451 /* Print out the trace buffer if it makes sense */
452#ifndef CONFIG_DEBUG_BFIN_NO_KERN_HWTRACE
453 if (trapnr == VEC_CPLB_I_M || trapnr == VEC_CPLB_M)
454 printk(KERN_NOTICE "No trace since you do not have "
455 "CONFIG_DEBUG_BFIN_NO_KERN_HWTRACE enabled\n"
456 KERN_NOTICE "\n");
457 else
458#endif
459 dump_bfin_trace_buffer();
411 show_stack(current, &stack); 460 show_stack(current, &stack);
412 if (current->mm == NULL) 461 if (oops_in_progress) {
462#ifndef CONFIG_ACCESS_CHECK
463 printk(KERN_EMERG "Hey - dork - please turn on "
464 "CONFIG_ACCESS_CHECK\n");
465#endif
413 panic("Kernel exception"); 466 panic("Kernel exception");
467 }
468
469 /* Ensure that bad return addresses don't end up in an infinite
470 * loop, due to speculative loads/reads
471 */
472 fp->pc = SAFE_USER_INSTRUCTION;
414 } 473 }
415 info.si_signo = sig; 474 info.si_signo = sig;
416 info.si_errno = 0; 475 info.si_errno = 0;
417 info.si_addr = (void *)fp->pc; 476 info.si_addr = (void *)fp->pc;
418 force_sig_info(sig, &info, current); 477 force_sig_info(sig, &info, current);
419 478
420 /* if the address that we are about to return to is not valid, set it
421 * to a valid address, if we have a current application or panic
422 */
423 if (!(fp->pc <= physical_mem_end
424#if L1_CODE_LENGTH != 0
425 || (fp->pc >= L1_CODE_START &&
426 fp->pc <= (L1_CODE_START + L1_CODE_LENGTH))
427#endif
428 )) {
429 if (current->mm) {
430 fp->pc = current->mm->start_code;
431 } else {
432 printk(KERN_EMERG
433 "I can't return to memory that doesn't exist"
434 " - bad things happen\n");
435 panic("Help - I've fallen and can't get up\n");
436 }
437 }
438
439 trace_buffer_restore(j); 479 trace_buffer_restore(j);
440 return; 480 return;
441} 481}
@@ -448,21 +488,21 @@ void dump_bfin_trace_buffer(void)
448{ 488{
449#ifdef CONFIG_DEBUG_BFIN_HWTRACE_ON 489#ifdef CONFIG_DEBUG_BFIN_HWTRACE_ON
450 int tflags, i = 0; 490 int tflags, i = 0;
491 char buf[150];
451#ifdef CONFIG_DEBUG_BFIN_HWTRACE_EXPAND 492#ifdef CONFIG_DEBUG_BFIN_HWTRACE_EXPAND
452 int j, index; 493 int j, index;
453#endif 494#endif
454 495
455 trace_buffer_save(tflags); 496 trace_buffer_save(tflags);
456 497
457 printk(KERN_EMERG "Hardware Trace:\n"); 498 printk(KERN_NOTICE "Hardware Trace:\n");
458 499
459 if (likely(bfin_read_TBUFSTAT() & TBUFCNT)) { 500 if (likely(bfin_read_TBUFSTAT() & TBUFCNT)) {
460 for (; bfin_read_TBUFSTAT() & TBUFCNT; i++) { 501 for (; bfin_read_TBUFSTAT() & TBUFCNT; i++) {
461 printk(KERN_EMERG "%4i Target : ", i); 502 decode_address(buf, (unsigned long)bfin_read_TBUF());
462 printk_address((unsigned long)bfin_read_TBUF()); 503 printk(KERN_NOTICE "%4i Target : %s\n", i, buf);
463 printk("\n" KERN_EMERG " Source : "); 504 decode_address(buf, (unsigned long)bfin_read_TBUF());
464 printk_address((unsigned long)bfin_read_TBUF()); 505 printk(KERN_NOTICE " Source : %s\n", buf);
465 printk("\n");
466 } 506 }
467 } 507 }
468 508
@@ -474,17 +514,16 @@ void dump_bfin_trace_buffer(void)
474 514
475 j = (1 << CONFIG_DEBUG_BFIN_HWTRACE_EXPAND_LEN) * 128; 515 j = (1 << CONFIG_DEBUG_BFIN_HWTRACE_EXPAND_LEN) * 128;
476 while (j) { 516 while (j) {
477 printk(KERN_EMERG "%4i Target : ", i); 517 decode_address(buf, software_trace_buff[index]);
478 printk_address(software_trace_buff[index]); 518 printk(KERN_NOTICE "%4i Target : %s\n", i, buf);
479 index -= 1; 519 index -= 1;
480 if (index < 0 ) 520 if (index < 0 )
481 index = EXPAND_LEN; 521 index = EXPAND_LEN;
482 printk("\n" KERN_EMERG " Source : "); 522 decode_address(buf, software_trace_buff[index]);
483 printk_address(software_trace_buff[index]); 523 printk(KERN_NOTICE " Source : %s\n", buf);
484 index -= 1; 524 index -= 1;
485 if (index < 0) 525 if (index < 0)
486 index = EXPAND_LEN; 526 index = EXPAND_LEN;
487 printk("\n");
488 j--; 527 j--;
489 i++; 528 i++;
490 } 529 }
@@ -499,10 +538,7 @@ static void show_trace(struct task_struct *tsk, unsigned long *sp)
499{ 538{
500 unsigned long addr; 539 unsigned long addr;
501 540
502 printk("\nCall Trace:"); 541 printk(KERN_NOTICE "\n" KERN_NOTICE "Call Trace:\n");
503#ifdef CONFIG_KALLSYMS
504 printk("\n");
505#endif
506 542
507 while (!kstack_end(sp)) { 543 while (!kstack_end(sp)) {
508 addr = *sp++; 544 addr = *sp++;
@@ -518,7 +554,7 @@ static void show_trace(struct task_struct *tsk, unsigned long *sp)
518 print_ip_sym(addr); 554 print_ip_sym(addr);
519 } 555 }
520 556
521 printk("\n"); 557 printk(KERN_NOTICE "\n");
522} 558}
523 559
524void show_stack(struct task_struct *task, unsigned long *stack) 560void show_stack(struct task_struct *task, unsigned long *stack)
@@ -540,14 +576,15 @@ void show_stack(struct task_struct *task, unsigned long *stack)
540 addr = (unsigned long)stack; 576 addr = (unsigned long)stack;
541 endstack = (unsigned long *)PAGE_ALIGN(addr); 577 endstack = (unsigned long *)PAGE_ALIGN(addr);
542 578
543 printk(KERN_EMERG "Stack from %08lx:", (unsigned long)stack); 579 printk(KERN_NOTICE "Stack from %08lx:", (unsigned long)stack);
544 for (i = 0; i < kstack_depth_to_print; i++) { 580 for (i = 0; i < kstack_depth_to_print; i++) {
545 if (stack + 1 > endstack) 581 if (stack + 1 > endstack)
546 break; 582 break;
547 if (i % 8 == 0) 583 if (i % 8 == 0)
548 printk("\n" KERN_EMERG " "); 584 printk("\n" KERN_NOTICE " ");
549 printk(" %08lx", *stack++); 585 printk(" %08lx", *stack++);
550 } 586 }
587 printk("\n");
551 588
552 show_trace(task, stack); 589 show_trace(task, stack);
553} 590}
@@ -568,33 +605,34 @@ EXPORT_SYMBOL(dump_stack);
568 605
569void dump_bfin_regs(struct pt_regs *fp, void *retaddr) 606void dump_bfin_regs(struct pt_regs *fp, void *retaddr)
570{ 607{
571 if (current->pid) { 608 char buf [150];
572 printk(KERN_EMERG "\n" KERN_EMERG "CURRENT PROCESS:\n" 609
573 KERN_EMERG "\n"); 610 if (!oops_in_progress) {
574 printk(KERN_EMERG "COMM=%s PID=%d\n", 611 if (current->pid && current->mm) {
575 current->comm, current->pid); 612 printk(KERN_NOTICE "\n" KERN_NOTICE "CURRENT PROCESS:\n");
613 printk(KERN_NOTICE "COMM=%s PID=%d\n",
614 current->comm, current->pid);
615
616 printk(KERN_NOTICE "TEXT = 0x%p-0x%p DATA = 0x%p-0x%p\n"
617 KERN_NOTICE "BSS = 0x%p-0x%p USER-STACK = 0x%p\n"
618 KERN_NOTICE "\n",
619 (void *)current->mm->start_code,
620 (void *)current->mm->end_code,
621 (void *)current->mm->start_data,
622 (void *)current->mm->end_data,
623 (void *)current->mm->end_data,
624 (void *)current->mm->brk,
625 (void *)current->mm->start_stack);
626 } else {
627 printk (KERN_NOTICE "\n" KERN_NOTICE
628 "No Valid pid - Either things are really messed up,"
629 " or you are in the kernel\n");
630 }
576 } else { 631 } else {
577 printk 632 printk(KERN_NOTICE "Kernel or interrupt exception\n");
578 (KERN_EMERG "\n" KERN_EMERG
579 "No Valid pid - Either things are really messed up,"
580 " or you are in the kernel\n");
581 }
582
583 if (current->mm) {
584 printk(KERN_EMERG "TEXT = 0x%p-0x%p DATA = 0x%p-0x%p\n"
585 KERN_EMERG "BSS = 0x%p-0x%p USER-STACK = 0x%p\n"
586 KERN_EMERG "\n",
587 (void *)current->mm->start_code,
588 (void *)current->mm->end_code,
589 (void *)current->mm->start_data,
590 (void *)current->mm->end_data,
591 (void *)current->mm->end_data,
592 (void *)current->mm->brk,
593 (void *)current->mm->start_stack);
594 } 633 }
595 634
596 printk(KERN_EMERG "return address: [0x%p]; contents of:", retaddr); 635 if (retaddr >= (void *)FIXED_CODE_START && retaddr < (void *)physical_mem_end
597 if (retaddr != 0 && retaddr <= (void *)physical_mem_end
598#if L1_CODE_LENGTH != 0 636#if L1_CODE_LENGTH != 0
599 /* FIXME: Copy the code out of L1 Instruction SRAM through dma 637 /* FIXME: Copy the code out of L1 Instruction SRAM through dma
600 memcpy. */ 638 memcpy. */
@@ -604,18 +642,20 @@ void dump_bfin_regs(struct pt_regs *fp, void *retaddr)
604 ) { 642 ) {
605 int i = ((unsigned int)retaddr & 0xFFFFFFF0) - 32; 643 int i = ((unsigned int)retaddr & 0xFFFFFFF0) - 32;
606 unsigned short x = 0; 644 unsigned short x = 0;
645 printk(KERN_NOTICE "return address: [0x%p]; contents of:", retaddr);
607 for (; i < ((unsigned int)retaddr & 0xFFFFFFF0) + 32; i += 2) { 646 for (; i < ((unsigned int)retaddr & 0xFFFFFFF0) + 32; i += 2) {
608 if (!(i & 0xF)) 647 if (!(i & 0xF))
609 printk("\n" KERN_EMERG "0x%08x: ", i); 648 printk("\n" KERN_NOTICE "0x%08x: ", i);
610 649
611 if (get_user(x, (unsigned short *)i)) 650 if (get_user(x, (unsigned short *)i))
612 break; 651 break;
613#ifndef CONFIG_DEBUG_HWERR 652#ifndef CONFIG_DEBUG_HWERR
614 /* If one of the last few instructions was a STI 653 /* If one of the last few instructions was a STI
615 * it is likely that the error occured awhile ago 654 * it is likely that the error occured awhile ago
616 * and we just noticed 655 * and we just noticed. This only happens in kernel
656 * context, which should mean an oops is happening
617 */ 657 */
618 if (x >= 0x0040 && x <= 0x0047 && i <= 0) 658 if (oops_in_progress && x >= 0x0040 && x <= 0x0047 && i <= 0)
619 panic("\n\nWARNING : You should reconfigure" 659 panic("\n\nWARNING : You should reconfigure"
620 " the kernel to turn on\n" 660 " the kernel to turn on\n"
621 " 'Hardware error interrupt" 661 " 'Hardware error interrupt"
@@ -628,56 +668,60 @@ void dump_bfin_regs(struct pt_regs *fp, void *retaddr)
628 else 668 else
629 printk(" %04x ", x); 669 printk(" %04x ", x);
630 } 670 }
631 printk("\n" KERN_EMERG "\n"); 671 printk("\n");
632 } else 672 } else
633 printk(KERN_EMERG 673 printk("\n" KERN_NOTICE
634 "Cannot look at the [PC] for it is" 674 "Cannot look at the [PC] for it is"
635 "in unreadable L1 SRAM - sorry\n"); 675 " in unreadable memory - sorry\n");
676
677 printk(KERN_NOTICE "\n" KERN_NOTICE "SEQUENCER STATUS:\n");
678 printk(KERN_NOTICE " SEQSTAT: %08lx IPEND: %04lx SYSCFG: %04lx\n",
679 (long)fp->seqstat, fp->ipend, fp->syscfg);
636 680
681 decode_address(buf, fp->rete);
682 printk(KERN_NOTICE " RETE: %s\n", buf);
683 decode_address(buf, fp->retn);
684 printk(KERN_NOTICE " RETN: %s\n", buf);
685 decode_address(buf, fp->retx);
686 printk(KERN_NOTICE " RETX: %s\n", buf);
687 decode_address(buf, fp->rets);
688 printk(KERN_NOTICE " RETS: %s\n", buf);
637 689
638 printk(KERN_EMERG 690 if ((long)fp->seqstat & SEQSTAT_EXCAUSE) {
639 "RETE: %08lx RETN: %08lx RETX: %08lx RETS: %08lx\n", 691 decode_address(buf, bfin_read_DCPLB_FAULT_ADDR());
640 fp->rete, fp->retn, fp->retx, fp->rets); 692 printk(KERN_NOTICE "DCPLB_FAULT_ADDR: %s\n", buf);
641 printk(KERN_EMERG "IPEND: %04lx SYSCFG: %04lx\n", 693 decode_address(buf, bfin_read_ICPLB_FAULT_ADDR());
642 fp->ipend, fp->syscfg); 694 printk(KERN_NOTICE "ICPLB_FAULT_ADDR: %s\n", buf);
643 printk(KERN_EMERG "SEQSTAT: %08lx SP: %08lx\n", 695 }
644 (long)fp->seqstat, (long)fp); 696
645 printk(KERN_EMERG "R0: %08lx R1: %08lx R2: %08lx R3: %08lx\n", 697 printk(KERN_NOTICE "\n" KERN_NOTICE "PROCESSOR STATE:\n");
698 printk(KERN_NOTICE " R0 : %08lx R1 : %08lx R2 : %08lx R3 : %08lx\n",
646 fp->r0, fp->r1, fp->r2, fp->r3); 699 fp->r0, fp->r1, fp->r2, fp->r3);
647 printk(KERN_EMERG "R4: %08lx R5: %08lx R6: %08lx R7: %08lx\n", 700 printk(KERN_NOTICE " R4 : %08lx R5 : %08lx R6 : %08lx R7 : %08lx\n",
648 fp->r4, fp->r5, fp->r6, fp->r7); 701 fp->r4, fp->r5, fp->r6, fp->r7);
649 printk(KERN_EMERG "P0: %08lx P1: %08lx P2: %08lx P3: %08lx\n", 702 printk(KERN_NOTICE " P0 : %08lx P1 : %08lx P2 : %08lx P3 : %08lx\n",
650 fp->p0, fp->p1, fp->p2, fp->p3); 703 fp->p0, fp->p1, fp->p2, fp->p3);
651 printk(KERN_EMERG 704 printk(KERN_NOTICE " P4 : %08lx P5 : %08lx FP : %08lx SP : %08lx\n",
652 "P4: %08lx P5: %08lx FP: %08lx\n", 705 fp->p4, fp->p5, fp->fp, (long)fp);
653 fp->p4, fp->p5, fp->fp); 706 printk(KERN_NOTICE " LB0: %08lx LT0: %08lx LC0: %08lx\n",
654 printk(KERN_EMERG
655 "A0.w: %08lx A0.x: %08lx A1.w: %08lx A1.x: %08lx\n",
656 fp->a0w, fp->a0x, fp->a1w, fp->a1x);
657
658 printk(KERN_EMERG "LB0: %08lx LT0: %08lx LC0: %08lx\n",
659 fp->lb0, fp->lt0, fp->lc0); 707 fp->lb0, fp->lt0, fp->lc0);
660 printk(KERN_EMERG "LB1: %08lx LT1: %08lx LC1: %08lx\n", 708 printk(KERN_NOTICE " LB1: %08lx LT1: %08lx LC1: %08lx\n",
661 fp->lb1, fp->lt1, fp->lc1); 709 fp->lb1, fp->lt1, fp->lc1);
662 printk(KERN_EMERG "B0: %08lx L0: %08lx M0: %08lx I0: %08lx\n", 710 printk(KERN_NOTICE " B0 : %08lx L0 : %08lx M0 : %08lx I0 : %08lx\n",
663 fp->b0, fp->l0, fp->m0, fp->i0); 711 fp->b0, fp->l0, fp->m0, fp->i0);
664 printk(KERN_EMERG "B1: %08lx L1: %08lx M1: %08lx I1: %08lx\n", 712 printk(KERN_NOTICE " B1 : %08lx L1 : %08lx M1 : %08lx I1 : %08lx\n",
665 fp->b1, fp->l1, fp->m1, fp->i1); 713 fp->b1, fp->l1, fp->m1, fp->i1);
666 printk(KERN_EMERG "B2: %08lx L2: %08lx M2: %08lx I2: %08lx\n", 714 printk(KERN_NOTICE " B2 : %08lx L2 : %08lx M2 : %08lx I2 : %08lx\n",
667 fp->b2, fp->l2, fp->m2, fp->i2); 715 fp->b2, fp->l2, fp->m2, fp->i2);
668 printk(KERN_EMERG "B3: %08lx L3: %08lx M3: %08lx I3: %08lx\n", 716 printk(KERN_NOTICE " B3 : %08lx L3 : %08lx M3 : %08lx I3 : %08lx\n",
669 fp->b3, fp->l3, fp->m3, fp->i3); 717 fp->b3, fp->l3, fp->m3, fp->i3);
718 printk(KERN_NOTICE "A0.w: %08lx A0.x: %08lx A1.w: %08lx A1.x: %08lx\n",
719 fp->a0w, fp->a0x, fp->a1w, fp->a1x);
670 720
671 printk(KERN_EMERG "\n" KERN_EMERG "USP: %08lx ASTAT: %08lx\n", 721 printk(KERN_NOTICE "USP : %08lx ASTAT: %08lx\n",
672 rdusp(), fp->astat); 722 rdusp(), fp->astat);
673 if ((long)fp->seqstat & SEQSTAT_EXCAUSE) {
674 printk(KERN_EMERG "DCPLB_FAULT_ADDR=%p\n",
675 (void *)bfin_read_DCPLB_FAULT_ADDR());
676 printk(KERN_EMERG "ICPLB_FAULT_ADDR=%p\n",
677 (void *)bfin_read_ICPLB_FAULT_ADDR());
678 }
679 723
680 printk("\n\n"); 724 printk(KERN_NOTICE "\n");
681} 725}
682 726
683#ifdef CONFIG_SYS_BFIN_SPINLOCK_L1 727#ifdef CONFIG_SYS_BFIN_SPINLOCK_L1
@@ -752,6 +796,8 @@ void panic_cplb_error(int cplb_panic, struct pt_regs *fp)
752 break; 796 break;
753 } 797 }
754 798
799 oops_in_progress = 1;
800
755 printk(KERN_EMERG "DCPLB_FAULT_ADDR=%p\n", (void *)bfin_read_DCPLB_FAULT_ADDR()); 801 printk(KERN_EMERG "DCPLB_FAULT_ADDR=%p\n", (void *)bfin_read_DCPLB_FAULT_ADDR());
756 printk(KERN_EMERG "ICPLB_FAULT_ADDR=%p\n", (void *)bfin_read_ICPLB_FAULT_ADDR()); 802 printk(KERN_EMERG "ICPLB_FAULT_ADDR=%p\n", (void *)bfin_read_ICPLB_FAULT_ADDR());
757 dump_bfin_regs(fp, (void *)fp->retx); 803 dump_bfin_regs(fp, (void *)fp->retx);