| .. | .. |
|---|
| 34 | 34 | #include <linux/delay.h> |
|---|
| 35 | 35 | #include <linux/hardirq.h> |
|---|
| 36 | 36 | #include <linux/ratelimit.h> |
|---|
| 37 | +#include <linux/pgtable.h> |
|---|
| 37 | 38 | |
|---|
| 38 | 39 | #include <asm/stacktrace.h> |
|---|
| 39 | 40 | #include <asm/ptrace.h> |
|---|
| 40 | 41 | #include <asm/timex.h> |
|---|
| 41 | 42 | #include <linux/uaccess.h> |
|---|
| 42 | | -#include <asm/pgtable.h> |
|---|
| 43 | 43 | #include <asm/processor.h> |
|---|
| 44 | 44 | #include <asm/traps.h> |
|---|
| 45 | 45 | #include <asm/hw_breakpoint.h> |
|---|
| .. | .. |
|---|
| 51 | 51 | extern void kernel_exception(void); |
|---|
| 52 | 52 | extern void user_exception(void); |
|---|
| 53 | 53 | |
|---|
| 54 | | -extern void fast_syscall_kernel(void); |
|---|
| 54 | +extern void fast_illegal_instruction_user(void); |
|---|
| 55 | 55 | extern void fast_syscall_user(void); |
|---|
| 56 | 56 | extern void fast_alloca(void); |
|---|
| 57 | 57 | extern void fast_unaligned(void); |
|---|
| .. | .. |
|---|
| 88 | 88 | |
|---|
| 89 | 89 | static dispatch_init_table_t __initdata dispatch_init_table[] = { |
|---|
| 90 | 90 | |
|---|
| 91 | +#ifdef CONFIG_USER_ABI_CALL0_PROBE |
|---|
| 92 | +{ EXCCAUSE_ILLEGAL_INSTRUCTION, USER, fast_illegal_instruction_user }, |
|---|
| 93 | +#endif |
|---|
| 91 | 94 | { EXCCAUSE_ILLEGAL_INSTRUCTION, 0, do_illegal_instruction}, |
|---|
| 92 | | -{ EXCCAUSE_SYSTEM_CALL, KRNL, fast_syscall_kernel }, |
|---|
| 93 | 95 | { EXCCAUSE_SYSTEM_CALL, USER, fast_syscall_user }, |
|---|
| 94 | 96 | { EXCCAUSE_SYSTEM_CALL, 0, system_call }, |
|---|
| 95 | 97 | /* EXCCAUSE_INSTRUCTION_FETCH unhandled */ |
|---|
| .. | .. |
|---|
| 186 | 188 | "\tEXCCAUSE is %ld\n", |
|---|
| 187 | 189 | current->comm, task_pid_nr(current), regs->pc, |
|---|
| 188 | 190 | exccause); |
|---|
| 189 | | - force_sig(SIGILL, current); |
|---|
| 191 | + force_sig(SIGILL); |
|---|
| 190 | 192 | } |
|---|
| 191 | 193 | |
|---|
| 192 | 194 | /* |
|---|
| .. | .. |
|---|
| 215 | 217 | |
|---|
| 216 | 218 | static inline void check_valid_nmi(void) |
|---|
| 217 | 219 | { |
|---|
| 218 | | - unsigned intread = get_sr(interrupt); |
|---|
| 219 | | - unsigned intenable = get_sr(intenable); |
|---|
| 220 | + unsigned intread = xtensa_get_sr(interrupt); |
|---|
| 221 | + unsigned intenable = xtensa_get_sr(intenable); |
|---|
| 220 | 222 | |
|---|
| 221 | 223 | BUG_ON(intread & intenable & |
|---|
| 222 | 224 | ~(XTENSA_INTLEVEL_ANDBELOW_MASK(PROFILING_INTLEVEL) ^ |
|---|
| .. | .. |
|---|
| 273 | 275 | irq_enter(); |
|---|
| 274 | 276 | |
|---|
| 275 | 277 | for (;;) { |
|---|
| 276 | | - unsigned intread = get_sr(interrupt); |
|---|
| 277 | | - unsigned intenable = get_sr(intenable); |
|---|
| 278 | + unsigned intread = xtensa_get_sr(interrupt); |
|---|
| 279 | + unsigned intenable = xtensa_get_sr(intenable); |
|---|
| 278 | 280 | unsigned int_at_level = intread & intenable; |
|---|
| 279 | 281 | unsigned level; |
|---|
| 280 | 282 | |
|---|
| .. | .. |
|---|
| 308 | 310 | |
|---|
| 309 | 311 | pr_info_ratelimited("Illegal Instruction in '%s' (pid = %d, pc = %#010lx)\n", |
|---|
| 310 | 312 | current->comm, task_pid_nr(current), regs->pc); |
|---|
| 311 | | - force_sig(SIGILL, current); |
|---|
| 313 | + force_sig(SIGILL); |
|---|
| 312 | 314 | } |
|---|
| 313 | 315 | |
|---|
| 314 | 316 | |
|---|
| .. | .. |
|---|
| 332 | 334 | "(pid = %d, pc = %#010lx)\n", |
|---|
| 333 | 335 | regs->excvaddr, current->comm, |
|---|
| 334 | 336 | task_pid_nr(current), regs->pc); |
|---|
| 335 | | - force_sig_fault(SIGBUS, BUS_ADRALN, (void *) regs->excvaddr, current); |
|---|
| 337 | + force_sig_fault(SIGBUS, BUS_ADRALN, (void *) regs->excvaddr); |
|---|
| 336 | 338 | } |
|---|
| 337 | 339 | #endif |
|---|
| 338 | 340 | |
|---|
| .. | .. |
|---|
| 356 | 358 | |
|---|
| 357 | 359 | /* If in user mode, send SIGTRAP signal to current process */ |
|---|
| 358 | 360 | |
|---|
| 359 | | - force_sig(SIGTRAP, current); |
|---|
| 361 | + force_sig(SIGTRAP); |
|---|
| 360 | 362 | } |
|---|
| 361 | 363 | |
|---|
| 362 | 364 | |
|---|
| .. | .. |
|---|
| 422 | 424 | /* Setup specific handlers. */ |
|---|
| 423 | 425 | |
|---|
| 424 | 426 | for(i = 0; dispatch_init_table[i].cause >= 0; i++) { |
|---|
| 425 | | - |
|---|
| 426 | 427 | int fast = dispatch_init_table[i].fast; |
|---|
| 427 | 428 | int cause = dispatch_init_table[i].cause; |
|---|
| 428 | 429 | void *handler = dispatch_init_table[i].handler; |
|---|
| 429 | 430 | |
|---|
| 430 | 431 | if (fast == 0) |
|---|
| 431 | 432 | set_handler(default_handler, cause, handler); |
|---|
| 432 | | - if (fast && fast & USER) |
|---|
| 433 | + if ((fast & USER) != 0) |
|---|
| 433 | 434 | set_handler(fast_user_handler, cause, handler); |
|---|
| 434 | | - if (fast && fast & KRNL) |
|---|
| 435 | + if ((fast & KRNL) != 0) |
|---|
| 435 | 436 | set_handler(fast_kernel_handler, cause, handler); |
|---|
| 436 | 437 | } |
|---|
| 437 | 438 | |
|---|
| .. | .. |
|---|
| 478 | 479 | |
|---|
| 479 | 480 | static int show_trace_cb(struct stackframe *frame, void *data) |
|---|
| 480 | 481 | { |
|---|
| 482 | + const char *loglvl = data; |
|---|
| 483 | + |
|---|
| 481 | 484 | if (kernel_text_address(frame->pc)) |
|---|
| 482 | | - pr_cont(" [<%08lx>] %pB\n", frame->pc, (void *)frame->pc); |
|---|
| 485 | + printk("%s [<%08lx>] %pB\n", |
|---|
| 486 | + loglvl, frame->pc, (void *)frame->pc); |
|---|
| 483 | 487 | return 0; |
|---|
| 484 | 488 | } |
|---|
| 485 | 489 | |
|---|
| 486 | | -void show_trace(struct task_struct *task, unsigned long *sp) |
|---|
| 490 | +static void show_trace(struct task_struct *task, unsigned long *sp, |
|---|
| 491 | + const char *loglvl) |
|---|
| 487 | 492 | { |
|---|
| 488 | 493 | if (!sp) |
|---|
| 489 | 494 | sp = stack_pointer(task); |
|---|
| 490 | 495 | |
|---|
| 491 | | - pr_info("Call Trace:\n"); |
|---|
| 492 | | - walk_stackframe(sp, show_trace_cb, NULL); |
|---|
| 493 | | -#ifndef CONFIG_KALLSYMS |
|---|
| 494 | | - pr_cont("\n"); |
|---|
| 495 | | -#endif |
|---|
| 496 | + printk("%sCall Trace:\n", loglvl); |
|---|
| 497 | + walk_stackframe(sp, show_trace_cb, (void *)loglvl); |
|---|
| 496 | 498 | } |
|---|
| 497 | 499 | |
|---|
| 498 | | -static int kstack_depth_to_print = 24; |
|---|
| 500 | +#define STACK_DUMP_ENTRY_SIZE 4 |
|---|
| 501 | +#define STACK_DUMP_LINE_SIZE 32 |
|---|
| 502 | +static size_t kstack_depth_to_print = CONFIG_PRINT_STACK_DEPTH; |
|---|
| 499 | 503 | |
|---|
| 500 | | -void show_stack(struct task_struct *task, unsigned long *sp) |
|---|
| 504 | +void show_stack(struct task_struct *task, unsigned long *sp, const char *loglvl) |
|---|
| 501 | 505 | { |
|---|
| 502 | | - int i = 0; |
|---|
| 503 | | - unsigned long *stack; |
|---|
| 506 | + size_t len; |
|---|
| 504 | 507 | |
|---|
| 505 | 508 | if (!sp) |
|---|
| 506 | 509 | sp = stack_pointer(task); |
|---|
| 507 | | - stack = sp; |
|---|
| 508 | 510 | |
|---|
| 509 | | - pr_info("Stack:\n"); |
|---|
| 511 | + len = min((-(size_t)sp) & (THREAD_SIZE - STACK_DUMP_ENTRY_SIZE), |
|---|
| 512 | + kstack_depth_to_print * STACK_DUMP_ENTRY_SIZE); |
|---|
| 510 | 513 | |
|---|
| 511 | | - for (i = 0; i < kstack_depth_to_print; i++) { |
|---|
| 512 | | - if (kstack_end(sp)) |
|---|
| 513 | | - break; |
|---|
| 514 | | - pr_cont(" %08lx", *sp++); |
|---|
| 515 | | - if (i % 8 == 7) |
|---|
| 516 | | - pr_cont("\n"); |
|---|
| 517 | | - } |
|---|
| 518 | | - show_trace(task, stack); |
|---|
| 514 | + printk("%sStack:\n", loglvl); |
|---|
| 515 | + print_hex_dump(loglvl, " ", DUMP_PREFIX_NONE, |
|---|
| 516 | + STACK_DUMP_LINE_SIZE, STACK_DUMP_ENTRY_SIZE, |
|---|
| 517 | + sp, len, false); |
|---|
| 518 | + show_trace(task, sp, loglvl); |
|---|
| 519 | 519 | } |
|---|
| 520 | 520 | |
|---|
| 521 | 521 | DEFINE_SPINLOCK(die_lock); |
|---|
| .. | .. |
|---|
| 523 | 523 | void die(const char * str, struct pt_regs * regs, long err) |
|---|
| 524 | 524 | { |
|---|
| 525 | 525 | static int die_counter; |
|---|
| 526 | + const char *pr = ""; |
|---|
| 527 | + |
|---|
| 528 | + if (IS_ENABLED(CONFIG_PREEMPTION)) |
|---|
| 529 | + pr = IS_ENABLED(CONFIG_PREEMPT_RT) ? " PREEMPT_RT" : " PREEMPT"; |
|---|
| 526 | 530 | |
|---|
| 527 | 531 | console_verbose(); |
|---|
| 528 | 532 | spin_lock_irq(&die_lock); |
|---|
| 529 | 533 | |
|---|
| 530 | | - pr_info("%s: sig: %ld [#%d]%s\n", str, err, ++die_counter, |
|---|
| 531 | | - IS_ENABLED(CONFIG_PREEMPT) ? " PREEMPT" : ""); |
|---|
| 534 | + pr_info("%s: sig: %ld [#%d]%s\n", str, err, ++die_counter, pr); |
|---|
| 532 | 535 | show_regs(regs); |
|---|
| 533 | 536 | if (!user_mode(regs)) |
|---|
| 534 | | - show_stack(NULL, (unsigned long*)regs->areg[1]); |
|---|
| 537 | + show_stack(NULL, (unsigned long *)regs->areg[1], KERN_INFO); |
|---|
| 535 | 538 | |
|---|
| 536 | 539 | add_taint(TAINT_DIE, LOCKDEP_NOW_UNRELIABLE); |
|---|
| 537 | 540 | spin_unlock_irq(&die_lock); |
|---|