diff options
Diffstat (limited to 'kernel/panic.c')
-rw-r--r-- | kernel/panic.c | 123 |
1 files changed, 67 insertions, 56 deletions
diff --git a/kernel/panic.c b/kernel/panic.c index 2a2ff36ff44d..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 | ||
26 | int panic_on_oops; | 26 | int 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 | |||
56 | NORET_TYPE void panic(const char * fmt, ...) | 55 | NORET_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(); |
@@ -74,7 +70,9 @@ NORET_TYPE void panic(const char * fmt, ...) | |||
74 | vsnprintf(buf, sizeof(buf), fmt, args); | 70 | vsnprintf(buf, sizeof(buf), fmt, args); |
75 | va_end(args); | 71 | va_end(args); |
76 | printk(KERN_EMERG "Kernel panic - not syncing: %s\n",buf); | 72 | printk(KERN_EMERG "Kernel panic - not syncing: %s\n",buf); |
77 | bust_spinlocks(0); | 73 | #ifdef CONFIG_DEBUG_BUGVERBOSE |
74 | dump_stack(); | ||
75 | #endif | ||
78 | 76 | ||
79 | /* | 77 | /* |
80 | * If we have crashed and we have a crash kernel loaded let it handle | 78 | * If we have crashed and we have a crash kernel loaded let it handle |
@@ -83,14 +81,12 @@ NORET_TYPE void panic(const char * fmt, ...) | |||
83 | */ | 81 | */ |
84 | crash_kexec(NULL); | 82 | crash_kexec(NULL); |
85 | 83 | ||
86 | #ifdef CONFIG_SMP | ||
87 | /* | 84 | /* |
88 | * Note smp_send_stop is the usual smp shutdown function, which | 85 | * Note smp_send_stop is the usual smp shutdown function, which |
89 | * unfortunately means it may not be hardened to work in a panic | 86 | * unfortunately means it may not be hardened to work in a panic |
90 | * situation. | 87 | * situation. |
91 | */ | 88 | */ |
92 | smp_send_stop(); | 89 | smp_send_stop(); |
93 | #endif | ||
94 | 90 | ||
95 | atomic_notifier_call_chain(&panic_notifier_list, 0, buf); | 91 | atomic_notifier_call_chain(&panic_notifier_list, 0, buf); |
96 | 92 | ||
@@ -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,38 +122,44 @@ 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); |
134 | i++; | 137 | i++; |
135 | } | 138 | } |
139 | bust_spinlocks(0); | ||
136 | } | 140 | } |
137 | 141 | ||
138 | EXPORT_SYMBOL(panic); | 142 | EXPORT_SYMBOL(panic); |
139 | 143 | ||
140 | 144 | ||
141 | struct tnt { | 145 | struct tnt { |
142 | u8 bit; | 146 | u8 bit; |
143 | char true; | 147 | char true; |
144 | char false; | 148 | char false; |
145 | }; | 149 | }; |
146 | 150 | ||
147 | static const struct tnt tnts[] = { | 151 | static const struct tnt tnts[] = { |
148 | { TAINT_PROPRIETARY_MODULE, 'P', 'G' }, | 152 | { TAINT_PROPRIETARY_MODULE, 'P', 'G' }, |
149 | { TAINT_FORCED_MODULE, 'F', ' ' }, | 153 | { TAINT_FORCED_MODULE, 'F', ' ' }, |
150 | { TAINT_UNSAFE_SMP, 'S', ' ' }, | 154 | { TAINT_UNSAFE_SMP, 'S', ' ' }, |
151 | { TAINT_FORCED_RMMOD, 'R', ' ' }, | 155 | { TAINT_FORCED_RMMOD, 'R', ' ' }, |
152 | { TAINT_MACHINE_CHECK, 'M', ' ' }, | 156 | { TAINT_MACHINE_CHECK, 'M', ' ' }, |
153 | { TAINT_BAD_PAGE, 'B', ' ' }, | 157 | { TAINT_BAD_PAGE, 'B', ' ' }, |
154 | { TAINT_USER, 'U', ' ' }, | 158 | { TAINT_USER, 'U', ' ' }, |
155 | { TAINT_DIE, 'D', ' ' }, | 159 | { TAINT_DIE, 'D', ' ' }, |
156 | { TAINT_OVERRIDDEN_ACPI_TABLE, 'A', ' ' }, | 160 | { TAINT_OVERRIDDEN_ACPI_TABLE, 'A', ' ' }, |
157 | { TAINT_WARN, 'W', ' ' }, | 161 | { TAINT_WARN, 'W', ' ' }, |
158 | { TAINT_CRAP, 'C', ' ' }, | 162 | { TAINT_CRAP, 'C', ' ' }, |
159 | }; | 163 | }; |
160 | 164 | ||
161 | /** | 165 | /** |
@@ -192,7 +196,8 @@ const char *print_tainted(void) | |||
192 | *s = 0; | 196 | *s = 0; |
193 | } else | 197 | } else |
194 | snprintf(buf, sizeof(buf), "Not tainted"); | 198 | snprintf(buf, sizeof(buf), "Not tainted"); |
195 | return(buf); | 199 | |
200 | return buf; | ||
196 | } | 201 | } |
197 | 202 | ||
198 | int test_taint(unsigned flag) | 203 | int test_taint(unsigned flag) |
@@ -208,7 +213,8 @@ unsigned long get_taint(void) | |||
208 | 213 | ||
209 | void add_taint(unsigned flag) | 214 | void add_taint(unsigned flag) |
210 | { | 215 | { |
211 | 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; | ||
212 | set_bit(flag, &tainted_mask); | 218 | set_bit(flag, &tainted_mask); |
213 | } | 219 | } |
214 | EXPORT_SYMBOL(add_taint); | 220 | EXPORT_SYMBOL(add_taint); |
@@ -263,8 +269,8 @@ static void do_oops_enter_exit(void) | |||
263 | } | 269 | } |
264 | 270 | ||
265 | /* | 271 | /* |
266 | * 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. |
267 | * is a bit racy.. | 273 | * This is a bit racy.. |
268 | */ | 274 | */ |
269 | int oops_may_print(void) | 275 | int oops_may_print(void) |
270 | { | 276 | { |
@@ -273,20 +279,22 @@ int oops_may_print(void) | |||
273 | 279 | ||
274 | /* | 280 | /* |
275 | * Called when the architecture enters its oops handler, before it prints | 281 | * Called when the architecture enters its oops handler, before it prints |
276 | * 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 |
277 | * then let it proceed. | 283 | * time then let it proceed. |
278 | * | 284 | * |
279 | * 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 |
280 | * 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 |
281 | * 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. | ||
282 | * | 289 | * |
283 | * 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 |
284 | * 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: |
285 | * oops_enter(), once in oops_exit(). | 292 | * once in oops_enter(), once in oops_exit(). |
286 | */ | 293 | */ |
287 | void oops_enter(void) | 294 | void oops_enter(void) |
288 | { | 295 | { |
289 | 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(); | ||
290 | do_oops_enter_exit(); | 298 | do_oops_enter_exit(); |
291 | } | 299 | } |
292 | 300 | ||
@@ -355,15 +363,18 @@ EXPORT_SYMBOL(warn_slowpath); | |||
355 | #endif | 363 | #endif |
356 | 364 | ||
357 | #ifdef CONFIG_CC_STACKPROTECTOR | 365 | #ifdef CONFIG_CC_STACKPROTECTOR |
366 | |||
358 | /* | 367 | /* |
359 | * Called when gcc's -fstack-protector feature is used, and | 368 | * Called when gcc's -fstack-protector feature is used, and |
360 | * gcc detects corruption of the on-stack canary value | 369 | * gcc detects corruption of the on-stack canary value |
361 | */ | 370 | */ |
362 | void __stack_chk_fail(void) | 371 | void __stack_chk_fail(void) |
363 | { | 372 | { |
364 | panic("stack-protector: Kernel stack is corrupted"); | 373 | panic("stack-protector: Kernel stack is corrupted in: %p\n", |
374 | __builtin_return_address(0)); | ||
365 | } | 375 | } |
366 | EXPORT_SYMBOL(__stack_chk_fail); | 376 | EXPORT_SYMBOL(__stack_chk_fail); |
377 | |||
367 | #endif | 378 | #endif |
368 | 379 | ||
369 | core_param(panic, panic_timeout, int, 0644); | 380 | core_param(panic, panic_timeout, int, 0644); |