From: jbeulich@novell.com Subject: make i386 and x86 NMI code consistent, disable all APIC-related stuff Patch-mainline: obsolete References: 191115 Index: head-2008-03-06/arch/x86/kernel/cpu/Makefile =================================================================== --- head-2008-03-06.orig/arch/x86/kernel/cpu/Makefile 2008-03-05 16:14:58.000000000 +0100 +++ head-2008-03-06/arch/x86/kernel/cpu/Makefile 2008-03-06 10:52:57.000000000 +0100 @@ -18,4 +18,6 @@ obj-$(CONFIG_X86_MCE) += mcheck/ obj-$(CONFIG_MTRR) += mtrr/ obj-$(CONFIG_CPU_FREQ) += cpufreq/ +ifneq ($(CONFIG_XEN),y) obj-$(CONFIG_X86_LOCAL_APIC) += perfctr-watchdog.o +endif Index: head-2008-03-06/arch/x86/kernel/nmi_32.c =================================================================== --- head-2008-03-06.orig/arch/x86/kernel/nmi_32.c 2008-03-05 16:14:58.000000000 +0100 +++ head-2008-03-06/arch/x86/kernel/nmi_32.c 2008-03-06 10:52:57.000000000 +0100 @@ -28,7 +28,10 @@ #include "mach_traps.h" -int unknown_nmi_panic; +extern void die_nmi(struct pt_regs *, const char *msg); + +#ifndef CONFIG_XEN + int nmi_watchdog_enabled; static cpumask_t backtrace_mask = CPU_MASK_NONE; @@ -315,8 +318,6 @@ void touch_nmi_watchdog(void) } EXPORT_SYMBOL(touch_nmi_watchdog); -extern void die_nmi(struct pt_regs *, const char *msg); - __kprobes int nmi_watchdog_tick(struct pt_regs * regs, unsigned reason) { @@ -388,8 +389,12 @@ __kprobes int nmi_watchdog_tick(struct p return rc; } +#endif /* CONFIG_XEN */ + #ifdef CONFIG_SYSCTL +int unknown_nmi_panic; + static int unknown_nmi_panic_callback(struct pt_regs *regs, int cpu) { unsigned char reason = get_nmi_reason(); @@ -400,6 +405,7 @@ static int unknown_nmi_panic_callback(st return 0; } +#ifndef CONFIG_XEN /* * proc handler for /proc/sys/kernel/nmi */ @@ -438,6 +444,7 @@ int proc_nmi_enabled(struct ctl_table *t } return 0; } +#endif #endif @@ -450,6 +457,7 @@ int do_nmi_callback(struct pt_regs *regs return 0; } +#ifndef CONFIG_XEN void __trigger_all_cpu_backtrace(void) { int i; @@ -465,3 +473,4 @@ void __trigger_all_cpu_backtrace(void) EXPORT_SYMBOL(nmi_active); EXPORT_SYMBOL(nmi_watchdog); +#endif Index: head-2008-03-06/arch/x86/kernel/nmi_64.c =================================================================== --- head-2008-03-06.orig/arch/x86/kernel/nmi_64.c 2008-03-05 16:14:58.000000000 +0100 +++ head-2008-03-06/arch/x86/kernel/nmi_64.c 2008-03-06 10:52:57.000000000 +0100 @@ -26,10 +26,12 @@ #include #include -int unknown_nmi_panic; -int nmi_watchdog_enabled; int panic_on_unrecovered_nmi; +#ifndef CONFIG_XEN + +int nmi_watchdog_enabled; + static cpumask_t backtrace_mask = CPU_MASK_NONE; /* nmi_active: @@ -380,6 +382,8 @@ int __kprobes nmi_watchdog_tick(struct p return rc; } +#endif /* CONFIG_XEN */ + static unsigned ignore_nmis; asmlinkage __kprobes void do_nmi(struct pt_regs * regs, long error_code) @@ -405,6 +409,8 @@ void restart_nmi(void) #ifdef CONFIG_SYSCTL +int unknown_nmi_panic; + static int unknown_nmi_panic_callback(struct pt_regs *regs, int cpu) { unsigned char reason = get_nmi_reason(); @@ -415,6 +421,7 @@ static int unknown_nmi_panic_callback(st return 0; } +#ifndef CONFIG_XEN /* * proc handler for /proc/sys/kernel/nmi */ @@ -449,6 +456,7 @@ int proc_nmi_enabled(struct ctl_table *t } return 0; } +#endif #endif @@ -461,6 +469,7 @@ int do_nmi_callback(struct pt_regs *regs return 0; } +#ifndef CONFIG_XEN void __trigger_all_cpu_backtrace(void) { int i; @@ -476,3 +485,4 @@ void __trigger_all_cpu_backtrace(void) EXPORT_SYMBOL(nmi_active); EXPORT_SYMBOL(nmi_watchdog); +#endif Index: head-2008-03-06/arch/x86/kernel/traps_32-xen.c =================================================================== --- head-2008-03-06.orig/arch/x86/kernel/traps_32-xen.c 2008-03-06 10:52:48.000000000 +0100 +++ head-2008-03-06/arch/x86/kernel/traps_32-xen.c 2008-03-06 10:52:57.000000000 +0100 @@ -806,12 +806,14 @@ static __kprobes void default_do_nmi(str == NOTIFY_STOP) return; #ifdef CONFIG_X86_LOCAL_APIC +#ifndef CONFIG_XEN /* * Ok, so this is none of the documented NMI sources, * so it must be the NMI watchdog. */ if (nmi_watchdog_tick(regs, reason)) return; +#endif if (!do_nmi_callback(regs, smp_processor_id())) #endif unknown_nmi_error(reason, regs); Index: head-2008-03-06/arch/x86/kernel/traps_64-xen.c =================================================================== --- head-2008-03-06.orig/arch/x86/kernel/traps_64-xen.c 2008-03-06 10:52:39.000000000 +0100 +++ head-2008-03-06/arch/x86/kernel/traps_64-xen.c 2008-03-06 10:52:57.000000000 +0100 @@ -895,7 +895,7 @@ asmlinkage __kprobes void default_do_nmi if (notify_die(DIE_NMI_IPI, "nmi_ipi", regs, reason, 2, SIGINT) == NOTIFY_STOP) return; -#ifdef CONFIG_X86_LOCAL_APIC +#if defined(CONFIG_X86_LOCAL_APIC) && !defined(CONFIG_XEN) /* * Ok, so this is none of the documented NMI sources, * so it must be the NMI watchdog. Index: head-2008-03-06/include/asm-x86/irq_32.h =================================================================== --- head-2008-03-06.orig/include/asm-x86/irq_32.h 2008-01-24 23:58:37.000000000 +0100 +++ head-2008-03-06/include/asm-x86/irq_32.h 2008-03-06 10:52:57.000000000 +0100 @@ -20,7 +20,7 @@ static __inline__ int irq_canonicalize(i return ((irq == 2) ? 9 : irq); } -#ifdef CONFIG_X86_LOCAL_APIC +#if defined(CONFIG_X86_LOCAL_APIC) && !defined(CONFIG_XEN) # define ARCH_HAS_NMI_WATCHDOG /* See include/linux/nmi.h */ #endif Index: head-2008-03-06/include/asm-x86/nmi_32.h =================================================================== --- head-2008-03-06.orig/include/asm-x86/nmi_32.h 2008-03-05 16:14:58.000000000 +0100 +++ head-2008-03-06/include/asm-x86/nmi_32.h 2008-03-06 10:52:57.000000000 +0100 @@ -4,8 +4,6 @@ #include #include -#ifdef ARCH_HAS_NMI_WATCHDOG - /** * do_nmi_callback * @@ -14,6 +12,8 @@ */ int do_nmi_callback(struct pt_regs *regs, int cpu); +#ifdef ARCH_HAS_NMI_WATCHDOG + extern int nmi_watchdog_enabled; extern int avail_to_resrv_perfctr_nmi_bit(unsigned int); extern int avail_to_resrv_perfctr_nmi(unsigned int); @@ -41,13 +41,10 @@ struct ctl_table; struct file; extern int proc_nmi_enabled(struct ctl_table *, int , struct file *, void __user *, size_t *, loff_t *); -extern int unknown_nmi_panic; void __trigger_all_cpu_backtrace(void); #define trigger_all_cpu_backtrace() __trigger_all_cpu_backtrace() -#endif - void lapic_watchdog_stop(void); int lapic_watchdog_init(unsigned nmi_hz); int lapic_wd_event(unsigned nmi_hz); @@ -55,7 +52,12 @@ unsigned lapic_adjust_nmi_hz(unsigned hz int lapic_watchdog_ok(void); void disable_lapic_nmi_watchdog(void); void enable_lapic_nmi_watchdog(void); + +#endif + void stop_nmi(void); void restart_nmi(void); +extern int unknown_nmi_panic; + #endif /* ASM_NMI_H */ Index: head-2008-03-06/include/asm-x86/nmi_64.h =================================================================== --- head-2008-03-06.orig/include/asm-x86/nmi_64.h 2008-03-05 16:14:58.000000000 +0100 +++ head-2008-03-06/include/asm-x86/nmi_64.h 2008-03-06 10:52:57.000000000 +0100 @@ -39,6 +39,9 @@ extern void die_nmi(char *str, struct pt #define get_nmi_reason() inb(0x61) extern int unknown_nmi_panic; + +#ifndef CONFIG_XEN + extern int nmi_watchdog_enabled; extern int check_nmi_watchdog(void); @@ -84,6 +87,9 @@ unsigned lapic_adjust_nmi_hz(unsigned hz int lapic_watchdog_ok(void); void disable_lapic_nmi_watchdog(void); void enable_lapic_nmi_watchdog(void); + +#endif + void stop_nmi(void); void restart_nmi(void); Index: head-2008-03-06/include/asm-x86/mach-xen/asm/irq_64.h =================================================================== --- head-2008-03-06.orig/include/asm-x86/mach-xen/asm/irq_64.h 2007-06-12 13:14:13.000000000 +0200 +++ head-2008-03-06/include/asm-x86/mach-xen/asm/irq_64.h 2008-03-06 10:52:57.000000000 +0100 @@ -20,7 +20,7 @@ static __inline__ int irq_canonicalize(i return ((irq == 2) ? 9 : irq); } -#ifdef CONFIG_X86_LOCAL_APIC +#ifndef CONFIG_XEN #define ARCH_HAS_NMI_WATCHDOG /* See include/linux/nmi.h */ #endif Index: head-2008-03-06/include/asm-x86/mach-xen/setup_arch_post.h =================================================================== --- head-2008-03-06.orig/include/asm-x86/mach-xen/setup_arch_post.h 2007-06-12 13:14:13.000000000 +0200 +++ head-2008-03-06/include/asm-x86/mach-xen/setup_arch_post.h 2008-03-06 10:52:57.000000000 +0100 @@ -27,12 +27,10 @@ static void __init machine_specific_arch .type = CALLBACKTYPE_syscall, .address = (unsigned long)system_call, }; -#ifdef CONFIG_X86_LOCAL_APIC static struct callback_register __initdata nmi_cb = { .type = CALLBACKTYPE_nmi, .address = (unsigned long)nmi, }; -#endif ret = HYPERVISOR_callback_op(CALLBACKOP_register, &event); if (ret == 0) @@ -48,7 +46,6 @@ static void __init machine_specific_arch #endif BUG_ON(ret); -#ifdef CONFIG_X86_LOCAL_APIC ret = HYPERVISOR_callback_op(CALLBACKOP_register, &nmi_cb); #if CONFIG_XEN_COMPAT <= 0x030002 if (ret == -ENOSYS) { @@ -59,5 +56,4 @@ static void __init machine_specific_arch HYPERVISOR_nmi_op(XENNMI_register_callback, &cb); } #endif -#endif } Index: head-2008-03-06/kernel/sysctl.c =================================================================== --- head-2008-03-06.orig/kernel/sysctl.c 2008-03-06 09:51:06.000000000 +0100 +++ head-2008-03-06/kernel/sysctl.c 2008-03-06 10:52:57.000000000 +0100 @@ -672,6 +672,7 @@ static struct ctl_table kern_table[] = { .mode = 0644, .proc_handler = &proc_dointvec, }, +#ifndef CONFIG_XEN { .procname = "nmi_watchdog", .data = &nmi_watchdog_enabled, @@ -680,6 +681,7 @@ static struct ctl_table kern_table[] = { .proc_handler = &proc_nmi_enabled, }, #endif +#endif #if defined(CONFIG_X86) { .ctl_name = KERN_PANIC_ON_NMI,