4 * Copyright (C) 1991, 1992 Linus Torvalds
8 * This function is used through-out the kernel (including mm and fs)
9 * to indicate a major problem.
11 #include <linux/config.h>
12 #include <linux/module.h>
13 #include <linux/sched.h>
14 #include <linux/delay.h>
15 #include <linux/reboot.h>
16 #include <linux/notifier.h>
17 #include <linux/init.h>
18 #include <linux/sysrq.h>
19 #include <linux/interrupt.h>
20 #include <linux/nmi.h>
21 #include <linux/kexec.h>
22 #include <linux/crash_dump.h>
24 int panic_timeout = 900;
25 int panic_on_oops = 1;
30 EXPORT_SYMBOL(panic_timeout);
32 struct notifier_block *panic_notifier_list;
34 EXPORT_SYMBOL(panic_notifier_list);
36 static int __init panic_setup(char *str)
38 panic_timeout = simple_strtoul(str, NULL, 0);
41 __setup("panic=", panic_setup);
43 static long no_blink(long time)
48 /* Returns how long it waited in ms */
49 long (*panic_blink)(long time);
50 EXPORT_SYMBOL(panic_blink);
53 * panic - halt the system
54 * @fmt: The text string to print
56 * Display a message, then perform cleanups.
58 * This function never returns.
61 NORET_TYPE void panic(const char * fmt, ...)
64 static char buf[1024];
66 #if defined(CONFIG_ARCH_S390)
67 unsigned long caller = (unsigned long) __builtin_return_address(0);
72 vsnprintf(buf, sizeof(buf), fmt, args);
74 printk(KERN_EMERG "Kernel panic - not syncing: %s\n",buf);
80 /* If we have crashed, perform a kexec reboot, for dump write-out */
81 crash_machine_kexec();
87 notifier_call_chain(&panic_notifier_list, 0, buf);
90 panic_blink = no_blink;
92 if (panic_timeout > 0)
95 * Delay timeout seconds before rebooting the machine.
96 * We can't use the "normal" timers since we just panicked..
98 printk(KERN_EMERG "Rebooting in %d seconds..",panic_timeout);
99 for (i = 0; i < panic_timeout*1000; ) {
100 touch_nmi_watchdog();
106 * Should we run the reboot notifier. For the moment Im
107 * choosing not too. It might crash, be corrupt or do
108 * more harm than good for other reasons.
110 machine_restart(NULL);
114 extern int stop_a_enabled;
115 /* Make sure the user can actually press Stop-A (L1-A) */
117 printk(KERN_EMERG "Press Stop-A (L1-A) to return to the boot prom\n");
120 #if defined(CONFIG_ARCH_S390)
121 disabled_wait(caller);
131 EXPORT_SYMBOL(panic);
134 * print_tainted - return a string to represent the kernel taint state.
136 * 'P' - Proprietary module has been loaded.
137 * 'F' - Module has been forcibly loaded.
138 * 'S' - SMP with CPUs not designed for SMP.
139 * 'R' - User forced a module unload.
140 * 'M' - Machine had a machine check experience.
141 * 'B' - System has hit bad_page.
143 * The string is overwritten by the next call to print_taint().
146 const char *print_tainted(void)
150 snprintf(buf, sizeof(buf), "Tainted: %c%c%c%c%c%c",
151 tainted & TAINT_PROPRIETARY_MODULE ? 'P' : 'G',
152 tainted & TAINT_FORCED_MODULE ? 'F' : ' ',
153 tainted & TAINT_UNSAFE_SMP ? 'S' : ' ',
154 tainted & TAINT_FORCED_RMMOD ? 'R' : ' ',
155 tainted & TAINT_MACHINE_CHECK ? 'M' : ' ',
156 tainted & TAINT_BAD_PAGE ? 'B' : ' ');
159 snprintf(buf, sizeof(buf), "Not tainted");
162 EXPORT_SYMBOL(print_tainted);
164 void add_taint(unsigned flag)
168 EXPORT_SYMBOL(add_taint);
170 int check_tainted(void)
174 EXPORT_SYMBOL_GPL(check_tainted);