aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/panic.c
diff options
context:
space:
mode:
authorIngo Molnar <mingo@elte.hu>2009-03-13 06:14:06 -0400
committerIngo Molnar <mingo@elte.hu>2009-03-13 06:25:53 -0400
commitc95dbf27e201587b2a6cf63f8501a0313d9b4801 (patch)
tree305eb239751b1bbfc7b9f3f9a2053cfc8e365eea /kernel/panic.c
parentd1dedb52acd98bd5e13e1ff4c4d045d58bbd16fe (diff)
panic: clean up kernel/panic.c
Impact: cleanup, no code changed Clean up kernel/panic.c some more and make it more consistent. LKML-Reference: <49B91A7E.76E4.0078.0@novell.com> Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'kernel/panic.c')
-rw-r--r--kernel/panic.c111
1 files changed, 59 insertions, 52 deletions
diff --git a/kernel/panic.c b/kernel/panic.c
index ca75e819d0ea..3fd8c5bf8b39 100644
--- a/kernel/panic.c
+++ b/kernel/panic.c
@@ -8,19 +8,19 @@
8 * This function is used through-out the kernel (including mm and fs) 8 * This function is used through-out the kernel (including mm and fs)
9 * to indicate a major problem. 9 * to indicate a major problem.
10 */ 10 */
11#include <linux/debug_locks.h>
12#include <linux/interrupt.h>
13#include <linux/kallsyms.h>
14#include <linux/notifier.h>
11#include <linux/module.h> 15#include <linux/module.h>
12#include <linux/sched.h> 16#include <linux/random.h>
13#include <linux/delay.h>
14#include <linux/reboot.h> 17#include <linux/reboot.h>
15#include <linux/notifier.h> 18#include <linux/delay.h>
16#include <linux/init.h> 19#include <linux/kexec.h>
20#include <linux/sched.h>
17#include <linux/sysrq.h> 21#include <linux/sysrq.h>
18#include <linux/interrupt.h> 22#include <linux/init.h>
19#include <linux/nmi.h> 23#include <linux/nmi.h>
20#include <linux/kexec.h>
21#include <linux/debug_locks.h>
22#include <linux/random.h>
23#include <linux/kallsyms.h>
24#include <linux/dmi.h> 24#include <linux/dmi.h>
25 25
26int panic_on_oops; 26int panic_on_oops;
@@ -52,19 +52,15 @@ EXPORT_SYMBOL(panic_blink);
52 * 52 *
53 * This function never returns. 53 * This function never returns.
54 */ 54 */
55
56NORET_TYPE void panic(const char * fmt, ...) 55NORET_TYPE void panic(const char * fmt, ...)
57{ 56{
58 long i;
59 static char buf[1024]; 57 static char buf[1024];
60 va_list args; 58 va_list args;
61#if defined(CONFIG_S390) 59 long i;
62 unsigned long caller = (unsigned long) __builtin_return_address(0);
63#endif
64 60
65 /* 61 /*
66 * It's possible to come here directly from a panic-assertion and not 62 * It's possible to come here directly from a panic-assertion and
67 * have preempt disabled. Some functions called from here want 63 * not have preempt disabled. Some functions called from here want
68 * preempt to be disabled. No point enabling it later though... 64 * preempt to be disabled. No point enabling it later though...
69 */ 65 */
70 preempt_disable(); 66 preempt_disable();
@@ -99,19 +95,21 @@ NORET_TYPE void panic(const char * fmt, ...)
99 95
100 if (panic_timeout > 0) { 96 if (panic_timeout > 0) {
101 /* 97 /*
102 * Delay timeout seconds before rebooting the machine. 98 * Delay timeout seconds before rebooting the machine.
103 * We can't use the "normal" timers since we just panicked.. 99 * We can't use the "normal" timers since we just panicked.
104 */ 100 */
105 printk(KERN_EMERG "Rebooting in %d seconds..",panic_timeout); 101 printk(KERN_EMERG "Rebooting in %d seconds..", panic_timeout);
102
106 for (i = 0; i < panic_timeout*1000; ) { 103 for (i = 0; i < panic_timeout*1000; ) {
107 touch_nmi_watchdog(); 104 touch_nmi_watchdog();
108 i += panic_blink(i); 105 i += panic_blink(i);
109 mdelay(1); 106 mdelay(1);
110 i++; 107 i++;
111 } 108 }
112 /* This will not be a clean reboot, with everything 109 /*
113 * shutting down. But if there is a chance of 110 * This will not be a clean reboot, with everything
114 * rebooting the system it will be rebooted. 111 * shutting down. But if there is a chance of
112 * rebooting the system it will be rebooted.
115 */ 113 */
116 emergency_restart(); 114 emergency_restart();
117 } 115 }
@@ -124,10 +122,15 @@ NORET_TYPE void panic(const char * fmt, ...)
124 } 122 }
125#endif 123#endif
126#if defined(CONFIG_S390) 124#if defined(CONFIG_S390)
127 disabled_wait(caller); 125 {
126 unsigned long caller;
127
128 caller = (unsigned long)__builtin_return_address(0);
129 disabled_wait(caller);
130 }
128#endif 131#endif
129 local_irq_enable(); 132 local_irq_enable();
130 for (i = 0;;) { 133 for (i = 0; ; ) {
131 touch_softlockup_watchdog(); 134 touch_softlockup_watchdog();
132 i += panic_blink(i); 135 i += panic_blink(i);
133 mdelay(1); 136 mdelay(1);
@@ -140,23 +143,23 @@ EXPORT_SYMBOL(panic);
140 143
141 144
142struct tnt { 145struct tnt {
143 u8 bit; 146 u8 bit;
144 char true; 147 char true;
145 char false; 148 char false;
146}; 149};
147 150
148static const struct tnt tnts[] = { 151static const struct tnt tnts[] = {
149 { TAINT_PROPRIETARY_MODULE, 'P', 'G' }, 152 { TAINT_PROPRIETARY_MODULE, 'P', 'G' },
150 { TAINT_FORCED_MODULE, 'F', ' ' }, 153 { TAINT_FORCED_MODULE, 'F', ' ' },
151 { TAINT_UNSAFE_SMP, 'S', ' ' }, 154 { TAINT_UNSAFE_SMP, 'S', ' ' },
152 { TAINT_FORCED_RMMOD, 'R', ' ' }, 155 { TAINT_FORCED_RMMOD, 'R', ' ' },
153 { TAINT_MACHINE_CHECK, 'M', ' ' }, 156 { TAINT_MACHINE_CHECK, 'M', ' ' },
154 { TAINT_BAD_PAGE, 'B', ' ' }, 157 { TAINT_BAD_PAGE, 'B', ' ' },
155 { TAINT_USER, 'U', ' ' }, 158 { TAINT_USER, 'U', ' ' },
156 { TAINT_DIE, 'D', ' ' }, 159 { TAINT_DIE, 'D', ' ' },
157 { TAINT_OVERRIDDEN_ACPI_TABLE, 'A', ' ' }, 160 { TAINT_OVERRIDDEN_ACPI_TABLE, 'A', ' ' },
158 { TAINT_WARN, 'W', ' ' }, 161 { TAINT_WARN, 'W', ' ' },
159 { TAINT_CRAP, 'C', ' ' }, 162 { TAINT_CRAP, 'C', ' ' },
160}; 163};
161 164
162/** 165/**
@@ -193,7 +196,8 @@ const char *print_tainted(void)
193 *s = 0; 196 *s = 0;
194 } else 197 } else
195 snprintf(buf, sizeof(buf), "Not tainted"); 198 snprintf(buf, sizeof(buf), "Not tainted");
196 return(buf); 199
200 return buf;
197} 201}
198 202
199int test_taint(unsigned flag) 203int test_taint(unsigned flag)
@@ -209,7 +213,8 @@ unsigned long get_taint(void)
209 213
210void add_taint(unsigned flag) 214void add_taint(unsigned flag)
211{ 215{
212 debug_locks = 0; /* can't trust the integrity of the kernel anymore */ 216 /* can't trust the integrity of the kernel anymore: */
217 debug_locks = 0;
213 set_bit(flag, &tainted_mask); 218 set_bit(flag, &tainted_mask);
214} 219}
215EXPORT_SYMBOL(add_taint); 220EXPORT_SYMBOL(add_taint);
@@ -264,8 +269,8 @@ static void do_oops_enter_exit(void)
264} 269}
265 270
266/* 271/*
267 * Return true if the calling CPU is allowed to print oops-related info. This 272 * Return true if the calling CPU is allowed to print oops-related info.
268 * is a bit racy.. 273 * This is a bit racy..
269 */ 274 */
270int oops_may_print(void) 275int oops_may_print(void)
271{ 276{
@@ -274,20 +279,22 @@ int oops_may_print(void)
274 279
275/* 280/*
276 * Called when the architecture enters its oops handler, before it prints 281 * Called when the architecture enters its oops handler, before it prints
277 * anything. If this is the first CPU to oops, and it's oopsing the first time 282 * anything. If this is the first CPU to oops, and it's oopsing the first
278 * then let it proceed. 283 * time then let it proceed.
279 * 284 *
280 * This is all enabled by the pause_on_oops kernel boot option. We do all this 285 * This is all enabled by the pause_on_oops kernel boot option. We do all
281 * to ensure that oopses don't scroll off the screen. It has the side-effect 286 * this to ensure that oopses don't scroll off the screen. It has the
282 * of preventing later-oopsing CPUs from mucking up the display, too. 287 * side-effect of preventing later-oopsing CPUs from mucking up the display,
288 * too.
283 * 289 *
284 * It turns out that the CPU which is allowed to print ends up pausing for the 290 * It turns out that the CPU which is allowed to print ends up pausing for
285 * right duration, whereas all the other CPUs pause for twice as long: once in 291 * the right duration, whereas all the other CPUs pause for twice as long:
286 * oops_enter(), once in oops_exit(). 292 * once in oops_enter(), once in oops_exit().
287 */ 293 */
288void oops_enter(void) 294void oops_enter(void)
289{ 295{
290 debug_locks_off(); /* can't trust the integrity of the kernel anymore */ 296 /* can't trust the integrity of the kernel anymore: */
297 debug_locks_off();
291 do_oops_enter_exit(); 298 do_oops_enter_exit();
292} 299}
293 300