Skip to content

Commit 1ddba02

Browse files
committed
CRIS: Minor generic kernel/traps.c changes.
- Collect extern declarations at top of file. - Change raw_printk to printk, use oops_in_progress instead. - Fix formatting and whitespace. - Allow the watchdog to be disabled during oops.
1 parent 3e1fdc4 commit 1ddba02

1 file changed

Lines changed: 139 additions & 87 deletions

File tree

‎arch/cris/kernel/traps.c‎

Lines changed: 139 additions & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -1,66 +1,78 @@
1-
/* $Id: traps.c,v 1.11 2005/01/24 16:03:19 orjanf Exp $
2-
*
1+
/*
32
* linux/arch/cris/traps.c
43
*
5-
* Here we handle the break vectors not used by the system call
6-
* mechanism, as well as some general stack/register dumping
4+
* Here we handle the break vectors not used by the system call
5+
* mechanism, as well as some general stack/register dumping
76
* things.
8-
*
9-
* Copyright (C) 2000-2002 Axis Communications AB
7+
*
8+
* Copyright (C) 2000-2007 Axis Communications AB
109
*
1110
* Authors: Bjorn Wesen
12-
* Hans-Peter Nilsson
11+
* Hans-Peter Nilsson
1312
*
1413
*/
1514

1615
#include <linux/init.h>
1716
#include <linux/module.h>
17+
1818
#include <asm/pgtable.h>
1919
#include <asm/uaccess.h>
2020

21+
extern void arch_enable_nmi(void);
22+
extern void stop_watchdog(void);
23+
extern void reset_watchdog(void);
24+
extern void show_registers(struct pt_regs *regs);
25+
26+
#ifdef CONFIG_DEBUG_BUGVERBOSE
27+
extern void handle_BUG(struct pt_regs *regs);
28+
#else
29+
#define handle_BUG(regs)
30+
#endif
31+
2132
static int kstack_depth_to_print = 24;
2233

23-
extern int raw_printk(const char *fmt, ...);
34+
void (*nmi_handler)(struct pt_regs *);
2435

