2 * linux/arch/cris/traps.c
4 * Here we handle the break vectors not used by the system call
5 * mechanism, as well as some general stack/register dumping
8 * Copyright (C) 2000-2007 Axis Communications AB
10 * Authors: Bjorn Wesen
15 #include <linux/init.h>
16 #include <linux/module.h>
17 #include <linux/utsname.h>
18 #include <linux/sched/debug.h>
19 #ifdef CONFIG_KALLSYMS
20 #include <linux/kallsyms.h>
23 #include <asm/pgtable.h>
24 #include <linux/uaccess.h>
25 #include <arch/system.h>
27 extern void arch_enable_nmi(void);
28 extern void stop_watchdog(void);
29 extern void reset_watchdog(void);
30 extern void show_registers(struct pt_regs
*regs
);
32 #ifdef CONFIG_DEBUG_BUGVERBOSE
33 extern void handle_BUG(struct pt_regs
*regs
);
35 #define handle_BUG(regs)
38 static int kstack_depth_to_print
= 24;
40 void (*nmi_handler
)(struct pt_regs
*);
42 void show_trace(unsigned long *stack
)
44 unsigned long addr
, module_start
, module_end
;
45 extern char _stext
, _etext
;
48 pr_err("\nCall Trace: ");
51 module_start
= VMALLOC_START
;
52 module_end
= VMALLOC_END
;
54 while (((long)stack
& (THREAD_SIZE
- 1)) != 0) {
55 if (__get_user(addr
, stack
)) {
56 /* This message matches "failing address" marked
57 s390 in ksymoops, so lines containing it will
58 not be filtered out by ksymoops. */
59 pr_err("Failing address 0x%lx\n", (unsigned long)stack
);
65 * If the address is either in the text segment of the
66 * kernel, or in the region which contains vmalloc'ed
67 * memory, it *may* be the address of a calling
68 * routine; if so, print it so that someone tracing
69 * down the cause of the crash will be able to figure
70 * out the call path that was taken.
72 if (((addr
>= (unsigned long)&_stext
) &&
73 (addr
<= (unsigned long)&_etext
)) ||
74 ((addr
>= module_start
) && (addr
<= module_end
))) {
75 #ifdef CONFIG_KALLSYMS
78 if (i
&& ((i
% 8) == 0))
80 pr_err("[<%08lx>] ", addr
);
88 * These constants are for searching for possible module text
89 * segments. MODULE_RANGE is a guess of how much space is likely
93 #define MODULE_RANGE (8*1024*1024)
96 * The output (format, strings and order) is adjusted to be usable with
97 * ksymoops-2.4.1 with some necessary CRIS-specific patches. Please don't
98 * change it unless you're serious about adjusting ksymoops and syncing
99 * with the ksymoops maintainer.
103 show_stack(struct task_struct
*task
, unsigned long *sp
)
105 unsigned long *stack
, addr
;
109 * debugging aid: "show_stack(NULL);" prints a
115 sp
= (unsigned long*)task
->thread
.ksp
;
117 sp
= (unsigned long*)rdsp();
122 pr_err("\nStack from %08lx:\n ", (unsigned long)stack
);
123 for (i
= 0; i
< kstack_depth_to_print
; i
++) {
124 if (((long)stack
& (THREAD_SIZE
-1)) == 0)
126 if (i
&& ((i
% 8) == 0))
128 if (__get_user(addr
, stack
)) {
129 /* This message matches "failing address" marked
130 s390 in ksymoops, so lines containing it will
131 not be filtered out by ksymoops. */
132 pr_err("Failing address 0x%lx\n", (unsigned long)stack
);
136 pr_err("%08lx ", addr
);
142 /* displays a short stack trace */
147 unsigned long *sp
= (unsigned long *)rdusp();
150 pr_err("Stack dump [0x%08lx]:\n", (unsigned long)sp
);
151 for (i
= 0; i
< 16; i
++)
152 pr_err("sp + %d: 0x%08lx\n", i
*4, sp
[i
]);
157 void set_nmi_handler(void (*handler
)(struct pt_regs
*))
159 nmi_handler
= handler
;
163 #ifdef CONFIG_DEBUG_NMI_OOPS
164 void oops_nmi_handler(struct pt_regs
*regs
)
167 oops_in_progress
= 1;
169 show_registers(regs
);
170 oops_in_progress
= 0;
172 pr_err("\n"); /* Flush mtdoops. */
175 static int __init
oops_nmi_register(void)
177 set_nmi_handler(oops_nmi_handler
);
181 __initcall(oops_nmi_register
);
186 * This gets called from entry.S when the watchdog has bitten. Show something
187 * similar to an Oops dump, and if the kernel is configured to be a nice
188 * doggy, then halt instead of reboot.
190 void watchdog_bite_hook(struct pt_regs
*regs
)
192 #ifdef CONFIG_ETRAX_WATCHDOG_NICE_DOGGY
195 show_registers(regs
);
200 show_registers(regs
);
204 /* This is normally the Oops function. */
205 void die_if_kernel(const char *str
, struct pt_regs
*regs
, long err
)
210 #ifdef CONFIG_ETRAX_WATCHDOG_NICE_DOGGY
212 * This printout might take too long and could trigger
213 * the watchdog normally. If NICE_DOGGY is set, simply
214 * stop the watchdog during the printout.
222 pr_err("Linux %s %s\n", utsname()->release
, utsname()->version
);
223 pr_err("%s: %04lx\n", str
, err
& 0xffff);
225 show_registers(regs
);
228 oops_in_progress
= 0;
229 pr_err("\n"); /* Flush mtdoops. */
231 #ifdef CONFIG_ETRAX_WATCHDOG_NICE_DOGGY
237 void __init
trap_init(void)
239 /* Nothing needs to be done */