20 #include <linux/signal.h>
21 #include <linux/personality.h>
27 #include <linux/module.h>
28 #include <linux/kexec.h>
31 #include <linux/sched.h>
34 #include <asm/atomic.h>
35 #include <asm/traps.h>
36 #include <asm/stacktrace.h>
37 #include <asm/exception.h>
38 #include <asm/system_misc.h>
40 static const char *handler[]= {
52 static void dump_mem(
const char *lvl,
const char *
str,
unsigned long bottom,
67 printk(
"%s%s(0x%016lx to 0x%016lx)\n", lvl, str, bottom, top);
69 for (first = bottom & ~31; first <
top; first += 32) {
71 char str[
sizeof(
" 12345678") * 8 + 1];
73 memset(str,
' ',
sizeof(str));
74 str[
sizeof(
str) - 1] =
'\0';
76 for (p = first, i = 0; i < 8 && p <
top; i++, p += 4) {
77 if (p >= bottom && p < top) {
80 sprintf(str + i * 9,
" %08x", val);
82 sprintf(str + i * 9,
" ????????");
85 printk(
"%s%04lx:%s\n", lvl, first & 0xffff, str);
94 if (in_exception_text(where))
95 dump_mem(
"",
"Exception stack", stack,
96 stack +
sizeof(
struct pt_regs));
99 static void dump_instr(
const char *lvl,
struct pt_regs *
regs)
103 char str[
sizeof(
"00000000 ") * 5 + 2 + 1], *
p =
str;
114 for (i = -4; i < 1; i++) {
120 p +=
sprintf(
p, i == 0 ?
"(%08x) " :
"%08x ", val);
134 const register unsigned long current_sp
asm (
"sp");
136 pr_debug(
"%s(regs = %p tsk = %p)\n", __func__, regs, tsk);
146 frame.fp = (
unsigned long)__builtin_frame_address(0);
147 frame.sp = current_sp;
153 frame.fp = thread_saved_fp(tsk);
154 frame.sp = thread_saved_sp(tsk);
160 unsigned long where =
frame.
pc;
179 dump_backtrace(
NULL, tsk);
183 #ifdef CONFIG_PREEMPT
184 #define S_PREEMPT " PREEMPT"
198 static int die_counter;
202 str, err, ++die_counter);
206 if (ret == NOTIFY_STOP)
211 pr_emerg(
"Process %.*s (pid: %d, stack limit = 0x%p)\n",
217 dump_backtrace(regs, tsk);
239 ret = __die(str, err, thread, regs);
250 panic(
"Fatal exception in interrupt");
252 panic(
"Fatal exception");
253 if (ret != NOTIFY_STOP)
278 pr_info(
"%s[%d]: undefined instruction: pc=%p\n",
307 dump_instr(
"", regs);
322 pr_crit(
"Bad mode in %s handler detected, code 0x%08x\n",
323 handler[reason], esr);
325 die(
"Oops - bad mode", regs, 0);
332 printk(
"%s:%d: bad pte %016lx.\n", file, line, val);
337 printk(
"%s:%d: bad pmd %016lx.\n", file, line, val);
342 printk(
"%s:%d: bad pgd %016lx.\n", file, line, val);