3 #include <linux/types.h>
4 #include <linux/kdebug.h>
5 #include <linux/signal.h>
6 #include <linux/sched.h>
7 #include <linux/uaccess.h>
8 #include <asm/system.h>
11 void handle_BUG(struct pt_regs
*regs
)
13 enum bug_trap_type tt
;
14 tt
= report_bug(regs
->pc
, regs
);
15 if (tt
== BUG_TRAP_TYPE_WARN
) {
16 regs
->pc
+= instruction_size(regs
->pc
);
20 die("Kernel BUG", regs
, TRAPA_BUG_OPCODE
& 0xff);
23 int is_valid_bugaddr(unsigned long addr
)
27 if (addr
< PAGE_OFFSET
)
29 if (probe_kernel_address((insn_size_t
*)addr
, opcode
))
32 if (opcode
== TRAPA_BUG_OPCODE
|| opcode
== TRAPA_UNWINDER_BUG_OPCODE
)
40 * Generic trap handler.
42 BUILD_TRAP_HANDLER(debug
)
47 regs
->pc
-= instruction_size(ctrl_inw(regs
->pc
- 4));
49 if (notify_die(DIE_TRAP
, "debug trap", regs
, 0, vec
& 0xff,
50 SIGTRAP
) == NOTIFY_STOP
)
53 force_sig(SIGTRAP
, current
);
57 * Special handler for BUG() traps.
59 BUILD_TRAP_HANDLER(bug
)
64 regs
->pc
-= instruction_size(ctrl_inw(regs
->pc
- 4));
66 if (notify_die(DIE_TRAP
, "bug trap", regs
, 0, TRAPA_BUG_OPCODE
& 0xff,
67 SIGTRAP
) == NOTIFY_STOP
)
71 if (__kernel_text_address(instruction_pointer(regs
))) {
72 insn_size_t insn
= *(insn_size_t
*)instruction_pointer(regs
);
73 if (insn
== TRAPA_BUG_OPCODE
)
79 force_sig(SIGTRAP
, current
);