]> git.ipfire.org Git - people/pmueller/ipfire-2.x.git/blob - src/patches/60060_xen-x86-consistent-nmi.patch1
Imported xen patches.
[people/pmueller/ipfire-2.x.git] / src / patches / 60060_xen-x86-consistent-nmi.patch1
1 From: jbeulich@novell.com
2 Subject: make i386 and x86 NMI code consistent, disable all APIC-related stuff
3 Patch-mainline: obsolete
4 References: 191115
5
6 ---
7 arch/x86/kernel/Makefile | 1 -
8 arch/x86/kernel/cpu/Makefile | 2 +-
9 arch/x86/kernel/nmi.c | 13 ++++++++++---
10 arch/x86/kernel/traps_32-xen.c | 2 ++
11 arch/x86/kernel/traps_64-xen.c | 6 +++++-
12 arch/x86/mach-xen/setup.c | 4 ----
13 include/asm-x86/irq.h | 2 +-
14 include/asm-x86/nmi.h | 12 ++++++++----
15 kernel/sysctl.c | 2 ++
16 9 files changed, 29 insertions(+), 15 deletions(-)
17
18 --- a/arch/x86/kernel/cpu/Makefile
19 +++ b/arch/x86/kernel/cpu/Makefile
20 @@ -24,3 +24,4 @@ obj-$(CONFIG_CPU_FREQ) += cpufreq/
21
22 obj-$(CONFIG_X86_LOCAL_APIC) += perfctr-watchdog.o
23 +disabled-obj-$(CONFIG_XEN) := perfctr-watchdog.o
24
25 --- a/arch/x86/kernel/Makefile
26 +++ b/arch/x86/kernel/Makefile
27 @@ -120,7 +120,6 @@ ifeq ($(CONFIG_X86_64),y)
28
29 obj-$(CONFIG_PCI_MMCONFIG) += mmconf-fam10h_64.o
30
31 - obj-$(CONFIG_XEN) += nmi.o
32 time_64-$(CONFIG_XEN) += time_32.o
33 endif
34
35 --- a/arch/x86/kernel/nmi.c
36 +++ b/arch/x86/kernel/nmi.c
37 @@ -27,7 +27,7 @@
38 #include <linux/kdebug.h>
39 #include <linux/smp.h>
40
41 -#ifndef CONFIG_XEN
42 +#ifdef ARCH_HAS_NMI_WATCHDOG
43 #include <asm/i8259.h>
44 #endif
45 #include <asm/io_apic.h>
46 @@ -41,6 +41,9 @@
47 #include <mach_traps.h>
48
49 int unknown_nmi_panic;
50 +
51 +#ifdef ARCH_HAS_NMI_WATCHDOG
52 +
53 int nmi_watchdog_enabled;
54
55 static cpumask_t backtrace_mask = CPU_MASK_NONE;
56 @@ -181,10 +184,8 @@ int __init check_nmi_watchdog(void)
57 kfree(prev_nmi_count);
58 return 0;
59 error:
60 -#ifndef CONFIG_XEN
61 if (nmi_watchdog == NMI_IO_APIC && !timer_through_8259)
62 disable_8259A_irq(0);
63 -#endif
64 #ifdef CONFIG_X86_32
65 timer_ack = 0;
66 #endif
67 @@ -460,6 +461,8 @@ nmi_watchdog_tick(struct pt_regs *regs,
68 return rc;
69 }
70
71 +#endif /* ARCH_HAS_NMI_WATCHDOG */
72 +
73 #ifdef CONFIG_SYSCTL
74
75 static int __init setup_unknown_nmi_panic(char *str)
76 @@ -479,6 +482,7 @@ static int unknown_nmi_panic_callback(st
77 return 0;
78 }
79
80 +#ifdef ARCH_HAS_NMI_WATCHDOG
81 /*
82 * proc handler for /proc/sys/kernel/nmi
83 */
84 @@ -511,6 +515,7 @@ int proc_nmi_enabled(struct ctl_table *t
85 }
86 return 0;
87 }
88 +#endif
89
90 #endif /* CONFIG_SYSCTL */
91
92 @@ -523,6 +528,7 @@ int do_nmi_callback(struct pt_regs *regs
93 return 0;
94 }
95
96 +#ifdef ARCH_HAS_NMI_WATCHDOG
97 void __trigger_all_cpu_backtrace(void)
98 {
99 int i;
100 @@ -535,3 +541,4 @@ void __trigger_all_cpu_backtrace(void)
101 mdelay(1);
102 }
103 }
104 +#endif
105 --- a/arch/x86/kernel/traps_32-xen.c
106 +++ b/arch/x86/kernel/traps_32-xen.c
107 @@ -823,12 +823,14 @@ static notrace __kprobes void default_do
108 == NOTIFY_STOP)
109 return;
110 #ifdef CONFIG_X86_LOCAL_APIC
111 +#ifdef ARCH_HAS_NMI_WATCHDOG
112 /*
113 * Ok, so this is none of the documented NMI sources,
114 * so it must be the NMI watchdog.
115 */
116 if (nmi_watchdog_tick(regs, reason))
117 return;
118 +#endif
119 if (!do_nmi_callback(regs, cpu))
120 unknown_nmi_error(reason, regs);
121 #else
122 --- a/arch/x86/kernel/traps_64-xen.c
123 +++ b/arch/x86/kernel/traps_64-xen.c
124 @@ -636,7 +636,7 @@ void die(const char *str, struct pt_regs
125 oops_end(flags, regs, SIGSEGV);
126 }
127
128 -#if defined(CONFIG_X86_LOCAL_APIC) || defined(CONFIG_SYSCTL)
129 +#ifdef CONFIG_SYSCTL
130 notrace __kprobes void
131 die_nmi(char *str, struct pt_regs *regs, int do_panic)
132 {
133 @@ -882,6 +882,7 @@ asmlinkage notrace __kprobes void defaul
134 == NOTIFY_STOP)
135 return;
136 #ifdef CONFIG_X86_LOCAL_APIC
137 +#ifdef ARCH_HAS_NMI_WATCHDOG
138 /*
139 * Ok, so this is none of the documented NMI sources,
140 * so it must be the NMI watchdog.
141 @@ -891,6 +892,9 @@ asmlinkage notrace __kprobes void defaul
142 #endif
143 if (!do_nmi_callback(regs, cpu))
144 unknown_nmi_error(reason, regs);
145 +#else
146 + unknown_nmi_error(reason, regs);
147 +#endif
148
149 return;
150 }
151 --- a/arch/x86/mach-xen/setup.c
152 +++ b/arch/x86/mach-xen/setup.c
153 @@ -108,12 +108,10 @@ void __init machine_specific_arch_setup(
154 .address = CALLBACK_ADDR(system_call)
155 };
156 #endif
157 -#if defined(CONFIG_X86_LOCAL_APIC) || defined(CONFIG_X86_32)
158 static struct callback_register __initdata nmi_cb = {
159 .type = CALLBACKTYPE_nmi,
160 .address = CALLBACK_ADDR(nmi)
161 };
162 -#endif
163
164 ret = HYPERVISOR_callback_op(CALLBACKOP_register, &event);
165 if (ret == 0)
166 @@ -137,7 +135,6 @@ void __init machine_specific_arch_setup(
167 #endif
168 BUG_ON(ret);
169
170 -#if defined(CONFIG_X86_LOCAL_APIC) || defined(CONFIG_X86_32)
171 ret = HYPERVISOR_callback_op(CALLBACKOP_register, &nmi_cb);
172 #if CONFIG_XEN_COMPAT <= 0x030002
173 if (ret == -ENOSYS) {
174 @@ -148,7 +145,6 @@ void __init machine_specific_arch_setup(
175 HYPERVISOR_nmi_op(XENNMI_register_callback, &cb);
176 }
177 #endif
178 -#endif
179
180 #ifdef CONFIG_X86_32
181 /* Do an early initialization of the fixmap area */
182 --- a/include/asm-x86/irq.h
183 +++ b/include/asm-x86/irq.h
184 @@ -15,7 +15,7 @@ static inline int irq_canonicalize(int i
185 return ((irq == 2) ? 9 : irq);
186 }
187
188 -#ifdef CONFIG_X86_LOCAL_APIC
189 +#if defined(CONFIG_X86_LOCAL_APIC) && !defined(CONFIG_XEN)
190 # define ARCH_HAS_NMI_WATCHDOG
191 #endif
192
193 --- a/include/asm-x86/nmi.h
194 +++ b/include/asm-x86/nmi.h
195 @@ -5,8 +5,6 @@
196 #include <asm/irq.h>
197 #include <asm/io.h>
198
199 -#ifdef ARCH_HAS_NMI_WATCHDOG
200 -
201 /**
202 * do_nmi_callback
203 *
204 @@ -20,6 +18,11 @@ extern void default_do_nmi(struct pt_reg
205 #endif
206
207 extern void die_nmi(char *str, struct pt_regs *regs, int do_panic);
208 +
209 +extern int unknown_nmi_panic;
210 +
211 +#ifdef ARCH_HAS_NMI_WATCHDOG
212 +
213 extern int check_nmi_watchdog(void);
214 extern int nmi_watchdog_enabled;
215 extern int avail_to_resrv_perfctr_nmi_bit(unsigned int);
216 @@ -46,7 +49,6 @@ struct ctl_table;
217 struct file;
218 extern int proc_nmi_enabled(struct ctl_table *, int , struct file *,
219 void __user *, size_t *, loff_t *);
220 -extern int unknown_nmi_panic;
221
222 void __trigger_all_cpu_backtrace(void);
223 #define trigger_all_cpu_backtrace() __trigger_all_cpu_backtrace()
224 @@ -69,7 +71,6 @@ static inline int nmi_watchdog_active(vo
225 */
226 return nmi_watchdog & 0x3;
227 }
228 -#endif
229
230 void lapic_watchdog_stop(void);
231 int lapic_watchdog_init(unsigned nmi_hz);
232 @@ -78,6 +79,9 @@ unsigned lapic_adjust_nmi_hz(unsigned hz
233 int lapic_watchdog_ok(void);
234 void disable_lapic_nmi_watchdog(void);
235 void enable_lapic_nmi_watchdog(void);
236 +
237 +#endif
238 +
239 void stop_nmi(void);
240 void restart_nmi(void);
241
242 --- a/kernel/sysctl.c
243 +++ b/kernel/sysctl.c
244 @@ -673,6 +673,7 @@ static struct ctl_table kern_table[] = {
245 .mode = 0644,
246 .proc_handler = &proc_dointvec,
247 },
248 +#ifdef ARCH_HAS_NMI_WATCHDOG
249 {
250 .procname = "nmi_watchdog",
251 .data = &nmi_watchdog_enabled,
252 @@ -681,6 +682,7 @@ static struct ctl_table kern_table[] = {
253 .proc_handler = &proc_nmi_enabled,
254 },
255 #endif
256 +#endif
257 #if defined(CONFIG_X86)
258 {
259 .ctl_name = KERN_PANIC_ON_NMI,