blob: 534ccd49edf9bf12f9bac60ad7eea380306bd0e4 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * linux/kernel/panic.c
3 *
4 * Copyright (C) 1991, 1992 Linus Torvalds
5 */
6
7/*
8 * This function is used through-out the kernel (including mm and fs)
9 * to indicate a major problem.
10 */
Andrew Morton657b3012006-08-13 23:24:19 -070011#include <linux/debug_locks.h>
Ingo Molnarc95dbf22009-03-13 11:14:06 +010012#include <linux/interrupt.h>
Simon Kagstrom456b5652009-10-16 14:09:18 +020013#include <linux/kmsg_dump.h>
Arjan van de Ven79b4cc52008-01-30 13:32:50 +010014#include <linux/kallsyms.h>
Ingo Molnarc95dbf22009-03-13 11:14:06 +010015#include <linux/notifier.h>
16#include <linux/module.h>
17#include <linux/random.h>
18#include <linux/reboot.h>
19#include <linux/delay.h>
20#include <linux/kexec.h>
21#include <linux/sched.h>
22#include <linux/sysrq.h>
23#include <linux/init.h>
24#include <linux/nmi.h>
Arjan van de Venbd89bb22008-11-28 08:36:09 -080025#include <linux/dmi.h>
Pratik Patel7d8d1722012-12-02 21:15:05 -080026#include <linux/coresight.h>
Bongkyu Kimbeccb932013-07-21 23:26:08 -050027#include <linux/console.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070028
TAMUKI Shoichic7ff0d92010-08-10 18:03:28 -070029#define PANIC_TIMER_STEP 100
30#define PANIC_BLINK_SPD 18
31
Nishanth Menonb7d739c2011-08-17 18:31:58 -050032/* Machine specific panic information string */
33char *mach_panic_string;
34
Linus Torvalds1da177e2005-04-16 15:20:36 -070035int panic_on_oops;
Andi Kleen25ddbb12008-10-15 22:01:41 -070036static unsigned long tainted_mask;
Andrew Mortondd287792006-03-23 03:00:57 -080037static int pause_on_oops;
38static int pause_on_oops_flag;
39static DEFINE_SPINLOCK(pause_on_oops_lock);
Linus Torvalds1da177e2005-04-16 15:20:36 -070040
Arve Hjønnevåg141e7992007-05-08 15:39:13 +070041#ifndef CONFIG_PANIC_TIMEOUT
42#define CONFIG_PANIC_TIMEOUT 0
43#endif
44int panic_timeout = CONFIG_PANIC_TIMEOUT;
Huang Ying81e88fd2011-01-12 14:44:55 +080045EXPORT_SYMBOL_GPL(panic_timeout);
Linus Torvalds1da177e2005-04-16 15:20:36 -070046
Alan Sterne041c682006-03-27 01:16:30 -080047ATOMIC_NOTIFIER_HEAD(panic_notifier_list);
Linus Torvalds1da177e2005-04-16 15:20:36 -070048
49EXPORT_SYMBOL(panic_notifier_list);
50
TAMUKI Shoichic7ff0d92010-08-10 18:03:28 -070051static long no_blink(int state)
Anton Blanchard8aeee852010-03-05 13:42:55 -080052{
TAMUKI Shoichic7ff0d92010-08-10 18:03:28 -070053 return 0;
Anton Blanchard8aeee852010-03-05 13:42:55 -080054}
55
TAMUKI Shoichic7ff0d92010-08-10 18:03:28 -070056/* Returns how long it waited in ms */
57long (*panic_blink)(int state);
58EXPORT_SYMBOL(panic_blink);
59
Michael Holzheu93e13a32012-01-12 17:20:18 -080060/*
61 * Stop ourself in panic -- architecture code may override this
62 */
63void __weak panic_smp_self_stop(void)
64{
65 while (1)
66 cpu_relax();
67}
68
Linus Torvalds1da177e2005-04-16 15:20:36 -070069/**
70 * panic - halt the system
71 * @fmt: The text string to print
72 *
73 * Display a message, then perform cleanups.
74 *
75 * This function never returns.
76 */
Joe Perches9402c952012-01-12 17:17:17 -080077void panic(const char *fmt, ...)
Linus Torvalds1da177e2005-04-16 15:20:36 -070078{
Michael Holzheu93e13a32012-01-12 17:20:18 -080079 static DEFINE_SPINLOCK(panic_lock);
Linus Torvalds1da177e2005-04-16 15:20:36 -070080 static char buf[1024];
81 va_list args;
TAMUKI Shoichic7ff0d92010-08-10 18:03:28 -070082 long i, i_next = 0;
83 int state = 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -070084
Pratik Patel7d8d1722012-12-02 21:15:05 -080085 coresight_abort();
Eric W. Biedermandc009d92005-06-25 14:57:52 -070086 /*
Vikram Mulukutlae11bc4f2012-06-27 17:25:46 -070087 * Disable local interrupts. This will prevent panic_smp_self_stop
88 * from deadlocking the first cpu that invokes the panic, since
89 * there is nothing to prevent an interrupt handler (that runs
90 * after the panic_lock is acquired) from invoking panic again.
91 */
92 local_irq_disable();
93
94 /*
Ingo Molnarc95dbf22009-03-13 11:14:06 +010095 * It's possible to come here directly from a panic-assertion and
96 * not have preempt disabled. Some functions called from here want
Eric W. Biedermandc009d92005-06-25 14:57:52 -070097 * preempt to be disabled. No point enabling it later though...
Michael Holzheu93e13a32012-01-12 17:20:18 -080098 *
99 * Only one CPU is allowed to execute the panic code from here. For
100 * multiple parallel invocations of panic, all other CPUs either
101 * stop themself or will wait until they are stopped by the 1st CPU
102 * with smp_send_stop().
Eric W. Biedermandc009d92005-06-25 14:57:52 -0700103 */
Michael Holzheu93e13a32012-01-12 17:20:18 -0800104 if (!spin_trylock(&panic_lock))
105 panic_smp_self_stop();
Eric W. Biedermandc009d92005-06-25 14:57:52 -0700106
Anton Blanchard5b530fc2010-05-26 14:44:24 -0700107 console_verbose();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700108 bust_spinlocks(1);
109 va_start(args, fmt);
110 vsnprintf(buf, sizeof(buf), fmt, args);
111 va_end(args);
112 printk(KERN_EMERG "Kernel panic - not syncing: %s\n",buf);
Ingo Molnar5cb27302008-02-14 09:07:01 +0100113#ifdef CONFIG_DEBUG_BUGVERBOSE
Andi Kleen6e6f0a12012-01-12 17:20:30 -0800114 /*
115 * Avoid nested stack-dumping if a panic occurs during oops processing
116 */
Jason Wessel026ee1f2012-04-12 12:49:17 -0700117 if (!test_taint(TAINT_DIE) && oops_in_progress <= 1)
Andi Kleen6e6f0a12012-01-12 17:20:30 -0800118 dump_stack();
Ingo Molnar5cb27302008-02-14 09:07:01 +0100119#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700120
Eric W. Biedermandc009d92005-06-25 14:57:52 -0700121 /*
122 * If we have crashed and we have a crash kernel loaded let it handle
123 * everything else.
124 * Do we want to call this before we try to display a message?
125 */
Alexander Nyberg6e274d12005-06-25 14:58:26 -0700126 crash_kexec(NULL);
Eric W. Biedermandc009d92005-06-25 14:57:52 -0700127
KOSAKI Motohiro0f4bd462009-12-22 03:15:43 +0000128 kmsg_dump(KMSG_DUMP_PANIC);
129
shihhao.fengbe8c7c32013-08-09 10:49:16 -0700130 /* print last_kmsg even after console suspend */
131 if (is_console_suspended())
132 resume_console();
133
Bongkyu Kimbeccb932013-07-21 23:26:08 -0500134 if (is_console_locked())
135 console_unlock();
136
Eric W. Biedermandc009d92005-06-25 14:57:52 -0700137 /*
138 * Note smp_send_stop is the usual smp shutdown function, which
139 * unfortunately means it may not be hardened to work in a panic
140 * situation.
141 */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700142 smp_send_stop();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700143
Alan Sterne041c682006-03-27 01:16:30 -0800144 atomic_notifier_call_chain(&panic_notifier_list, 0, buf);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700145
Aaro Koskinend014e882009-10-02 14:41:20 +0300146 bust_spinlocks(0);
147
TAMUKI Shoichic7ff0d92010-08-10 18:03:28 -0700148 if (!panic_blink)
149 panic_blink = no_blink;
150
Eric W. Biedermandc009d92005-06-25 14:57:52 -0700151 if (panic_timeout > 0) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700152 /*
Ingo Molnarc95dbf22009-03-13 11:14:06 +0100153 * Delay timeout seconds before rebooting the machine.
154 * We can't use the "normal" timers since we just panicked.
155 */
156 printk(KERN_EMERG "Rebooting in %d seconds..", panic_timeout);
157
TAMUKI Shoichic7ff0d92010-08-10 18:03:28 -0700158 for (i = 0; i < panic_timeout * 1000; i += PANIC_TIMER_STEP) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700159 touch_nmi_watchdog();
TAMUKI Shoichic7ff0d92010-08-10 18:03:28 -0700160 if (i >= i_next) {
161 i += panic_blink(state ^= 1);
162 i_next = i + 3600 / PANIC_BLINK_SPD;
163 }
164 mdelay(PANIC_TIMER_STEP);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700165 }
Hugh Dickins4302fbc2011-07-26 16:08:52 -0700166 }
167 if (panic_timeout != 0) {
Ingo Molnarc95dbf22009-03-13 11:14:06 +0100168 /*
169 * This will not be a clean reboot, with everything
170 * shutting down. But if there is a chance of
171 * rebooting the system it will be rebooted.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700172 */
Eric W. Biederman2f048ea2005-07-26 11:49:23 -0600173 emergency_restart();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700174 }
175#ifdef __sparc__
176 {
177 extern int stop_a_enabled;
Tom 'spot' Callawaya271c242005-04-24 20:38:02 -0700178 /* Make sure the user can actually press Stop-A (L1-A) */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700179 stop_a_enabled = 1;
Tom 'spot' Callawaya271c242005-04-24 20:38:02 -0700180 printk(KERN_EMERG "Press Stop-A (L1-A) to return to the boot prom\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700181 }
182#endif
Martin Schwidefsky347a8dc2006-01-06 00:19:28 -0800183#if defined(CONFIG_S390)
Ingo Molnarc95dbf22009-03-13 11:14:06 +0100184 {
185 unsigned long caller;
186
187 caller = (unsigned long)__builtin_return_address(0);
188 disabled_wait(caller);
189 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700190#endif
191 local_irq_enable();
TAMUKI Shoichic7ff0d92010-08-10 18:03:28 -0700192 for (i = 0; ; i += PANIC_TIMER_STEP) {
Jan Beulichc22db942006-02-10 01:51:11 -0800193 touch_softlockup_watchdog();
TAMUKI Shoichic7ff0d92010-08-10 18:03:28 -0700194 if (i >= i_next) {
195 i += panic_blink(state ^= 1);
196 i_next = i + 3600 / PANIC_BLINK_SPD;
197 }
198 mdelay(PANIC_TIMER_STEP);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700199 }
200}
201
202EXPORT_SYMBOL(panic);
203
Daniel Walkerc277e632007-10-18 03:06:08 -0700204
Andi Kleen25ddbb12008-10-15 22:01:41 -0700205struct tnt {
Ingo Molnarc95dbf22009-03-13 11:14:06 +0100206 u8 bit;
207 char true;
208 char false;
Andi Kleen25ddbb12008-10-15 22:01:41 -0700209};
210
211static const struct tnt tnts[] = {
Ingo Molnarc95dbf22009-03-13 11:14:06 +0100212 { TAINT_PROPRIETARY_MODULE, 'P', 'G' },
213 { TAINT_FORCED_MODULE, 'F', ' ' },
214 { TAINT_UNSAFE_SMP, 'S', ' ' },
215 { TAINT_FORCED_RMMOD, 'R', ' ' },
216 { TAINT_MACHINE_CHECK, 'M', ' ' },
217 { TAINT_BAD_PAGE, 'B', ' ' },
218 { TAINT_USER, 'U', ' ' },
219 { TAINT_DIE, 'D', ' ' },
220 { TAINT_OVERRIDDEN_ACPI_TABLE, 'A', ' ' },
221 { TAINT_WARN, 'W', ' ' },
222 { TAINT_CRAP, 'C', ' ' },
Ben Hutchings92946bc2010-04-03 19:36:42 +0100223 { TAINT_FIRMWARE_WORKAROUND, 'I', ' ' },
Ben Hutchings2449b8b2011-10-24 15:12:28 +0200224 { TAINT_OOT_MODULE, 'O', ' ' },
Andi Kleen25ddbb12008-10-15 22:01:41 -0700225};
226
Linus Torvalds1da177e2005-04-16 15:20:36 -0700227/**
228 * print_tainted - return a string to represent the kernel taint state.
229 *
230 * 'P' - Proprietary module has been loaded.
231 * 'F' - Module has been forcibly loaded.
232 * 'S' - SMP with CPUs not designed for SMP.
233 * 'R' - User forced a module unload.
234 * 'M' - System experienced a machine check exception.
235 * 'B' - System has hit bad_page.
236 * 'U' - Userspace-defined naughtiness.
Arjan van de Vena8005992008-12-01 13:14:00 -0800237 * 'D' - Kernel has oopsed before
Linus Torvalds1da177e2005-04-16 15:20:36 -0700238 * 'A' - ACPI table overridden.
Theodore Ts'o34f5a392007-02-10 01:45:24 -0800239 * 'W' - Taint on warning.
Greg Kroah-Hartman061b1bd2008-09-24 14:46:44 -0700240 * 'C' - modules from drivers/staging are loaded.
Ben Hutchings92946bc2010-04-03 19:36:42 +0100241 * 'I' - Working around severe firmware bug.
Ben Hutchings2449b8b2011-10-24 15:12:28 +0200242 * 'O' - Out-of-tree module has been loaded.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700243 *
Robert P. J. Dayfe002a42009-06-28 21:10:07 -0400244 * The string is overwritten by the next call to print_tainted().
Linus Torvalds1da177e2005-04-16 15:20:36 -0700245 */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700246const char *print_tainted(void)
247{
Andi Kleen25ddbb12008-10-15 22:01:41 -0700248 static char buf[ARRAY_SIZE(tnts) + sizeof("Tainted: ") + 1];
249
250 if (tainted_mask) {
251 char *s;
252 int i;
253
254 s = buf + sprintf(buf, "Tainted: ");
255 for (i = 0; i < ARRAY_SIZE(tnts); i++) {
256 const struct tnt *t = &tnts[i];
257 *s++ = test_bit(t->bit, &tainted_mask) ?
258 t->true : t->false;
259 }
260 *s = 0;
261 } else
Linus Torvalds1da177e2005-04-16 15:20:36 -0700262 snprintf(buf, sizeof(buf), "Not tainted");
Ingo Molnarc95dbf22009-03-13 11:14:06 +0100263
264 return buf;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700265}
266
Andi Kleen25ddbb12008-10-15 22:01:41 -0700267int test_taint(unsigned flag)
268{
269 return test_bit(flag, &tainted_mask);
270}
271EXPORT_SYMBOL(test_taint);
272
273unsigned long get_taint(void)
274{
275 return tainted_mask;
276}
277
Linus Torvalds1da177e2005-04-16 15:20:36 -0700278void add_taint(unsigned flag)
279{
Frederic Weisbecker9eeba612009-04-11 03:17:17 +0200280 /*
281 * Can't trust the integrity of the kernel anymore.
282 * We don't call directly debug_locks_off() because the issue
283 * is not necessarily serious enough to set oops_in_progress to 1
Ben Hutchings9ec84ac2011-12-07 14:30:58 +0000284 * Also we want to keep up lockdep for staging/out-of-tree
285 * development and post-warning case.
Frederic Weisbecker9eeba612009-04-11 03:17:17 +0200286 */
Peter Zijlstradf754e62011-11-14 13:13:49 +0100287 switch (flag) {
288 case TAINT_CRAP:
Ben Hutchings9ec84ac2011-12-07 14:30:58 +0000289 case TAINT_OOT_MODULE:
Peter Zijlstradf754e62011-11-14 13:13:49 +0100290 case TAINT_WARN:
291 case TAINT_FIRMWARE_WORKAROUND:
292 break;
293
294 default:
295 if (__debug_locks_off())
296 printk(KERN_WARNING "Disabling lock debugging due to kernel taint\n");
297 }
Frederic Weisbecker9eeba612009-04-11 03:17:17 +0200298
Andi Kleen25ddbb12008-10-15 22:01:41 -0700299 set_bit(flag, &tainted_mask);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700300}
301EXPORT_SYMBOL(add_taint);
Andrew Mortondd287792006-03-23 03:00:57 -0800302
Andrew Mortondd287792006-03-23 03:00:57 -0800303static void spin_msec(int msecs)
304{
305 int i;
306
307 for (i = 0; i < msecs; i++) {
308 touch_nmi_watchdog();
309 mdelay(1);
310 }
311}
312
313/*
314 * It just happens that oops_enter() and oops_exit() are identically
315 * implemented...
316 */
317static void do_oops_enter_exit(void)
318{
319 unsigned long flags;
320 static int spin_counter;
321
322 if (!pause_on_oops)
323 return;
324
325 spin_lock_irqsave(&pause_on_oops_lock, flags);
326 if (pause_on_oops_flag == 0) {
327 /* This CPU may now print the oops message */
328 pause_on_oops_flag = 1;
329 } else {
330 /* We need to stall this CPU */
331 if (!spin_counter) {
332 /* This CPU gets to do the counting */
333 spin_counter = pause_on_oops;
334 do {
335 spin_unlock(&pause_on_oops_lock);
336 spin_msec(MSEC_PER_SEC);
337 spin_lock(&pause_on_oops_lock);
338 } while (--spin_counter);
339 pause_on_oops_flag = 0;
340 } else {
341 /* This CPU waits for a different one */
342 while (spin_counter) {
343 spin_unlock(&pause_on_oops_lock);
344 spin_msec(1);
345 spin_lock(&pause_on_oops_lock);
346 }
347 }
348 }
349 spin_unlock_irqrestore(&pause_on_oops_lock, flags);
350}
351
352/*
Ingo Molnarc95dbf22009-03-13 11:14:06 +0100353 * Return true if the calling CPU is allowed to print oops-related info.
354 * This is a bit racy..
Andrew Mortondd287792006-03-23 03:00:57 -0800355 */
356int oops_may_print(void)
357{
358 return pause_on_oops_flag == 0;
359}
360
361/*
362 * Called when the architecture enters its oops handler, before it prints
Ingo Molnarc95dbf22009-03-13 11:14:06 +0100363 * anything. If this is the first CPU to oops, and it's oopsing the first
364 * time then let it proceed.
Andrew Mortondd287792006-03-23 03:00:57 -0800365 *
Ingo Molnarc95dbf22009-03-13 11:14:06 +0100366 * This is all enabled by the pause_on_oops kernel boot option. We do all
367 * this to ensure that oopses don't scroll off the screen. It has the
368 * side-effect of preventing later-oopsing CPUs from mucking up the display,
369 * too.
Andrew Mortondd287792006-03-23 03:00:57 -0800370 *
Ingo Molnarc95dbf22009-03-13 11:14:06 +0100371 * It turns out that the CPU which is allowed to print ends up pausing for
372 * the right duration, whereas all the other CPUs pause for twice as long:
373 * once in oops_enter(), once in oops_exit().
Andrew Mortondd287792006-03-23 03:00:57 -0800374 */
375void oops_enter(void)
376{
Thomas Gleixnerbdff7872009-07-24 15:30:45 -0400377 tracing_off();
Ingo Molnarc95dbf22009-03-13 11:14:06 +0100378 /* can't trust the integrity of the kernel anymore: */
379 debug_locks_off();
Andrew Mortondd287792006-03-23 03:00:57 -0800380 do_oops_enter_exit();
381}
382
383/*
Arjan van de Ven2c3b20e2007-12-20 15:01:17 +0100384 * 64-bit random ID for oopses:
385 */
386static u64 oops_id;
387
388static int init_oops_id(void)
389{
390 if (!oops_id)
391 get_random_bytes(&oops_id, sizeof(oops_id));
Arjan van de Vend6624f92009-01-06 14:40:54 -0800392 else
393 oops_id++;
Arjan van de Ven2c3b20e2007-12-20 15:01:17 +0100394
395 return 0;
396}
397late_initcall(init_oops_id);
398
Anton Blanchard863a6042010-08-10 18:03:30 -0700399void print_oops_end_marker(void)
Arjan van de Ven71c33912008-01-30 13:32:50 +0100400{
401 init_oops_id();
Nishanth Menonb7d739c2011-08-17 18:31:58 -0500402
403 if (mach_panic_string)
404 printk(KERN_WARNING "Board Information: %s\n",
405 mach_panic_string);
406
Arjan van de Ven71c33912008-01-30 13:32:50 +0100407 printk(KERN_WARNING "---[ end trace %016llx ]---\n",
408 (unsigned long long)oops_id);
409}
410
Arjan van de Ven2c3b20e2007-12-20 15:01:17 +0100411/*
Andrew Mortondd287792006-03-23 03:00:57 -0800412 * Called when the architecture exits its oops handler, after printing
413 * everything.
414 */
415void oops_exit(void)
416{
417 do_oops_enter_exit();
Arjan van de Ven71c33912008-01-30 13:32:50 +0100418 print_oops_end_marker();
Simon Kagstrom456b5652009-10-16 14:09:18 +0200419 kmsg_dump(KMSG_DUMP_OOPS);
Andrew Mortondd287792006-03-23 03:00:57 -0800420}
Arjan van de Ven3162f752006-09-26 10:52:39 +0200421
Arjan van de Ven79b4cc52008-01-30 13:32:50 +0100422#ifdef WANT_WARN_ON_SLOWPATH
Linus Torvalds0f6f49a2009-05-16 13:41:28 -0700423struct slowpath_args {
424 const char *fmt;
Arjan van de Vena8f18b92008-07-25 01:45:53 -0700425 va_list args;
Linus Torvalds0f6f49a2009-05-16 13:41:28 -0700426};
427
Ben Hutchingsb2be0522010-04-03 19:34:56 +0100428static void warn_slowpath_common(const char *file, int line, void *caller,
429 unsigned taint, struct slowpath_args *args)
Linus Torvalds0f6f49a2009-05-16 13:41:28 -0700430{
Arjan van de Venbd89bb22008-11-28 08:36:09 -0800431 const char *board;
432
Arjan van de Vena8f18b92008-07-25 01:45:53 -0700433 printk(KERN_WARNING "------------[ cut here ]------------\n");
Linus Torvalds0f6f49a2009-05-16 13:41:28 -0700434 printk(KERN_WARNING "WARNING: at %s:%d %pS()\n", file, line, caller);
Arjan van de Venbd89bb22008-11-28 08:36:09 -0800435 board = dmi_get_system_info(DMI_PRODUCT_NAME);
436 if (board)
437 printk(KERN_WARNING "Hardware name: %s\n", board);
Arjan van de Ven74853db2008-11-28 08:35:25 -0800438
Linus Torvalds0f6f49a2009-05-16 13:41:28 -0700439 if (args)
440 vprintk(args->fmt, args->args);
Arjan van de Vena8f18b92008-07-25 01:45:53 -0700441
442 print_modules();
443 dump_stack();
444 print_oops_end_marker();
Ben Hutchingsb2be0522010-04-03 19:34:56 +0100445 add_taint(taint);
Arjan van de Vena8f18b92008-07-25 01:45:53 -0700446}
Linus Torvalds0f6f49a2009-05-16 13:41:28 -0700447
448void warn_slowpath_fmt(const char *file, int line, const char *fmt, ...)
449{
450 struct slowpath_args args;
451
452 args.fmt = fmt;
453 va_start(args.args, fmt);
Ben Hutchingsb2be0522010-04-03 19:34:56 +0100454 warn_slowpath_common(file, line, __builtin_return_address(0),
455 TAINT_WARN, &args);
Linus Torvalds0f6f49a2009-05-16 13:41:28 -0700456 va_end(args.args);
457}
Andi Kleen57adc4d2009-05-06 16:02:53 -0700458EXPORT_SYMBOL(warn_slowpath_fmt);
459
Ben Hutchingsb2be0522010-04-03 19:34:56 +0100460void warn_slowpath_fmt_taint(const char *file, int line,
461 unsigned taint, const char *fmt, ...)
462{
463 struct slowpath_args args;
464
465 args.fmt = fmt;
466 va_start(args.args, fmt);
467 warn_slowpath_common(file, line, __builtin_return_address(0),
468 taint, &args);
469 va_end(args.args);
470}
471EXPORT_SYMBOL(warn_slowpath_fmt_taint);
472
Andi Kleen57adc4d2009-05-06 16:02:53 -0700473void warn_slowpath_null(const char *file, int line)
474{
Ben Hutchingsb2be0522010-04-03 19:34:56 +0100475 warn_slowpath_common(file, line, __builtin_return_address(0),
476 TAINT_WARN, NULL);
Andi Kleen57adc4d2009-05-06 16:02:53 -0700477}
478EXPORT_SYMBOL(warn_slowpath_null);
Arjan van de Ven79b4cc52008-01-30 13:32:50 +0100479#endif
480
Arjan van de Ven3162f752006-09-26 10:52:39 +0200481#ifdef CONFIG_CC_STACKPROTECTOR
Arjan van de Ven54371a42008-02-15 15:33:12 -0800482
Arjan van de Ven3162f752006-09-26 10:52:39 +0200483/*
484 * Called when gcc's -fstack-protector feature is used, and
485 * gcc detects corruption of the on-stack canary value
486 */
487void __stack_chk_fail(void)
488{
Ingo Molnar517a92c2008-02-14 09:02:13 +0100489 panic("stack-protector: Kernel stack is corrupted in: %p\n",
490 __builtin_return_address(0));
Arjan van de Ven3162f752006-09-26 10:52:39 +0200491}
492EXPORT_SYMBOL(__stack_chk_fail);
Arjan van de Ven54371a42008-02-15 15:33:12 -0800493
Arjan van de Ven3162f752006-09-26 10:52:39 +0200494#endif
Rusty Russellf44dd162008-10-22 10:00:24 -0500495
496core_param(panic, panic_timeout, int, 0644);
497core_param(pause_on_oops, pause_on_oops, int, 0644);
Olaf Heringd404ab02011-03-22 16:34:04 -0700498
499static int __init oops_setup(char *s)
500{
501 if (!s)
502 return -EINVAL;
503 if (!strcmp(s, "panic"))
504 panic_on_oops = 1;
505 return 0;
506}
507early_param("oops", oops_setup);