diff options
Diffstat (limited to 'arch/sh/kernel/traps.c')
-rw-r--r-- | arch/sh/kernel/traps.c | 24 |
1 files changed, 20 insertions, 4 deletions
diff --git a/arch/sh/kernel/traps.c b/arch/sh/kernel/traps.c index b3e0067db358..f69bd968fcca 100644 --- a/arch/sh/kernel/traps.c +++ b/arch/sh/kernel/traps.c | |||
@@ -5,18 +5,32 @@ | |||
5 | #include <linux/signal.h> | 5 | #include <linux/signal.h> |
6 | #include <linux/sched.h> | 6 | #include <linux/sched.h> |
7 | #include <linux/uaccess.h> | 7 | #include <linux/uaccess.h> |
8 | #include <asm/unwinder.h> | ||
8 | #include <asm/system.h> | 9 | #include <asm/system.h> |
9 | 10 | ||
10 | #ifdef CONFIG_BUG | 11 | #ifdef CONFIG_BUG |
11 | static void handle_BUG(struct pt_regs *regs) | 12 | void handle_BUG(struct pt_regs *regs) |
12 | { | 13 | { |
14 | const struct bug_entry *bug; | ||
15 | unsigned long bugaddr = regs->pc; | ||
13 | enum bug_trap_type tt; | 16 | enum bug_trap_type tt; |
14 | tt = report_bug(regs->pc, regs); | 17 | |
18 | if (!is_valid_bugaddr(bugaddr)) | ||
19 | goto invalid; | ||
20 | |||
21 | bug = find_bug(bugaddr); | ||
22 | |||
23 | /* Switch unwinders when unwind_stack() is called */ | ||
24 | if (bug->flags & BUGFLAG_UNWINDER) | ||
25 | unwinder_faulted = 1; | ||
26 | |||
27 | tt = report_bug(bugaddr, regs); | ||
15 | if (tt == BUG_TRAP_TYPE_WARN) { | 28 | if (tt == BUG_TRAP_TYPE_WARN) { |
16 | regs->pc += instruction_size(regs->pc); | 29 | regs->pc += instruction_size(bugaddr); |
17 | return; | 30 | return; |
18 | } | 31 | } |
19 | 32 | ||
33 | invalid: | ||
20 | die("Kernel BUG", regs, TRAPA_BUG_OPCODE & 0xff); | 34 | die("Kernel BUG", regs, TRAPA_BUG_OPCODE & 0xff); |
21 | } | 35 | } |
22 | 36 | ||
@@ -28,8 +42,10 @@ int is_valid_bugaddr(unsigned long addr) | |||
28 | return 0; | 42 | return 0; |
29 | if (probe_kernel_address((insn_size_t *)addr, opcode)) | 43 | if (probe_kernel_address((insn_size_t *)addr, opcode)) |
30 | return 0; | 44 | return 0; |
45 | if (opcode == TRAPA_BUG_OPCODE) | ||
46 | return 1; | ||
31 | 47 | ||
32 | return opcode == TRAPA_BUG_OPCODE; | 48 | return 0; |
33 | } | 49 | } |
34 | #endif | 50 | #endif |
35 | 51 | ||