xref: /linux-6.15/kernel/panic.c (revision 8aeee85a)
11da177e4SLinus Torvalds /*
21da177e4SLinus Torvalds  *  linux/kernel/panic.c
31da177e4SLinus Torvalds  *
41da177e4SLinus Torvalds  *  Copyright (C) 1991, 1992  Linus Torvalds
51da177e4SLinus Torvalds  */
61da177e4SLinus Torvalds 
71da177e4SLinus Torvalds /*
81da177e4SLinus Torvalds  * This function is used through-out the kernel (including mm and fs)
91da177e4SLinus Torvalds  * to indicate a major problem.
101da177e4SLinus Torvalds  */
11657b3010SAndrew Morton #include <linux/debug_locks.h>
12c95dbf27SIngo Molnar #include <linux/interrupt.h>
13456b565cSSimon Kagstrom #include <linux/kmsg_dump.h>
1479b4cc5eSArjan van de Ven #include <linux/kallsyms.h>
15c95dbf27SIngo Molnar #include <linux/notifier.h>
16c95dbf27SIngo Molnar #include <linux/module.h>
17c95dbf27SIngo Molnar #include <linux/random.h>
18c95dbf27SIngo Molnar #include <linux/reboot.h>
19c95dbf27SIngo Molnar #include <linux/delay.h>
20c95dbf27SIngo Molnar #include <linux/kexec.h>
21c95dbf27SIngo Molnar #include <linux/sched.h>
22c95dbf27SIngo Molnar #include <linux/sysrq.h>
23c95dbf27SIngo Molnar #include <linux/init.h>
24c95dbf27SIngo Molnar #include <linux/nmi.h>
25bd89bb29SArjan van de Ven #include <linux/dmi.h>
261da177e4SLinus Torvalds 
271da177e4SLinus Torvalds int panic_on_oops;
2825ddbb18SAndi Kleen static unsigned long tainted_mask;
29dd287796SAndrew Morton static int pause_on_oops;
30dd287796SAndrew Morton static int pause_on_oops_flag;
31dd287796SAndrew Morton static DEFINE_SPINLOCK(pause_on_oops_lock);
321da177e4SLinus Torvalds 
33dd287796SAndrew Morton int panic_timeout;
341da177e4SLinus Torvalds 
35e041c683SAlan Stern ATOMIC_NOTIFIER_HEAD(panic_notifier_list);
361da177e4SLinus Torvalds 
371da177e4SLinus Torvalds EXPORT_SYMBOL(panic_notifier_list);
381da177e4SLinus Torvalds 
391da177e4SLinus Torvalds /* Returns how long it waited in ms */
401da177e4SLinus Torvalds long (*panic_blink)(long time);
411da177e4SLinus Torvalds EXPORT_SYMBOL(panic_blink);
421da177e4SLinus Torvalds 
43*8aeee85aSAnton Blanchard static void panic_blink_one_second(void)
44*8aeee85aSAnton Blanchard {
45*8aeee85aSAnton Blanchard 	static long i = 0, end;
46*8aeee85aSAnton Blanchard 
47*8aeee85aSAnton Blanchard 	if (panic_blink) {
48*8aeee85aSAnton Blanchard 		end = i + MSEC_PER_SEC;
49*8aeee85aSAnton Blanchard 
50*8aeee85aSAnton Blanchard 		while (i < end) {
51*8aeee85aSAnton Blanchard 			i += panic_blink(i);
52*8aeee85aSAnton Blanchard 			mdelay(1);
53*8aeee85aSAnton Blanchard 			i++;
54*8aeee85aSAnton Blanchard 		}
55*8aeee85aSAnton Blanchard 	} else {
56*8aeee85aSAnton Blanchard 		/*
57*8aeee85aSAnton Blanchard 		 * When running under a hypervisor a small mdelay may get
58*8aeee85aSAnton Blanchard 		 * rounded up to the hypervisor timeslice. For example, with
59*8aeee85aSAnton Blanchard 		 * a 1ms in 10ms hypervisor timeslice we might inflate a
60*8aeee85aSAnton Blanchard 		 * mdelay(1) loop by 10x.
61*8aeee85aSAnton Blanchard 		 *
62*8aeee85aSAnton Blanchard 		 * If we have nothing to blink, spin on 1 second calls to
63*8aeee85aSAnton Blanchard 		 * mdelay to avoid this.
64*8aeee85aSAnton Blanchard 		 */
65*8aeee85aSAnton Blanchard 		mdelay(MSEC_PER_SEC);
66*8aeee85aSAnton Blanchard 	}
67*8aeee85aSAnton Blanchard }
68*8aeee85aSAnton Blanchard 
691da177e4SLinus Torvalds /**
701da177e4SLinus Torvalds  *	panic - halt the system
711da177e4SLinus Torvalds  *	@fmt: The text string to print
721da177e4SLinus Torvalds  *
731da177e4SLinus Torvalds  *	Display a message, then perform cleanups.
741da177e4SLinus Torvalds  *
751da177e4SLinus Torvalds  *	This function never returns.
761da177e4SLinus Torvalds  */
771da177e4SLinus Torvalds NORET_TYPE void panic(const char * fmt, ...)
781da177e4SLinus Torvalds {
791da177e4SLinus Torvalds 	static char buf[1024];
801da177e4SLinus Torvalds 	va_list args;
81c95dbf27SIngo Molnar 	long i;
821da177e4SLinus Torvalds 
83dc009d92SEric W. Biederman 	/*
84c95dbf27SIngo Molnar 	 * It's possible to come here directly from a panic-assertion and
85c95dbf27SIngo Molnar 	 * not have preempt disabled. Some functions called from here want
86dc009d92SEric W. Biederman 	 * preempt to be disabled. No point enabling it later though...
87dc009d92SEric W. Biederman 	 */
88dc009d92SEric W. Biederman 	preempt_disable();
89dc009d92SEric W. Biederman 
901da177e4SLinus Torvalds 	bust_spinlocks(1);
911da177e4SLinus Torvalds 	va_start(args, fmt);
921da177e4SLinus Torvalds 	vsnprintf(buf, sizeof(buf), fmt, args);
931da177e4SLinus Torvalds 	va_end(args);
941da177e4SLinus Torvalds 	printk(KERN_EMERG "Kernel panic - not syncing: %s\n",buf);
955cb27301SIngo Molnar #ifdef CONFIG_DEBUG_BUGVERBOSE
965cb27301SIngo Molnar 	dump_stack();
975cb27301SIngo Molnar #endif
981da177e4SLinus Torvalds 
99dc009d92SEric W. Biederman 	/*
100dc009d92SEric W. Biederman 	 * If we have crashed and we have a crash kernel loaded let it handle
101dc009d92SEric W. Biederman 	 * everything else.
102dc009d92SEric W. Biederman 	 * Do we want to call this before we try to display a message?
103dc009d92SEric W. Biederman 	 */
1046e274d14SAlexander Nyberg 	crash_kexec(NULL);
105dc009d92SEric W. Biederman 
1060f4bd46eSKOSAKI Motohiro 	kmsg_dump(KMSG_DUMP_PANIC);
1070f4bd46eSKOSAKI Motohiro 
108dc009d92SEric W. Biederman 	/*
109dc009d92SEric W. Biederman 	 * Note smp_send_stop is the usual smp shutdown function, which
110dc009d92SEric W. Biederman 	 * unfortunately means it may not be hardened to work in a panic
111dc009d92SEric W. Biederman 	 * situation.
112dc009d92SEric W. Biederman 	 */
1131da177e4SLinus Torvalds 	smp_send_stop();
1141da177e4SLinus Torvalds 
115e041c683SAlan Stern 	atomic_notifier_call_chain(&panic_notifier_list, 0, buf);
1161da177e4SLinus Torvalds 
117d014e889SAaro Koskinen 	bust_spinlocks(0);
118d014e889SAaro Koskinen 
119dc009d92SEric W. Biederman 	if (panic_timeout > 0) {
1201da177e4SLinus Torvalds 		/*
1211da177e4SLinus Torvalds 		 * Delay timeout seconds before rebooting the machine.
122c95dbf27SIngo Molnar 		 * We can't use the "normal" timers since we just panicked.
1231da177e4SLinus Torvalds 		 */
1241da177e4SLinus Torvalds 		printk(KERN_EMERG "Rebooting in %d seconds..", panic_timeout);
125c95dbf27SIngo Molnar 
126*8aeee85aSAnton Blanchard 		for (i = 0; i < panic_timeout; i++) {
1271da177e4SLinus Torvalds 			touch_nmi_watchdog();
128*8aeee85aSAnton Blanchard 			panic_blink_one_second();
1291da177e4SLinus Torvalds 		}
130c95dbf27SIngo Molnar 		/*
131c95dbf27SIngo Molnar 		 * This will not be a clean reboot, with everything
1322f048ea8SEric W. Biederman 		 * shutting down.  But if there is a chance of
1332f048ea8SEric W. Biederman 		 * rebooting the system it will be rebooted.
1341da177e4SLinus Torvalds 		 */
1352f048ea8SEric W. Biederman 		emergency_restart();
1361da177e4SLinus Torvalds 	}
1371da177e4SLinus Torvalds #ifdef __sparc__
1381da177e4SLinus Torvalds 	{
1391da177e4SLinus Torvalds 		extern int stop_a_enabled;
140a271c241STom 'spot' Callaway 		/* Make sure the user can actually press Stop-A (L1-A) */
1411da177e4SLinus Torvalds 		stop_a_enabled = 1;
142a271c241STom 'spot' Callaway 		printk(KERN_EMERG "Press Stop-A (L1-A) to return to the boot prom\n");
1431da177e4SLinus Torvalds 	}
1441da177e4SLinus Torvalds #endif
145347a8dc3SMartin Schwidefsky #if defined(CONFIG_S390)
146c95dbf27SIngo Molnar 	{
147c95dbf27SIngo Molnar 		unsigned long caller;
148c95dbf27SIngo Molnar 
149c95dbf27SIngo Molnar 		caller = (unsigned long)__builtin_return_address(0);
1501da177e4SLinus Torvalds 		disabled_wait(caller);
151c95dbf27SIngo Molnar 	}
1521da177e4SLinus Torvalds #endif
1531da177e4SLinus Torvalds 	local_irq_enable();
154*8aeee85aSAnton Blanchard 	while (1) {
155c22db941SJan Beulich 		touch_softlockup_watchdog();
156*8aeee85aSAnton Blanchard 		panic_blink_one_second();
1571da177e4SLinus Torvalds 	}
1581da177e4SLinus Torvalds }
1591da177e4SLinus Torvalds 
1601da177e4SLinus Torvalds EXPORT_SYMBOL(panic);
1611da177e4SLinus Torvalds 
1621da177e4SLinus Torvalds 
16325ddbb18SAndi Kleen struct tnt {
16425ddbb18SAndi Kleen 	u8	bit;
16525ddbb18SAndi Kleen 	char	true;
16625ddbb18SAndi Kleen 	char	false;
16725ddbb18SAndi Kleen };
16825ddbb18SAndi Kleen 
16925ddbb18SAndi Kleen static const struct tnt tnts[] = {
17025ddbb18SAndi Kleen 	{ TAINT_PROPRIETARY_MODULE,	'P', 'G' },
17125ddbb18SAndi Kleen 	{ TAINT_FORCED_MODULE,		'F', ' ' },
17225ddbb18SAndi Kleen 	{ TAINT_UNSAFE_SMP,		'S', ' ' },
17325ddbb18SAndi Kleen 	{ TAINT_FORCED_RMMOD,		'R', ' ' },
17425ddbb18SAndi Kleen 	{ TAINT_MACHINE_CHECK,		'M', ' ' },
17525ddbb18SAndi Kleen 	{ TAINT_BAD_PAGE,		'B', ' ' },
17625ddbb18SAndi Kleen 	{ TAINT_USER,			'U', ' ' },
17725ddbb18SAndi Kleen 	{ TAINT_DIE,			'D', ' ' },
17825ddbb18SAndi Kleen 	{ TAINT_OVERRIDDEN_ACPI_TABLE,	'A', ' ' },
17925ddbb18SAndi Kleen 	{ TAINT_WARN,			'W', ' ' },
18026e9a397SLinus Torvalds 	{ TAINT_CRAP,			'C', ' ' },
18125ddbb18SAndi Kleen };
18225ddbb18SAndi Kleen 
1831da177e4SLinus Torvalds /**
1841da177e4SLinus Torvalds  *	print_tainted - return a string to represent the kernel taint state.
1851da177e4SLinus Torvalds  *
1861da177e4SLinus Torvalds  *  'P' - Proprietary module has been loaded.
1871da177e4SLinus Torvalds  *  'F' - Module has been forcibly loaded.
1881da177e4SLinus Torvalds  *  'S' - SMP with CPUs not designed for SMP.
1891da177e4SLinus Torvalds  *  'R' - User forced a module unload.
1901da177e4SLinus Torvalds  *  'M' - System experienced a machine check exception.
1911da177e4SLinus Torvalds  *  'B' - System has hit bad_page.
1921da177e4SLinus Torvalds  *  'U' - Userspace-defined naughtiness.
193a8005992SArjan van de Ven  *  'D' - Kernel has oopsed before
1941da177e4SLinus Torvalds  *  'A' - ACPI table overridden.
1951da177e4SLinus Torvalds  *  'W' - Taint on warning.
196061b1bd3SGreg Kroah-Hartman  *  'C' - modules from drivers/staging are loaded.
1971da177e4SLinus Torvalds  *
198fe002a41SRobert P. J. Day  *	The string is overwritten by the next call to print_tainted().
1991da177e4SLinus Torvalds  */
2001da177e4SLinus Torvalds const char *print_tainted(void)
2011da177e4SLinus Torvalds {
20225ddbb18SAndi Kleen 	static char buf[ARRAY_SIZE(tnts) + sizeof("Tainted: ") + 1];
20325ddbb18SAndi Kleen 
20425ddbb18SAndi Kleen 	if (tainted_mask) {
20525ddbb18SAndi Kleen 		char *s;
20625ddbb18SAndi Kleen 		int i;
20725ddbb18SAndi Kleen 
20825ddbb18SAndi Kleen 		s = buf + sprintf(buf, "Tainted: ");
20925ddbb18SAndi Kleen 		for (i = 0; i < ARRAY_SIZE(tnts); i++) {
21025ddbb18SAndi Kleen 			const struct tnt *t = &tnts[i];
21125ddbb18SAndi Kleen 			*s++ = test_bit(t->bit, &tainted_mask) ?
21225ddbb18SAndi Kleen 					t->true : t->false;
2131da177e4SLinus Torvalds 		}
21425ddbb18SAndi Kleen 		*s = 0;
21525ddbb18SAndi Kleen 	} else
2161da177e4SLinus Torvalds 		snprintf(buf, sizeof(buf), "Not tainted");
217c95dbf27SIngo Molnar 
218c95dbf27SIngo Molnar 	return buf;
2191da177e4SLinus Torvalds }
2201da177e4SLinus Torvalds 
22125ddbb18SAndi Kleen int test_taint(unsigned flag)
22225ddbb18SAndi Kleen {
22325ddbb18SAndi Kleen 	return test_bit(flag, &tainted_mask);
22425ddbb18SAndi Kleen }
22525ddbb18SAndi Kleen EXPORT_SYMBOL(test_taint);
22625ddbb18SAndi Kleen 
22725ddbb18SAndi Kleen unsigned long get_taint(void)
22825ddbb18SAndi Kleen {
22925ddbb18SAndi Kleen 	return tainted_mask;
23025ddbb18SAndi Kleen }
23125ddbb18SAndi Kleen 
2321da177e4SLinus Torvalds void add_taint(unsigned flag)
2331da177e4SLinus Torvalds {
2349eeba613SFrederic Weisbecker 	/*
2359eeba613SFrederic Weisbecker 	 * Can't trust the integrity of the kernel anymore.
2369eeba613SFrederic Weisbecker 	 * We don't call directly debug_locks_off() because the issue
2379eeba613SFrederic Weisbecker 	 * is not necessarily serious enough to set oops_in_progress to 1
238574bbe78SFrederic Weisbecker 	 * Also we want to keep up lockdep for staging development and
239574bbe78SFrederic Weisbecker 	 * post-warning case.
2409eeba613SFrederic Weisbecker 	 */
241574bbe78SFrederic Weisbecker 	if (flag != TAINT_CRAP && flag != TAINT_WARN && __debug_locks_off())
242b48ccb09SIngo Molnar 		printk(KERN_WARNING "Disabling lock debugging due to kernel taint\n");
2439eeba613SFrederic Weisbecker 
24425ddbb18SAndi Kleen 	set_bit(flag, &tainted_mask);
2451da177e4SLinus Torvalds }
2461da177e4SLinus Torvalds EXPORT_SYMBOL(add_taint);
247dd287796SAndrew Morton 
248dd287796SAndrew Morton static void spin_msec(int msecs)
249dd287796SAndrew Morton {
250dd287796SAndrew Morton 	int i;
251dd287796SAndrew Morton 
252dd287796SAndrew Morton 	for (i = 0; i < msecs; i++) {
253dd287796SAndrew Morton 		touch_nmi_watchdog();
254dd287796SAndrew Morton 		mdelay(1);
255dd287796SAndrew Morton 	}
256dd287796SAndrew Morton }
257dd287796SAndrew Morton 
258dd287796SAndrew Morton /*
259dd287796SAndrew Morton  * It just happens that oops_enter() and oops_exit() are identically
260dd287796SAndrew Morton  * implemented...
261dd287796SAndrew Morton  */
262dd287796SAndrew Morton static void do_oops_enter_exit(void)
263dd287796SAndrew Morton {
264dd287796SAndrew Morton 	unsigned long flags;
265dd287796SAndrew Morton 	static int spin_counter;
266dd287796SAndrew Morton 
267dd287796SAndrew Morton 	if (!pause_on_oops)
268dd287796SAndrew Morton 		return;
269dd287796SAndrew Morton 
270dd287796SAndrew Morton 	spin_lock_irqsave(&pause_on_oops_lock, flags);
271dd287796SAndrew Morton 	if (pause_on_oops_flag == 0) {
272dd287796SAndrew Morton 		/* This CPU may now print the oops message */
273dd287796SAndrew Morton 		pause_on_oops_flag = 1;
274dd287796SAndrew Morton 	} else {
275dd287796SAndrew Morton 		/* We need to stall this CPU */
276dd287796SAndrew Morton 		if (!spin_counter) {
277dd287796SAndrew Morton 			/* This CPU gets to do the counting */
278dd287796SAndrew Morton 			spin_counter = pause_on_oops;
279dd287796SAndrew Morton 			do {
280dd287796SAndrew Morton 				spin_unlock(&pause_on_oops_lock);
281dd287796SAndrew Morton 				spin_msec(MSEC_PER_SEC);
282dd287796SAndrew Morton 				spin_lock(&pause_on_oops_lock);
283dd287796SAndrew Morton 			} while (--spin_counter);
284dd287796SAndrew Morton 			pause_on_oops_flag = 0;
285dd287796SAndrew Morton 		} else {
286dd287796SAndrew Morton 			/* This CPU waits for a different one */
287dd287796SAndrew Morton 			while (spin_counter) {
288dd287796SAndrew Morton 				spin_unlock(&pause_on_oops_lock);
289dd287796SAndrew Morton 				spin_msec(1);
290dd287796SAndrew Morton 				spin_lock(&pause_on_oops_lock);
291dd287796SAndrew Morton 			}
292dd287796SAndrew Morton 		}
293dd287796SAndrew Morton 	}
294dd287796SAndrew Morton 	spin_unlock_irqrestore(&pause_on_oops_lock, flags);
295dd287796SAndrew Morton }
296dd287796SAndrew Morton 
297dd287796SAndrew Morton /*
298c95dbf27SIngo Molnar  * Return true if the calling CPU is allowed to print oops-related info.
299c95dbf27SIngo Molnar  * This is a bit racy..
300dd287796SAndrew Morton  */
301dd287796SAndrew Morton int oops_may_print(void)
302dd287796SAndrew Morton {
303dd287796SAndrew Morton 	return pause_on_oops_flag == 0;
304dd287796SAndrew Morton }
305dd287796SAndrew Morton 
306dd287796SAndrew Morton /*
307dd287796SAndrew Morton  * Called when the architecture enters its oops handler, before it prints
308c95dbf27SIngo Molnar  * anything.  If this is the first CPU to oops, and it's oopsing the first
309c95dbf27SIngo Molnar  * time then let it proceed.
310dd287796SAndrew Morton  *
311c95dbf27SIngo Molnar  * This is all enabled by the pause_on_oops kernel boot option.  We do all
312c95dbf27SIngo Molnar  * this to ensure that oopses don't scroll off the screen.  It has the
313c95dbf27SIngo Molnar  * side-effect of preventing later-oopsing CPUs from mucking up the display,
314c95dbf27SIngo Molnar  * too.
315dd287796SAndrew Morton  *
316c95dbf27SIngo Molnar  * It turns out that the CPU which is allowed to print ends up pausing for
317c95dbf27SIngo Molnar  * the right duration, whereas all the other CPUs pause for twice as long:
318c95dbf27SIngo Molnar  * once in oops_enter(), once in oops_exit().
319dd287796SAndrew Morton  */
320dd287796SAndrew Morton void oops_enter(void)
321dd287796SAndrew Morton {
322bdff7870SThomas Gleixner 	tracing_off();
323c95dbf27SIngo Molnar 	/* can't trust the integrity of the kernel anymore: */
324c95dbf27SIngo Molnar 	debug_locks_off();
325dd287796SAndrew Morton 	do_oops_enter_exit();
326dd287796SAndrew Morton }
327dd287796SAndrew Morton 
328dd287796SAndrew Morton /*
3292c3b20e9SArjan van de Ven  * 64-bit random ID for oopses:
3302c3b20e9SArjan van de Ven  */
3312c3b20e9SArjan van de Ven static u64 oops_id;
3322c3b20e9SArjan van de Ven 
3332c3b20e9SArjan van de Ven static int init_oops_id(void)
3342c3b20e9SArjan van de Ven {
3352c3b20e9SArjan van de Ven 	if (!oops_id)
3362c3b20e9SArjan van de Ven 		get_random_bytes(&oops_id, sizeof(oops_id));
337d6624f99SArjan van de Ven 	else
338d6624f99SArjan van de Ven 		oops_id++;
3392c3b20e9SArjan van de Ven 
3402c3b20e9SArjan van de Ven 	return 0;
3412c3b20e9SArjan van de Ven }
3422c3b20e9SArjan van de Ven late_initcall(init_oops_id);
3432c3b20e9SArjan van de Ven 
34471c33911SArjan van de Ven static void print_oops_end_marker(void)
34571c33911SArjan van de Ven {
34671c33911SArjan van de Ven 	init_oops_id();
34771c33911SArjan van de Ven 	printk(KERN_WARNING "---[ end trace %016llx ]---\n",
34871c33911SArjan van de Ven 		(unsigned long long)oops_id);
34971c33911SArjan van de Ven }
35071c33911SArjan van de Ven 
3512c3b20e9SArjan van de Ven /*
352dd287796SAndrew Morton  * Called when the architecture exits its oops handler, after printing
353dd287796SAndrew Morton  * everything.
354dd287796SAndrew Morton  */
355dd287796SAndrew Morton void oops_exit(void)
356dd287796SAndrew Morton {
357dd287796SAndrew Morton 	do_oops_enter_exit();
35871c33911SArjan van de Ven 	print_oops_end_marker();
359456b565cSSimon Kagstrom 	kmsg_dump(KMSG_DUMP_OOPS);
360dd287796SAndrew Morton }
3613162f751SArjan van de Ven 
36279b4cc5eSArjan van de Ven #ifdef WANT_WARN_ON_SLOWPATH
3630f6f49a8SLinus Torvalds struct slowpath_args {
3640f6f49a8SLinus Torvalds 	const char *fmt;
365a8f18b90SArjan van de Ven 	va_list args;
3660f6f49a8SLinus Torvalds };
3670f6f49a8SLinus Torvalds 
3680f6f49a8SLinus Torvalds static void warn_slowpath_common(const char *file, int line, void *caller, struct slowpath_args *args)
3690f6f49a8SLinus Torvalds {
370bd89bb29SArjan van de Ven 	const char *board;
371bd89bb29SArjan van de Ven 
372a8f18b90SArjan van de Ven 	printk(KERN_WARNING "------------[ cut here ]------------\n");
3730f6f49a8SLinus Torvalds 	printk(KERN_WARNING "WARNING: at %s:%d %pS()\n", file, line, caller);
374bd89bb29SArjan van de Ven 	board = dmi_get_system_info(DMI_PRODUCT_NAME);
375bd89bb29SArjan van de Ven 	if (board)
376bd89bb29SArjan van de Ven 		printk(KERN_WARNING "Hardware name: %s\n", board);
37774853dbaSArjan van de Ven 
3780f6f49a8SLinus Torvalds 	if (args)
3790f6f49a8SLinus Torvalds 		vprintk(args->fmt, args->args);
380a8f18b90SArjan van de Ven 
381a8f18b90SArjan van de Ven 	print_modules();
382a8f18b90SArjan van de Ven 	dump_stack();
383a8f18b90SArjan van de Ven 	print_oops_end_marker();
384a8f18b90SArjan van de Ven 	add_taint(TAINT_WARN);
385a8f18b90SArjan van de Ven }
3860f6f49a8SLinus Torvalds 
3870f6f49a8SLinus Torvalds void warn_slowpath_fmt(const char *file, int line, const char *fmt, ...)
3880f6f49a8SLinus Torvalds {
3890f6f49a8SLinus Torvalds 	struct slowpath_args args;
3900f6f49a8SLinus Torvalds 
3910f6f49a8SLinus Torvalds 	args.fmt = fmt;
3920f6f49a8SLinus Torvalds 	va_start(args.args, fmt);
3930f6f49a8SLinus Torvalds 	warn_slowpath_common(file, line, __builtin_return_address(0), &args);
3940f6f49a8SLinus Torvalds 	va_end(args.args);
3950f6f49a8SLinus Torvalds }
39657adc4d2SAndi Kleen EXPORT_SYMBOL(warn_slowpath_fmt);
39757adc4d2SAndi Kleen 
39857adc4d2SAndi Kleen void warn_slowpath_null(const char *file, int line)
39957adc4d2SAndi Kleen {
4000f6f49a8SLinus Torvalds 	warn_slowpath_common(file, line, __builtin_return_address(0), NULL);
40157adc4d2SAndi Kleen }
40257adc4d2SAndi Kleen EXPORT_SYMBOL(warn_slowpath_null);
40379b4cc5eSArjan van de Ven #endif
40479b4cc5eSArjan van de Ven 
4053162f751SArjan van de Ven #ifdef CONFIG_CC_STACKPROTECTOR
40654371a43SArjan van de Ven 
4073162f751SArjan van de Ven /*
4083162f751SArjan van de Ven  * Called when gcc's -fstack-protector feature is used, and
4093162f751SArjan van de Ven  * gcc detects corruption of the on-stack canary value
4103162f751SArjan van de Ven  */
4113162f751SArjan van de Ven void __stack_chk_fail(void)
4123162f751SArjan van de Ven {
413517a92c4SIngo Molnar 	panic("stack-protector: Kernel stack is corrupted in: %p\n",
414517a92c4SIngo Molnar 		__builtin_return_address(0));
4153162f751SArjan van de Ven }
4163162f751SArjan van de Ven EXPORT_SYMBOL(__stack_chk_fail);
41754371a43SArjan van de Ven 
4183162f751SArjan van de Ven #endif
419f44dd164SRusty Russell 
420f44dd164SRusty Russell core_param(panic, panic_timeout, int, 0644);
421f44dd164SRusty Russell core_param(pause_on_oops, pause_on_oops, int, 0644);
422