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/syscalls.h>
20 #include <linux/interrupt.h>
21 #include <linux/nmi.h>
27 EXPORT_SYMBOL(panic_timeout);
29 struct notifier_block *panic_notifier_list;
31 EXPORT_SYMBOL(panic_notifier_list);
33 static int __init panic_setup(char *str)
35 panic_timeout = simple_strtoul(str, NULL, 0);
38 __setup("panic=", panic_setup);
41 EXPORT_SYMBOL_GPL(netdump_mode);
44 * panic - halt the system
45 * @fmt: The text string to print
47 * Display a message, then perform cleanups. Functions in the panic
48 * notifier list are called after the filesystem cache is flushed (when possible).
50 * This function never returns.
53 NORET_TYPE void panic(const char * fmt, ...)
55 static char buf[1024];
57 #if defined(CONFIG_ARCH_S390)
58 unsigned long caller = (unsigned long) __builtin_return_address(0);
63 vsnprintf(buf, sizeof(buf), fmt, args);
65 printk(KERN_EMERG "Kernel panic: %s\n",buf);
69 printk(KERN_EMERG "In interrupt handler - not syncing\n");
70 else if (!current->pid)
71 printk(KERN_EMERG "In idle task - not syncing\n");
80 notifier_call_chain(&panic_notifier_list, 0, buf);
82 if (panic_timeout > 0)
86 * Delay timeout seconds before rebooting the machine.
87 * We can't use the "normal" timers since we just panicked..
89 printk(KERN_EMERG "Rebooting in %d seconds..",panic_timeout);
90 for (i = 0; i < panic_timeout; i++) {
95 * Should we run the reboot notifier. For the moment Im
96 * choosing not too. It might crash, be corrupt or do
97 * more harm than good for other reasons.
99 machine_restart(NULL);
103 extern int stop_a_enabled;
104 /* Make sure the user can actually press L1-A */
106 printk(KERN_EMERG "Press L1-A to return to the boot prom\n");
109 #if defined(CONFIG_ARCH_S390)
110 disabled_wait(caller);
117 EXPORT_SYMBOL(panic);
120 * print_tainted - return a string to represent the kernel taint state.
122 * 'P' - Proprietary module has been loaded.
123 * 'F' - Module has been forcibly loaded.
124 * 'S' - SMP with CPUs not designed for SMP.
126 * The string is overwritten by the next call to print_taint().
129 const char *print_tainted(void)
133 snprintf(buf, sizeof(buf), "Tainted: %c%c%c",
134 tainted & TAINT_PROPRIETARY_MODULE ? 'P' : 'G',
135 tainted & TAINT_FORCED_MODULE ? 'F' : ' ',
136 tainted & TAINT_UNSAFE_SMP ? 'S' : ' ');
139 snprintf(buf, sizeof(buf), "Not tainted");