|
@@ -5,18 +5,32 @@
|
|
|
#include <linux/signal.h>
|
|
|
#include <linux/sched.h>
|
|
|
#include <linux/uaccess.h>
|
|
|
+#include <asm/unwinder.h>
|
|
|
#include <asm/system.h>
|
|
|
|
|
|
#ifdef CONFIG_BUG
|
|
|
void handle_BUG(struct pt_regs *regs)
|
|
|
{
|
|
|
+ const struct bug_entry *bug;
|
|
|
+ unsigned long bugaddr = regs->pc;
|
|
|
enum bug_trap_type tt;
|
|
|
- tt = report_bug(regs->pc, regs);
|
|
|
+
|
|
|
+ if (!is_valid_bugaddr(bugaddr))
|
|
|
+ goto invalid;
|
|
|
+
|
|
|
+ bug = find_bug(bugaddr);
|
|
|
+
|
|
|
+ /* Switch unwinders when unwind_stack() is called */
|
|
|
+ if (bug->flags & BUGFLAG_UNWINDER)
|
|
|
+ unwinder_faulted = 1;
|
|
|
+
|
|
|
+ tt = report_bug(bugaddr, regs);
|
|
|
if (tt == BUG_TRAP_TYPE_WARN) {
|
|
|
- regs->pc += instruction_size(regs->pc);
|
|
|
+ regs->pc += instruction_size(bugaddr);
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
+invalid:
|
|
|
die("Kernel BUG", regs, TRAPA_BUG_OPCODE & 0xff);
|
|
|
}
|
|
|
|
|
@@ -28,8 +42,7 @@ int is_valid_bugaddr(unsigned long addr)
|
|
|
return 0;
|
|
|
if (probe_kernel_address((insn_size_t *)addr, opcode))
|
|
|
return 0;
|
|
|
-
|
|
|
- if (opcode == TRAPA_BUG_OPCODE || opcode == TRAPA_UNWINDER_BUG_OPCODE)
|
|
|
+ if (opcode == TRAPA_BUG_OPCODE)
|
|
|
return 1;
|
|
|
|
|
|
return 0;
|