Blame view
arch/cris/kernel/traps.c
5.12 KB
1ddba0257
|
1 |
/* |
1da177e4c
|
2 3 |
* linux/arch/cris/traps.c * |
1ddba0257
|
4 5 |
* Here we handle the break vectors not used by the system call * mechanism, as well as some general stack/register dumping |
1da177e4c
|
6 |
* things. |
1ddba0257
|
7 8 |
* * Copyright (C) 2000-2007 Axis Communications AB |
1da177e4c
|
9 10 |
* * Authors: Bjorn Wesen |
1ddba0257
|
11 |
* Hans-Peter Nilsson |
1da177e4c
|
12 13 14 15 16 |
* */ #include <linux/init.h> #include <linux/module.h> |
421d08525
|
17 18 19 20 |
#include <linux/utsname.h> #ifdef CONFIG_KALLSYMS #include <linux/kallsyms.h> #endif |
1ddba0257
|
21 |
|
1da177e4c
|
22 23 |
#include <asm/pgtable.h> #include <asm/uaccess.h> |
b1a154dbf
|
24 |
#include <arch/system.h> |
1da177e4c
|
25 |
|
1ddba0257
|
26 27 28 29 30 31 32 33 34 35 |
extern void arch_enable_nmi(void); extern void stop_watchdog(void); extern void reset_watchdog(void); extern void show_registers(struct pt_regs *regs); #ifdef CONFIG_DEBUG_BUGVERBOSE extern void handle_BUG(struct pt_regs *regs); #else #define handle_BUG(regs) #endif |
1da177e4c
|
36 |
static int kstack_depth_to_print = 24; |
1ddba0257
|
37 |
void (*nmi_handler)(struct pt_regs *); |
059163cab
|
38 |
|
421d08525
|
39 |
void show_trace(unsigned long *stack) |
1da177e4c
|
40 41 42 43 |
{ unsigned long addr, module_start, module_end; extern char _stext, _etext; int i; |
421d08525
|
44 45 |
pr_err(" Call Trace: "); |
1da177e4c
|
46 |
|
1ddba0257
|
47 48 49 |
i = 1; module_start = VMALLOC_START; module_end = VMALLOC_END; |
1da177e4c
|
50 |
|
421d08525
|
51 |
while (((long)stack & (THREAD_SIZE - 1)) != 0) { |
1ddba0257
|
52 |
if (__get_user(addr, stack)) { |
1da177e4c
|
53 54 55 |
/* This message matches "failing address" marked s390 in ksymoops, so lines containing it will not be filtered out by ksymoops. */ |
421d08525
|
56 57 |
pr_err("Failing address 0x%lx ", (unsigned long)stack); |
1da177e4c
|
58 59 60 |
break; } stack++; |
1ddba0257
|
61 62 63 64 65 66 67 68 69 70 71 |
/* * If the address is either in the text segment of the * kernel, or in the region which contains vmalloc'ed * memory, it *may* be the address of a calling * routine; if so, print it so that someone tracing * down the cause of the crash will be able to figure * out the call path that was taken. */ if (((addr >= (unsigned long)&_stext) && (addr <= (unsigned long)&_etext)) || ((addr >= module_start) && (addr <= module_end))) { |
421d08525
|
72 73 74 |
#ifdef CONFIG_KALLSYMS print_ip_sym(addr); #else |
1ddba0257
|
75 |
if (i && ((i % 8) == 0)) |
421d08525
|
76 77 78 |
pr_err(" "); pr_err("[<%08lx>] ", addr); |
1ddba0257
|
79 |
i++; |
421d08525
|
80 |
#endif |
1ddba0257
|
81 82 |
} } |
1da177e4c
|
83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 |
} /* * These constants are for searching for possible module text * segments. MODULE_RANGE is a guess of how much space is likely * to be vmalloced. */ #define MODULE_RANGE (8*1024*1024) /* * The output (format, strings and order) is adjusted to be usable with * ksymoops-2.4.1 with some necessary CRIS-specific patches. Please don't * change it unless you're serious about adjusting ksymoops and syncing * with the ksymoops maintainer. */ |
1ddba0257
|
99 |
void |
1da177e4c
|
100 101 |
show_stack(struct task_struct *task, unsigned long *sp) { |
1ddba0257
|
102 103 |
unsigned long *stack, addr; int i; |
1da177e4c
|
104 105 106 107 108 |
/* * debugging aid: "show_stack(NULL);" prints a * back trace. */ |
1ddba0257
|
109 |
if (sp == NULL) { |
1da177e4c
|
110 111 112 113 114 |
if (task) sp = (unsigned long*)task->thread.ksp; else sp = (unsigned long*)rdsp(); } |
1ddba0257
|
115 |
stack = sp; |
1da177e4c
|
116 |
|
421d08525
|
117 118 119 |
pr_err(" Stack from %08lx: ", (unsigned long)stack); |
1ddba0257
|
120 121 122 123 |
for (i = 0; i < kstack_depth_to_print; i++) { if (((long)stack & (THREAD_SIZE-1)) == 0) break; if (i && ((i % 8) == 0)) |
421d08525
|
124 125 |
pr_err(" "); |
1ddba0257
|
126 |
if (__get_user(addr, stack)) { |
1da177e4c
|
127 128 129 |
/* This message matches "failing address" marked s390 in ksymoops, so lines containing it will not be filtered out by ksymoops. */ |
421d08525
|
130 131 |
pr_err("Failing address 0x%lx ", (unsigned long)stack); |
1da177e4c
|
132 133 134 |
break; } stack++; |
421d08525
|
135 |
pr_err("%08lx ", addr); |
1ddba0257
|
136 |
} |
1da177e4c
|
137 138 |
show_trace(sp); } |
1ddba0257
|
139 140 |
#if 0 /* displays a short stack trace */ |
059163cab
|
141 |
|
1ddba0257
|
142 143 |
int show_stack(void) |
059163cab
|
144 |
{ |
1ddba0257
|
145 146 |
unsigned long *sp = (unsigned long *)rdusp(); int i; |
421d08525
|
147 148 |
pr_err("Stack dump [0x%08lx]: ", (unsigned long)sp); |
1ddba0257
|
149 |
for (i = 0; i < 16; i++) |
421d08525
|
150 151 |
pr_err("sp + %d: 0x%08lx ", i*4, sp[i]); |
1ddba0257
|
152 |
return 0; |
059163cab
|
153 |
} |
1ddba0257
|
154 |
#endif |
059163cab
|
155 |
|
421d08525
|
156 |
void set_nmi_handler(void (*handler)(struct pt_regs *)) |
1ddba0257
|
157 158 159 |
{ nmi_handler = handler; arch_enable_nmi(); |
059163cab
|
160 161 162 |
} #ifdef CONFIG_DEBUG_NMI_OOPS |
421d08525
|
163 |
void oops_nmi_handler(struct pt_regs *regs) |
059163cab
|
164 |
{ |
1ddba0257
|
165 166 |
stop_watchdog(); oops_in_progress = 1; |
421d08525
|
167 168 |
pr_err("NMI! "); |
1ddba0257
|
169 170 |
show_registers(regs); oops_in_progress = 0; |
421d08525
|
171 172 173 |
oops_exit(); pr_err(" "); /* Flush mtdoops. */ |
059163cab
|
174 |
} |
421d08525
|
175 |
static int __init oops_nmi_register(void) |
059163cab
|
176 |
{ |
1ddba0257
|
177 178 |
set_nmi_handler(oops_nmi_handler); return 0; |
059163cab
|
179 180 181 182 183 |
} __initcall(oops_nmi_register); #endif |
1ddba0257
|
184 185 |
/* * This gets called from entry.S when the watchdog has bitten. Show something |
25985edce
|
186 |
* similar to an Oops dump, and if the kernel is configured to be a nice |
1ddba0257
|
187 188 |
* doggy, then halt instead of reboot. */ |
421d08525
|
189 |
void watchdog_bite_hook(struct pt_regs *regs) |
1da177e4c
|
190 |
{ |
1ddba0257
|
191 192 193 194 195 196 197 198 199 |
#ifdef CONFIG_ETRAX_WATCHDOG_NICE_DOGGY local_irq_disable(); stop_watchdog(); show_registers(regs); while (1) ; /* Do nothing. */ #else show_registers(regs); |
1da177e4c
|
200 |
#endif |
1ddba0257
|
201 |
} |
1da177e4c
|
202 |
|
1ddba0257
|
203 |
/* This is normally the Oops function. */ |
421d08525
|
204 |
void die_if_kernel(const char *str, struct pt_regs *regs, long err) |
1da177e4c
|
205 |
{ |
1ddba0257
|
206 207 |
if (user_mode(regs)) return; |
1da177e4c
|
208 |
|
1ddba0257
|
209 210 211 212 213 214 215 216 |
#ifdef CONFIG_ETRAX_WATCHDOG_NICE_DOGGY /* * This printout might take too long and could trigger * the watchdog normally. If NICE_DOGGY is set, simply * stop the watchdog during the printout. */ stop_watchdog(); #endif |
1da177e4c
|
217 |
|
421d08525
|
218 |
oops_enter(); |
1ddba0257
|
219 |
handle_BUG(regs); |
421d08525
|
220 221 222 223 |
pr_err("Linux %s %s ", utsname()->release, utsname()->version); pr_err("%s: %04lx ", str, err & 0xffff); |
1ddba0257
|
224 225 |
show_registers(regs); |
421d08525
|
226 |
oops_exit(); |
1ddba0257
|
227 |
oops_in_progress = 0; |
421d08525
|
228 229 |
pr_err(" "); /* Flush mtdoops. */ |
1ddba0257
|
230 231 232 233 234 |
#ifdef CONFIG_ETRAX_WATCHDOG_NICE_DOGGY reset_watchdog(); #endif do_exit(SIGSEGV); |
1da177e4c
|
235 |
} |
059163cab
|
236 |
|
421d08525
|
237 |
void __init trap_init(void) |
059163cab
|
238 |
{ |
1ddba0257
|
239 |
/* Nothing needs to be done */ |
059163cab
|
240 |
} |