powerpc/jump_label: Annotate jump label assembly
[linux/fpc-iii.git] / arch / cris / kernel / traps.c
blobda4c72401e277f66ccfea6661a654a9f4a5d585e
1 /*
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
6 * things.
8 * Copyright (C) 2000-2007 Axis Communications AB
10 * Authors: Bjorn Wesen
11 * Hans-Peter Nilsson
15 #include <linux/init.h>
16 #include <linux/module.h>
17 #include <linux/utsname.h>
18 #ifdef CONFIG_KALLSYMS
19 #include <linux/kallsyms.h>
20 #endif
22 #include <asm/pgtable.h>
23 #include <asm/uaccess.h>
24 #include <arch/system.h>
26 extern void arch_enable_nmi(void);
27 extern void stop_watchdog(void);
28 extern void reset_watchdog(void);
29 extern void show_registers(struct pt_regs *regs);
31 #ifdef CONFIG_DEBUG_BUGVERBOSE
32 extern void handle_BUG(struct pt_regs *regs);
33 #else
34 #define handle_BUG(regs)
35 #endif
37 static int kstack_depth_to_print = 24;
39 void (*nmi_handler)(struct pt_regs *);
41 void show_trace(unsigned long *stack)
43 unsigned long addr, module_start, module_end;
44 extern char _stext, _etext;
45 int i;
47 pr_err("\nCall Trace: ");
49 i = 1;
50 module_start = VMALLOC_START;
51 module_end = VMALLOC_END;
53 while (((long)stack & (THREAD_SIZE - 1)) != 0) {
54 if (__get_user(addr, stack)) {
55 /* This message matches "failing address" marked
56 s390 in ksymoops, so lines containing it will
57 not be filtered out by ksymoops. */
58 pr_err("Failing address 0x%lx\n", (unsigned long)stack);
59 break;
61 stack++;
64 * If the address is either in the text segment of the
65 * kernel, or in the region which contains vmalloc'ed
66 * memory, it *may* be the address of a calling
67 * routine; if so, print it so that someone tracing
68 * down the cause of the crash will be able to figure
69 * out the call path that was taken.
71 if (((addr >= (unsigned long)&_stext) &&
72 (addr <= (unsigned long)&_etext)) ||
73 ((addr >= module_start) && (addr <= module_end))) {
74 #ifdef CONFIG_KALLSYMS
75 print_ip_sym(addr);
76 #else
77 if (i && ((i % 8) == 0))
78 pr_err("\n ");
79 pr_err("[<%08lx>] ", addr);
80 i++;
81 #endif
87 * These constants are for searching for possible module text
88 * segments. MODULE_RANGE is a guess of how much space is likely
89 * to be vmalloced.
92 #define MODULE_RANGE (8*1024*1024)
95 * The output (format, strings and order) is adjusted to be usable with
96 * ksymoops-2.4.1 with some necessary CRIS-specific patches. Please don't
97 * change it unless you're serious about adjusting ksymoops and syncing
98 * with the ksymoops maintainer.
101 void
102 show_stack(struct task_struct *task, unsigned long *sp)
104 unsigned long *stack, addr;
105 int i;
108 * debugging aid: "show_stack(NULL);" prints a
109 * back trace.
112 if (sp == NULL) {
113 if (task)
114 sp = (unsigned long*)task->thread.ksp;
115 else
116 sp = (unsigned long*)rdsp();
119 stack = sp;
121 pr_err("\nStack from %08lx:\n ", (unsigned long)stack);
122 for (i = 0; i < kstack_depth_to_print; i++) {
123 if (((long)stack & (THREAD_SIZE-1)) == 0)
124 break;
125 if (i && ((i % 8) == 0))
126 pr_err("\n ");
127 if (__get_user(addr, stack)) {
128 /* This message matches "failing address" marked
129 s390 in ksymoops, so lines containing it will
130 not be filtered out by ksymoops. */
131 pr_err("Failing address 0x%lx\n", (unsigned long)stack);
132 break;
134 stack++;
135 pr_err("%08lx ", addr);
137 show_trace(sp);
140 #if 0
141 /* displays a short stack trace */
144 show_stack(void)
146 unsigned long *sp = (unsigned long *)rdusp();
147 int i;
149 pr_err("Stack dump [0x%08lx]:\n", (unsigned long)sp);
150 for (i = 0; i < 16; i++)
151 pr_err("sp + %d: 0x%08lx\n", i*4, sp[i]);
152 return 0;
154 #endif
156 void set_nmi_handler(void (*handler)(struct pt_regs *))
158 nmi_handler = handler;
159 arch_enable_nmi();
162 #ifdef CONFIG_DEBUG_NMI_OOPS
163 void oops_nmi_handler(struct pt_regs *regs)
165 stop_watchdog();
166 oops_in_progress = 1;
167 pr_err("NMI!\n");
168 show_registers(regs);
169 oops_in_progress = 0;
170 oops_exit();
171 pr_err("\n"); /* Flush mtdoops. */
174 static int __init oops_nmi_register(void)
176 set_nmi_handler(oops_nmi_handler);
177 return 0;
180 __initcall(oops_nmi_register);
182 #endif
185 * This gets called from entry.S when the watchdog has bitten. Show something
186 * similar to an Oops dump, and if the kernel is configured to be a nice
187 * doggy, then halt instead of reboot.
189 void watchdog_bite_hook(struct pt_regs *regs)
191 #ifdef CONFIG_ETRAX_WATCHDOG_NICE_DOGGY
192 local_irq_disable();
193 stop_watchdog();
194 show_registers(regs);
196 while (1)
197 ; /* Do nothing. */
198 #else
199 show_registers(regs);
200 #endif
203 /* This is normally the Oops function. */
204 void die_if_kernel(const char *str, struct pt_regs *regs, long err)
206 if (user_mode(regs))
207 return;
209 #ifdef CONFIG_ETRAX_WATCHDOG_NICE_DOGGY
211 * This printout might take too long and could trigger
212 * the watchdog normally. If NICE_DOGGY is set, simply
213 * stop the watchdog during the printout.
215 stop_watchdog();
216 #endif
218 oops_enter();
219 handle_BUG(regs);
221 pr_err("Linux %s %s\n", utsname()->release, utsname()->version);
222 pr_err("%s: %04lx\n", str, err & 0xffff);
224 show_registers(regs);
226 oops_exit();
227 oops_in_progress = 0;
228 pr_err("\n"); /* Flush mtdoops. */
230 #ifdef CONFIG_ETRAX_WATCHDOG_NICE_DOGGY
231 reset_watchdog();
232 #endif
233 do_exit(SIGSEGV);
236 void __init trap_init(void)
238 /* Nothing needs to be done */