25-
void show_trace(unsigned long * stack)
36+
void
37+
show_trace(unsigned long *stack)
2638
{
2739
unsigned long addr, module_start, module_end;
2840
extern char _stext, _etext;
2941
int i;
3042

31-
raw_printk("\nCall Trace: ");
43+
printk("\nCall Trace: ");
3244

33-
i = 1;
34-
module_start = VMALLOC_START;
35-
module_end = VMALLOC_END;
45+
i = 1;
46+
module_start = VMALLOC_START;
47+
module_end = VMALLOC_END;
3648

37-
while (((long) stack & (THREAD_SIZE-1)) != 0) {
38-
if (__get_user (addr, stack)) {
49+
while (((long)stack & (THREAD_SIZE-1)) != 0) {
50+
if (__get_user(addr, stack)) {
3951
/* This message matches "failing address" marked
4052
s390 in ksymoops, so lines containing it will
4153
not be filtered out by ksymoops. */
42-
raw_printk ("Failing address 0x%lx\n", (unsigned long)stack);
54+
printk("Failing address 0x%lx\n", (unsigned long)stack);
4355
break;
4456
}
4557
stack++;
4658

47-
/*
48-
* If the address is either in the text segment of the
49-
* kernel, or in the region which contains vmalloc'ed
50-
* memory, it *may* be the address of a calling
51-
* routine; if so, print it so that someone tracing
52-
* down the cause of the crash will be able to figure
53-
* out the call path that was taken.
54-
*/
55-
if (((addr >= (unsigned long) &_stext) &&
56-
(addr <= (unsigned long) &_etext)) ||
57-
((addr >= module_start) && (addr <= module_end))) {
58-
if (i && ((i % 8) == 0))
59-
raw_printk("\n ");
60-
raw_printk("[<%08lx>] ", addr);
61-
i++;
62-
}
63-
}
59+
/*
60+
* If the address is either in the text segment of the
61+
* kernel, or in the region which contains vmalloc'ed
62+
* memory, it *may* be the address of a calling
63+
* routine; if so, print it so that someone tracing
64+
* down the cause of the crash will be able to figure
65+
* out the call path that was taken.
66+
*/
67+
if (((addr >= (unsigned long)&_stext) &&
68+
(addr <= (unsigned long)&_etext)) ||
69+
((addr >= module_start) && (addr <= module_end))) {
70+
if (i && ((i % 8) == 0))
71+
printk("\n ");
72+
printk("[<%08lx>] ", addr);
73+
i++;
74+
}
75+
}
6476
}
6577

6678
/*
@@ -78,109 +90,149 @@ void show_trace(unsigned long * stack)
7890
* with the ksymoops maintainer.
7991
*/
8092

81-
void
93+
void
8294
show_stack(struct task_struct *task, unsigned long *sp)
8395
{
84-
unsigned long *stack, addr;
85-
int i;
96+
unsigned long *stack, addr;
97+
int i;
8698

8799
/*
88100
* debugging aid: "show_stack(NULL);" prints a
89101
* back trace.
90102
*/
91103

92-
if(sp == NULL) {
104+
if (sp == NULL) {
93105
if (task)
94106
sp = (unsigned long*)task->thread.ksp;
95107
else
96108
sp = (unsigned long*)rdsp();
97109
}
98110

99-
stack = sp;
111+
stack = sp;
100112

101-
raw_printk("\nStack from %08lx:\n ", (unsigned long)stack);
102-
for(i = 0; i < kstack_depth_to_print; i++) {
103-
if (((long) stack & (THREAD_SIZE-1)) == 0)
104-
break;
105-
if (i && ((i % 8) == 0))
106-
raw_printk("\n ");
107-
if (__get_user (addr, stack)) {
113+
printk("\nStack from %08lx:\n ", (unsigned long)stack);
114+
for (i = 0; i < kstack_depth_to_print; i++) {
115+
if (((long)stack & (THREAD_SIZE-1)) == 0)
116+
break;
117+
if (i && ((i % 8) == 0))
118+
printk("\n ");
119+
if (__get_user(addr, stack)) {
108120
/* This message matches "failing address" marked
109121
s390 in ksymoops, so lines containing it will
110122
not be filtered out by ksymoops. */
111-
raw_printk ("Failing address 0x%lx\n", (unsigned long)stack);
123+
printk("Failing address 0x%lx\n", (unsigned long)stack);
112124
break;
113125
}
114126
stack++;
115-
raw_printk("%08lx ", addr);
116-
}
127+
printk("%08lx ", addr);
128+
}
117129
show_trace(sp);
118130
}
119131

120-
static void (*nmi_handler)(struct pt_regs*);
121-
extern void arch_enable_nmi(void);
132+
#if 0
133+
/* displays a short stack trace */
122134

123-
void set_nmi_handler(void (*handler)(struct pt_regs*))
135+
int
136+
show_stack(void)
124137
{
125-
nmi_handler = handler;
126-
arch_enable_nmi();
138+
unsigned long *sp = (unsigned long *)rdusp();
139+
int i;
140+
141+
printk("Stack dump [0x%08lx]:\n", (unsigned long)sp);
142+
for (i = 0; i < 16; i++)
143+
printk("sp + %d: 0x%08lx\n", i*4, sp[i]);
144+
return 0;
127145
}
146+
#endif
128147

129-
void handle_nmi(struct pt_regs* regs)
148+
void
149+
dump_stack(void)
130150
{
131-
if (nmi_handler)
132-
nmi_handler(regs);
151+
show_stack(NULL, NULL);
152+
}
153+
EXPORT_SYMBOL(dump_stack);
154+
155+
void
156+
set_nmi_handler(void (*handler)(struct pt_regs *))
157+
{
158+
nmi_handler = handler;
159+
arch_enable_nmi();
133160
}
134161

135162
#ifdef CONFIG_DEBUG_NMI_OOPS
136-
void oops_nmi_handler(struct pt_regs* regs)
163+
void
164+
oops_nmi_handler(struct pt_regs *regs)
137165
{
138-
stop_watchdog();
139-
raw_printk("NMI!\n");
140-
show_registers(regs);
166+
stop_watchdog();
167+
oops_in_progress = 1;
168+
printk("NMI!\n");
169+
show_registers(regs);
170+
oops_in_progress = 0;
141171
}
142172

143-
static int
144-
__init oops_nmi_register(void)
173+
static int __init
174+
oops_nmi_register(void)
145175
{
146-
set_nmi_handler(oops_nmi_handler);
147-
return 0;
176+
set_nmi_handler(oops_nmi_handler);
177+
return 0;
148178
}
149179

150180
__initcall(oops_nmi_register);
151181

152182
#endif
153183

154-
#if 0
155-
/* displays a short stack trace */
156-
157-
int
158-
show_stack()
184+
/*
185+
* This gets called from entry.S when the watchdog has bitten. Show something
186+
* similiar to an Oops dump, and if the kernel is configured to be a nice
187+
* doggy, then halt instead of reboot.
188+
*/
189+
void
190+
watchdog_bite_hook(struct pt_regs *regs)
159191
{
160-
unsigned long *sp = (unsigned long *)rdusp();
161-
int i;
162-
raw_printk("Stack dump [0x%08lx]:\n", (unsigned long)sp);
163-
for(i = 0; i < 16; i++)
164-
raw_printk("sp + %d: 0x%08lx\n", i*4, sp[i]);
165-
return 0;
166-
}
192+
#ifdef CONFIG_ETRAX_WATCHDOG_NICE_DOGGY
193+
local_irq_disable();
194+
stop_watchdog();
195+
show_registers(regs);
196+
197+
while (1)
198+
; /* Do nothing. */
199+
#else
200+
show_registers(regs);
167201
#endif
202+
}
168203

169-
void dump_stack(void)
204+
/* This is normally the Oops function. */
205+
void
206+
die_if_kernel(const char *str, struct pt_regs *regs, long err)
170207
{
171-
show_stack(NULL, NULL);
172-
}
208+
if (user_mode(regs))
209+
return;
173210

174-
EXPORT_SYMBOL(dump_stack);
211+
#ifdef CONFIG_ETRAX_WATCHDOG_NICE_DOGGY
212+
/*
213+
* This printout might take too long and could trigger
214+
* the watchdog normally. If NICE_DOGGY is set, simply
215+
* stop the watchdog during the printout.
216+
*/
217+
stop_watchdog();
218+
#endif
175219

176-
void __init
177-
trap_init(void)
178-
{
179-
/* Nothing needs to be done */
220+
handle_BUG(regs);
221+
222+
printk("%s: %04lx\n", str, err & 0xffff);
223+
224+
show_registers(regs);
225+
226+
oops_in_progress = 0;
227+
228+
#ifdef CONFIG_ETRAX_WATCHDOG_NICE_DOGGY
229+
reset_watchdog();
230+
#endif
231+
do_exit(SIGSEGV);
180232
}
181233

182-
void spinning_cpu(void* addr)
234+
void __init
235+
trap_init(void)
183236
{
184-
raw_printk("CPU %d spinning on %X\n", smp_processor_id(), addr);
185-
dump_stack();
237+
/* Nothing needs to be done */
186238
}

0 commit comments

Comments
 (0)