]>
Commit | Line | Data |
---|---|---|
8f69975d BS |
1 | From: Kurt Garloff <garloff@suse.de> |
2 | Subject: [PATCH] X86: sysctl to allow panic on IOCK NMI error | |
3 | References: bnc427979 | |
4 | ||
5 | This patch introduces a sysctl /proc/sys/kernel/panic_on_io_nmi., | |
6 | which defaults to 0 (off). | |
7 | When enabled, the kernel panics when the kernel receives an NMI | |
8 | caused by an IO error. | |
9 | ||
10 | The IO error triggered NMI indicates a serious system condition, | |
11 | which could result in IO data corruption. Rather than contiuing, | |
12 | panicing and dumping might be a better choice, so one can figure | |
13 | out what's causing the IO error. | |
14 | This could be especially important to companies running IO intensive | |
15 | applications where corruption must be avoided, e.g. a banks databases. | |
16 | ||
17 | ||
18 | Signed-off-by: Roberto Angelino <robertangelino@gmail.com> | |
19 | ||
20 | ||
21 | --- | |
22 | arch/x86/kernel/traps_32.c | 4 ++++ | |
23 | arch/x86/kernel/traps_64.c | 4 ++++ | |
24 | include/linux/kernel.h | 1 + | |
25 | include/linux/sysctl.h | 1 + | |
26 | kernel/sysctl.c | 8 ++++++++ | |
27 | kernel/sysctl_check.c | 1 + | |
28 | 6 files changed, 19 insertions(+) | |
29 | ||
30 | --- a/arch/x86/kernel/traps_32.c | |
31 | +++ b/arch/x86/kernel/traps_32.c | |
32 | @@ -83,6 +83,7 @@ gate_desc idt_table[256] | |
33 | __attribute__((__section__(".data.idt"))) = { { { { 0, 0 } } }, }; | |
34 | ||
35 | int panic_on_unrecovered_nmi; | |
36 | +int panic_on_io_nmi; | |
37 | int kstack_depth_to_print = 24; | |
38 | static unsigned int code_bytes = 64; | |
39 | #ifdef CONFIG_STACK_UNWIND | |
40 | @@ -779,6 +780,9 @@ io_check_error(unsigned char reason, str | |
41 | printk(KERN_EMERG "NMI: IOCK error (debug interrupt?)\n"); | |
42 | show_registers(regs); | |
43 | ||
44 | + if (panic_on_io_nmi) | |
45 | + panic("NMI IOCK error: Not continuing"); | |
46 | + | |
47 | /* Re-enable the IOCK line, wait for a few seconds */ | |
48 | reason = (reason & 0xf) | 8; | |
49 | outb(reason, 0x61); | |
50 | --- a/arch/x86/kernel/traps_64.c | |
51 | +++ b/arch/x86/kernel/traps_64.c | |
52 | @@ -56,6 +56,7 @@ | |
53 | #include <mach_traps.h> | |
54 | ||
55 | int panic_on_unrecovered_nmi; | |
56 | +int panic_on_io_nmi; | |
57 | int kstack_depth_to_print = 12; | |
58 | static unsigned int code_bytes = 64; | |
59 | #ifdef CONFIG_STACK_UNWIND | |
60 | @@ -840,6 +841,9 @@ io_check_error(unsigned char reason, str | |
61 | printk("NMI: IOCK error (debug interrupt?)\n"); | |
62 | show_registers(regs); | |
63 | ||
64 | + if (panic_on_io_nmi) | |
65 | + panic("NMI IOCK error: Not continuing"); | |
66 | + | |
67 | /* Re-enable the IOCK line, wait for a few seconds */ | |
68 | reason = (reason & 0xf) | 8; | |
69 | outb(reason, 0x61); | |
70 | --- a/include/linux/kernel.h | |
71 | +++ b/include/linux/kernel.h | |
72 | @@ -236,6 +236,7 @@ extern int oops_in_progress; /* If set, | |
73 | extern int panic_timeout; | |
74 | extern int panic_on_oops; | |
75 | extern int panic_on_unrecovered_nmi; | |
76 | +extern int panic_on_io_nmi; | |
77 | extern int tainted; | |
78 | extern int unsupported; | |
79 | extern const char *print_tainted(void); | |
80 | --- a/include/linux/sysctl.h | |
81 | +++ b/include/linux/sysctl.h | |
82 | @@ -165,6 +165,7 @@ enum | |
83 | KERN_PANIC_ON_NMI=76, /* int: whether we will panic on an unrecovered */ | |
84 | KERN_KDB=77, /* int: kdb on/off */ | |
85 | KERN_DUMP_AFTER_NOTIFIER=78, /* int: kdump after panic_notifier (SUSE only) */ | |
86 | + KERN_PANIC_ON_IO_NMI=79, /* int: whether we will panic on an io NMI */ | |
87 | }; | |
88 | ||
89 | ||
90 | --- a/kernel/sysctl.c | |
91 | +++ b/kernel/sysctl.c | |
92 | @@ -691,6 +691,14 @@ static struct ctl_table kern_table[] = { | |
93 | .proc_handler = &proc_dointvec, | |
94 | }, | |
95 | { | |
96 | + .ctl_name = KERN_PANIC_ON_IO_NMI, | |
97 | + .procname = "panic_on_io_nmi", | |
98 | + .data = &panic_on_io_nmi, | |
99 | + .maxlen = sizeof(int), | |
100 | + .mode = 0644, | |
101 | + .proc_handler = &proc_dointvec, | |
102 | + }, | |
103 | + { | |
104 | .ctl_name = KERN_BOOTLOADER_TYPE, | |
105 | .procname = "bootloader_type", | |
106 | .data = &bootloader_type, | |
107 | --- a/kernel/sysctl_check.c | |
108 | +++ b/kernel/sysctl_check.c | |
109 | @@ -104,6 +104,7 @@ static const struct trans_ctl_table tran | |
110 | { KERN_MAX_LOCK_DEPTH, "max_lock_depth" }, | |
111 | { KERN_NMI_WATCHDOG, "nmi_watchdog" }, | |
112 | { KERN_PANIC_ON_NMI, "panic_on_unrecovered_nmi" }, | |
113 | + { KERN_PANIC_ON_IO_NMI, "panic_on_io_nmi" }, | |
114 | { KERN_SETUID_DUMPABLE, "suid_dumpable" }, | |
115 | { KERN_KDB, "kdb" }, | |
116 | { KERN_DUMP_AFTER_NOTIFIER, "dump_after_notifier" }, |