diff options
Diffstat (limited to 'kernel/panic.c')
| -rw-r--r-- | kernel/panic.c | 115 | 
1 files changed, 60 insertions, 55 deletions
diff --git a/kernel/panic.c b/kernel/panic.c index 32fe4eff1b89..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(); | 
| @@ -77,7 +73,6 @@ NORET_TYPE void panic(const char * fmt, ...) | |||
| 77 | #ifdef CONFIG_DEBUG_BUGVERBOSE | 73 | #ifdef CONFIG_DEBUG_BUGVERBOSE | 
| 78 | dump_stack(); | 74 | dump_stack(); | 
| 79 | #endif | 75 | #endif | 
| 80 | bust_spinlocks(0); | ||
| 81 | 76 | ||
| 82 | /* | 77 | /* | 
| 83 | * 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 | 
| @@ -86,14 +81,12 @@ NORET_TYPE void panic(const char * fmt, ...) | |||
| 86 | */ | 81 | */ | 
| 87 | crash_kexec(NULL); | 82 | crash_kexec(NULL); | 
| 88 | 83 | ||
| 89 | #ifdef CONFIG_SMP | ||
| 90 | /* | 84 | /* | 
| 91 | * Note smp_send_stop is the usual smp shutdown function, which | 85 | * Note smp_send_stop is the usual smp shutdown function, which | 
| 92 | * 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 | 
| 93 | * situation. | 87 | * situation. | 
| 94 | */ | 88 | */ | 
| 95 | smp_send_stop(); | 89 | smp_send_stop(); | 
| 96 | #endif | ||
| 97 | 90 | ||
| 98 | atomic_notifier_call_chain(&panic_notifier_list, 0, buf); | 91 | atomic_notifier_call_chain(&panic_notifier_list, 0, buf); | 
| 99 | 92 | ||
| @@ -102,19 +95,21 @@ NORET_TYPE void panic(const char * fmt, ...) | |||
| 102 | 95 | ||
| 103 | if (panic_timeout > 0) { | 96 | if (panic_timeout > 0) { | 
| 104 | /* | 97 | /* | 
| 105 | * Delay timeout seconds before rebooting the machine. | 98 | * Delay timeout seconds before rebooting the machine. | 
| 106 | * We can't use the "normal" timers since we just panicked.. | 99 | * We can't use the "normal" timers since we just panicked. | 
| 107 | */ | 100 | */ | 
| 108 | printk(KERN_EMERG "Rebooting in %d seconds..",panic_timeout); | 101 | printk(KERN_EMERG "Rebooting in %d seconds..", panic_timeout); | 
| 102 | |||
| 109 | for (i = 0; i < panic_timeout*1000; ) { | 103 | for (i = 0; i < panic_timeout*1000; ) { | 
| 110 | touch_nmi_watchdog(); | 104 | touch_nmi_watchdog(); | 
| 111 | i += panic_blink(i); | 105 | i += panic_blink(i); | 
| 112 | mdelay(1); | 106 | mdelay(1); | 
| 113 | i++; | 107 | i++; | 
| 114 | } | 108 | } | 
| 115 | /* This will not be a clean reboot, with everything | 109 | /* | 
| 116 | * shutting down. But if there is a chance of | 110 | * This will not be a clean reboot, with everything | 
| 117 | * 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. | ||
| 118 | */ | 113 | */ | 
| 119 | emergency_restart(); | 114 | emergency_restart(); | 
| 120 | } | 115 | } | 
| @@ -127,38 +122,44 @@ NORET_TYPE void panic(const char * fmt, ...) | |||
| 127 | } | 122 | } | 
| 128 | #endif | 123 | #endif | 
| 129 | #if defined(CONFIG_S390) | 124 | #if defined(CONFIG_S390) | 
| 130 | disabled_wait(caller); | 125 | { | 
| 126 | unsigned long caller; | ||
| 127 | |||
| 128 | caller = (unsigned long)__builtin_return_address(0); | ||
| 129 | disabled_wait(caller); | ||
| 130 | } | ||
| 131 | #endif | 131 | #endif | 
| 132 | local_irq_enable(); | 132 | local_irq_enable(); | 
| 133 | for (i = 0;;) { | 133 | for (i = 0; ; ) { | 
| 134 | touch_softlockup_watchdog(); | 134 | touch_softlockup_watchdog(); | 
| 135 | i += panic_blink(i); | 135 | i += panic_blink(i); | 
| 136 | mdelay(1); | 136 | mdelay(1); | 
| 137 | i++; | 137 | i++; | 
| 138 | } | 138 | } | 
| 139 | bust_spinlocks(0); | ||
| 139 | } | 140 | } | 
| 140 | 141 | ||
| 141 | EXPORT_SYMBOL(panic); | 142 | EXPORT_SYMBOL(panic); | 
| 142 | 143 | ||
| 143 | 144 | ||
| 144 | struct tnt { | 145 | struct tnt { | 
| 145 | u8 bit; | 146 | u8 bit; | 
| 146 | char true; | 147 | char true; | 
| 147 | char false; | 148 | char false; | 
| 148 | }; | 149 | }; | 
| 149 | 150 | ||
| 150 | static const struct tnt tnts[] = { | 151 | static const struct tnt tnts[] = { | 
| 151 | { TAINT_PROPRIETARY_MODULE, 'P', 'G' }, | 152 | { TAINT_PROPRIETARY_MODULE, 'P', 'G' }, | 
| 152 | { TAINT_FORCED_MODULE, 'F', ' ' }, | 153 | { TAINT_FORCED_MODULE, 'F', ' ' }, | 
| 153 | { TAINT_UNSAFE_SMP, 'S', ' ' }, | 154 | { TAINT_UNSAFE_SMP, 'S', ' ' }, | 
| 154 | { TAINT_FORCED_RMMOD, 'R', ' ' }, | 155 | { TAINT_FORCED_RMMOD, 'R', ' ' }, | 
| 155 | { TAINT_MACHINE_CHECK, 'M', ' ' }, | 156 | { TAINT_MACHINE_CHECK, 'M', ' ' }, | 
| 156 | { TAINT_BAD_PAGE, 'B', ' ' }, | 157 | { TAINT_BAD_PAGE, 'B', ' ' }, | 
| 157 | { TAINT_USER, 'U', ' ' }, | 158 | { TAINT_USER, 'U', ' ' }, | 
| 158 | { TAINT_DIE, 'D', ' ' }, | 159 | { TAINT_DIE, 'D', ' ' }, | 
| 159 | { TAINT_OVERRIDDEN_ACPI_TABLE, 'A', ' ' }, | 160 | { TAINT_OVERRIDDEN_ACPI_TABLE, 'A', ' ' }, | 
| 160 | { TAINT_WARN, 'W', ' ' }, | 161 | { TAINT_WARN, 'W', ' ' }, | 
| 161 | { TAINT_CRAP, 'C', ' ' }, | 162 | { TAINT_CRAP, 'C', ' ' }, | 
| 162 | }; | 163 | }; | 
| 163 | 164 | ||
| 164 | /** | 165 | /** | 
| @@ -195,7 +196,8 @@ const char *print_tainted(void) | |||
| 195 | *s = 0; | 196 | *s = 0; | 
| 196 | } else | 197 | } else | 
| 197 | snprintf(buf, sizeof(buf), "Not tainted"); | 198 | snprintf(buf, sizeof(buf), "Not tainted"); | 
| 198 | return(buf); | 199 | |
| 200 | return buf; | ||
| 199 | } | 201 | } | 
| 200 | 202 | ||
| 201 | int test_taint(unsigned flag) | 203 | int test_taint(unsigned flag) | 
| @@ -211,7 +213,8 @@ unsigned long get_taint(void) | |||
| 211 | 213 | ||
| 212 | void add_taint(unsigned flag) | 214 | void add_taint(unsigned flag) | 
| 213 | { | 215 | { | 
| 214 | 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; | ||
| 215 | set_bit(flag, &tainted_mask); | 218 | set_bit(flag, &tainted_mask); | 
| 216 | } | 219 | } | 
| 217 | EXPORT_SYMBOL(add_taint); | 220 | EXPORT_SYMBOL(add_taint); | 
| @@ -266,8 +269,8 @@ static void do_oops_enter_exit(void) | |||
| 266 | } | 269 | } | 
| 267 | 270 | ||
| 268 | /* | 271 | /* | 
| 269 | * 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. | 
| 270 | * is a bit racy.. | 273 | * This is a bit racy.. | 
| 271 | */ | 274 | */ | 
| 272 | int oops_may_print(void) | 275 | int oops_may_print(void) | 
| 273 | { | 276 | { | 
| @@ -276,20 +279,22 @@ int oops_may_print(void) | |||
| 276 | 279 | ||
| 277 | /* | 280 | /* | 
| 278 | * Called when the architecture enters its oops handler, before it prints | 281 | * Called when the architecture enters its oops handler, before it prints | 
| 279 | * 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 | 
| 280 | * then let it proceed. | 283 | * time then let it proceed. | 
| 281 | * | 284 | * | 
| 282 | * 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 | 
| 283 | * 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 | 
| 284 | * 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. | ||
| 285 | * | 289 | * | 
| 286 | * 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 | 
| 287 | * 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: | 
| 288 | * oops_enter(), once in oops_exit(). | 292 | * once in oops_enter(), once in oops_exit(). | 
| 289 | */ | 293 | */ | 
| 290 | void oops_enter(void) | 294 | void oops_enter(void) | 
| 291 | { | 295 | { | 
| 292 | 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(); | ||
| 293 | do_oops_enter_exit(); | 298 | do_oops_enter_exit(); | 
| 294 | } | 299 | } | 
| 295 | 300 | ||
