1 From: jbeulich@novell.com
2 Subject: make i386 and x86 NMI code consistent, disable all APIC-related stuff
3 Patch-mainline: obsolete
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(-)
18 --- a/arch/x86/kernel/cpu/Makefile
19 +++ b/arch/x86/kernel/cpu/Makefile
20 @@ -24,3 +24,4 @@ obj-$(CONFIG_CPU_FREQ) += cpufreq/
22 obj-$(CONFIG_X86_LOCAL_APIC) += perfctr-watchdog.o
23 +disabled-obj-$(CONFIG_XEN) := perfctr-watchdog.o
25 --- a/arch/x86/kernel/Makefile
26 +++ b/arch/x86/kernel/Makefile
27 @@ -120,7 +120,6 @@ ifeq ($(CONFIG_X86_64),y)
29 obj-$(CONFIG_PCI_MMCONFIG) += mmconf-fam10h_64.o
31 - obj-$(CONFIG_XEN) += nmi.o
32 time_64-$(CONFIG_XEN) += time_32.o
35 --- a/arch/x86/kernel/nmi.c
36 +++ b/arch/x86/kernel/nmi.c
38 #include <linux/kdebug.h>
39 #include <linux/smp.h>
42 +#ifdef ARCH_HAS_NMI_WATCHDOG
43 #include <asm/i8259.h>
45 #include <asm/io_apic.h>
47 #include <mach_traps.h>
49 int unknown_nmi_panic;
51 +#ifdef ARCH_HAS_NMI_WATCHDOG
53 int nmi_watchdog_enabled;
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);
61 if (nmi_watchdog == NMI_IO_APIC && !timer_through_8259)
67 @@ -460,6 +461,8 @@ nmi_watchdog_tick(struct pt_regs *regs,
71 +#endif /* ARCH_HAS_NMI_WATCHDOG */
75 static int __init setup_unknown_nmi_panic(char *str)
76 @@ -479,6 +482,7 @@ static int unknown_nmi_panic_callback(st
80 +#ifdef ARCH_HAS_NMI_WATCHDOG
82 * proc handler for /proc/sys/kernel/nmi
84 @@ -511,6 +515,7 @@ int proc_nmi_enabled(struct ctl_table *t
90 #endif /* CONFIG_SYSCTL */
92 @@ -523,6 +528,7 @@ int do_nmi_callback(struct pt_regs *regs
96 +#ifdef ARCH_HAS_NMI_WATCHDOG
97 void __trigger_all_cpu_backtrace(void)
100 @@ -535,3 +541,4 @@ void __trigger_all_cpu_backtrace(void)
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
110 #ifdef CONFIG_X86_LOCAL_APIC
111 +#ifdef ARCH_HAS_NMI_WATCHDOG
113 * Ok, so this is none of the documented NMI sources,
114 * so it must be the NMI watchdog.
116 if (nmi_watchdog_tick(regs, reason))
119 if (!do_nmi_callback(regs, cpu))
120 unknown_nmi_error(reason, regs);
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);
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)
133 @@ -882,6 +882,7 @@ asmlinkage notrace __kprobes void defaul
136 #ifdef CONFIG_X86_LOCAL_APIC
137 +#ifdef ARCH_HAS_NMI_WATCHDOG
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
143 if (!do_nmi_callback(regs, cpu))
144 unknown_nmi_error(reason, regs);
146 + unknown_nmi_error(reason, regs);
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)
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)
164 ret = HYPERVISOR_callback_op(CALLBACKOP_register, &event);
166 @@ -137,7 +135,6 @@ void __init machine_specific_arch_setup(
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);
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);
188 -#ifdef CONFIG_X86_LOCAL_APIC
189 +#if defined(CONFIG_X86_LOCAL_APIC) && !defined(CONFIG_XEN)
190 # define ARCH_HAS_NMI_WATCHDOG
193 --- a/include/asm-x86/nmi.h
194 +++ b/include/asm-x86/nmi.h
199 -#ifdef ARCH_HAS_NMI_WATCHDOG
204 @@ -20,6 +18,11 @@ extern void default_do_nmi(struct pt_reg
207 extern void die_nmi(char *str, struct pt_regs *regs, int do_panic);
209 +extern int unknown_nmi_panic;
211 +#ifdef ARCH_HAS_NMI_WATCHDOG
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;
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;
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
226 return nmi_watchdog & 0x3;
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);
240 void restart_nmi(void);
242 --- a/kernel/sysctl.c
243 +++ b/kernel/sysctl.c
244 @@ -673,6 +673,7 @@ static struct ctl_table kern_table[] = {
246 .proc_handler = &proc_dointvec,
248 +#ifdef ARCH_HAS_NMI_WATCHDOG
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,
257 #if defined(CONFIG_X86)
259 .ctl_name = KERN_PANIC_ON_NMI,