From: Andrew Morton Signed-off-by: Andrew Morton --- dev/null | 0 i386/lib/kgdb_serial.c | 0 arch/i386/kernel/kgdb_stub.c | 10 +++++----- arch/i386/kernel/nmi.c | 27 +++------------------------ arch/i386/kernel/traps.c | 21 +++++++++++---------- arch/i386/mm/fault.c | 12 ++++++------ include/asm-i386/kgdb.h | 14 +++++++++----- 7 files changed, 34 insertions(+), 50 deletions(-) diff -puN arch/i386/kernel/kgdb_stub.c~kgdb-nmi-cleanup arch/i386/kernel/kgdb_stub.c --- devel/arch/i386/kernel/kgdb_stub.c~kgdb-nmi-cleanup 2006-03-06 19:19:07.000000000 -0800 +++ devel-akpm/arch/i386/kernel/kgdb_stub.c 2006-03-06 19:19:07.000000000 -0800 @@ -1073,7 +1073,7 @@ printexceptioninfo(int exceptionNo, int * it is always necessary to do a restore_flags before returning * so as to let go of that lock. */ -int kgdb_handle_exception(int exceptionVector, int signo, int err_code, +void kgdb_handle_exception(int exceptionVector, int signo, int err_code, struct pt_regs *regs) { struct task_struct *usethread = NULL; @@ -1101,7 +1101,7 @@ int kgdb_handle_exception(int exceptionV if ((regs->eflags & VM_MASK) || (3 & regs->xcs)) { printk("ignoring non-kernel exception\n"); print_regs(regs); - return (0); + return; } local_irq_save(flags); @@ -1804,12 +1804,12 @@ exit_kgdb: */ spin_unlock_wait(waitlocks + smp_processor_id()); local_irq_restore(flags); - return (0); + return; } /* Release kgdb spinlock */ KGDB_SPIN_UNLOCK(&kgdb_spinlock); local_irq_restore(flags); - return (0); + return; } static void kgdb_console_write(struct console *co, const char *s, @@ -1865,6 +1865,6 @@ int __init kgdb_console_init(char *str) } __setup("console=", kgdb_console_init); -typedef int gdb_debug_hook(int exceptionVector, +typedef void gdb_debug_hook(int exceptionVector, int signo, int err_code, struct pt_regs *linux_regs); gdb_debug_hook *linux_debug_hook = &kgdb_handle_exception; diff -puN arch/i386/kernel/nmi.c~kgdb-nmi-cleanup arch/i386/kernel/nmi.c --- devel/arch/i386/kernel/nmi.c~kgdb-nmi-cleanup 2006-03-06 19:19:07.000000000 -0800 +++ devel-akpm/arch/i386/kernel/nmi.c 2006-03-06 19:20:32.000000000 -0800 @@ -29,19 +29,11 @@ #include #include #include +#include #include "mach_traps.h" -#ifdef CONFIG_KGDB -#include -#ifdef CONFIG_SMP -unsigned int nmi_watchdog = NMI_IO_APIC; -#else -unsigned int nmi_watchdog = NMI_LOCAL_APIC; -#endif -#else unsigned int nmi_watchdog = NMI_NONE; -#endif extern int unknown_nmi_panic; static unsigned int nmi_hz = HZ; @@ -528,9 +520,6 @@ void touch_nmi_watchdog (void) */ touch_softlockup_watchdog(); } -#ifdef CONFIG_KGDB -int tune_watchdog = 5*HZ; -#endif extern void die_nmi(struct pt_regs *, const char *msg); @@ -546,29 +535,19 @@ void nmi_watchdog_tick (struct pt_regs * sum = per_cpu(irq_stat, cpu).apic_timer_irqs; -#ifdef CONFIG_KGDB if (!in_kgdb(regs) && last_irq_sums[cpu] == sum) { - -#else - if (last_irq_sums[cpu] == sum) { -#endif /* * Ayiee, looks like this CPU is stuck ... * wait a few IRQs (5 seconds) before doing the oops ... */ alert_counter[cpu]++; -#ifdef CONFIG_KGDB - if (alert_counter[cpu] == tune_watchdog) { + if (alert_counter[cpu] == 5*nmi_hz) { kgdb_handle_exception(2, SIGPWR, 0, regs); - last_irq_sums[cpu] = sum; - alert_counter[cpu] = 0; - } -#endif - if (alert_counter[cpu] == 5*nmi_hz) /* * die_nmi will return ONLY if NOTIFY_STOP happens.. */ die_nmi(regs, "BUG: NMI Watchdog detected LOCKUP"); + } } else { last_irq_sums[cpu] = sum; alert_counter[cpu] = 0; diff -puN arch/i386/kernel/traps.c~kgdb-nmi-cleanup arch/i386/kernel/traps.c --- devel/arch/i386/kernel/traps.c~kgdb-nmi-cleanup 2006-03-06 19:19:07.000000000 -0800 +++ devel-akpm/arch/i386/kernel/traps.c 2006-03-06 19:19:07.000000000 -0800 @@ -128,16 +128,17 @@ void breakpoint(void) BREAKPOINT; } -#define CHK_REMOTE_DEBUG(trapnr,signr,error_code,regs,after) \ + +#define check_remote_debug(trapnr,signr,error_code,regs,after) \ { \ - if (!user_mode(regs) ) \ - { \ + if (!user_mode(regs)) { \ kgdb_handle_exception(trapnr, signr, error_code, regs); \ after; \ - } else if ((trapnr == 3) && (regs->eflags &0x200)) local_irq_enable(); \ + } else if ((trapnr == 3) && (regs->eflags &0x200)) \ + local_irq_enable(); \ } #else -#define CHK_REMOTE_DEBUG(trapnr,signr,error_code,regs,after) +#define check_remote_debug(trapnr,signr,error_code,regs,after) #endif static inline int valid_stack_ptr(struct thread_info *tinfo, void *p) @@ -427,7 +428,7 @@ void die(const char * str, struct pt_reg if (user_mode(regs)) BREAKPOINT; #endif - CHK_REMOTE_DEBUG(0,SIGTRAP,err,regs,) + check_remote_debug(0,SIGTRAP,err,regs,) if (notify_die(DIE_OOPS, str, regs, err, current->thread.trap_no, SIGSEGV) != NOTIFY_STOP) @@ -506,7 +507,7 @@ static void __kprobes do_trap(int trapnr #define DO_ERROR(trapnr, signr, str, name) \ fastcall void do_##name(struct pt_regs * regs, long error_code) \ { \ - CHK_REMOTE_DEBUG(trapnr,signr,error_code,regs,) \ + check_remote_debug(trapnr,signr,error_code,regs,) \ if (notify_die(DIE_TRAP, str, regs, error_code, trapnr, signr) \ == NOTIFY_STOP) \ return; \ @@ -530,7 +531,7 @@ fastcall void do_##name(struct pt_regs * #define DO_VM86_ERROR(trapnr, signr, str, name) \ fastcall void do_##name(struct pt_regs * regs, long error_code) \ { \ - CHK_REMOTE_DEBUG(trapnr, signr, error_code,regs, return) \ + check_remote_debug(trapnr, signr, error_code,regs, return) \ if (notify_die(DIE_TRAP, str, regs, error_code, trapnr, signr) \ == NOTIFY_STOP) \ return; \ @@ -620,7 +621,7 @@ gp_in_vm86: gp_in_kernel: if (!fixup_exception(regs)) { - CHK_REMOTE_DEBUG(13,SIGSEGV,error_code,regs,) + check_remote_debug(13,SIGSEGV,error_code,regs,) if (notify_die(DIE_GPF, "general protection fault", regs, error_code, 13, SIGSEGV) == NOTIFY_STOP) return; @@ -885,7 +886,7 @@ fastcall void __kprobes do_debug(struct */ clear_dr7: set_debugreg(0, 7); - CHK_REMOTE_DEBUG(1,SIGTRAP,error_code,regs,) + check_remote_debug(1,SIGTRAP,error_code,regs,) return; debug_vm86: diff -puN arch/i386/mm/fault.c~kgdb-nmi-cleanup arch/i386/mm/fault.c --- devel/arch/i386/mm/fault.c~kgdb-nmi-cleanup 2006-03-06 19:19:07.000000000 -0800 +++ devel-akpm/arch/i386/mm/fault.c 2006-03-06 19:19:07.000000000 -0800 @@ -502,13 +502,13 @@ no_context: if (is_prefetch(regs, address, error_code)) return; -/* - * Oops. The kernel tried to access some bad page. We'll have to - * terminate things with extreme prejudice. - */ + /* + * Oops. The kernel tried to access some bad page. We'll have to + * terminate things with extreme prejudice. + */ #ifdef CONFIG_KGDB - if (!user_mode(regs)){ - kgdb_handle_exception(14,SIGBUS, error_code, regs); + if (!user_mode(regs)) { + kgdb_handle_exception(14, SIGBUS, error_code, regs); return; } #endif diff -puN include/asm-i386/kgdb.h~kgdb-nmi-cleanup include/asm-i386/kgdb.h --- devel/include/asm-i386/kgdb.h~kgdb-nmi-cleanup 2006-03-06 19:19:07.000000000 -0800 +++ devel-akpm/include/asm-i386/kgdb.h 2006-03-06 19:19:07.000000000 -0800 @@ -1,6 +1,8 @@ #ifndef __KGDB #define __KGDB +struct pt_regs; + /* * This file should not include ANY others. This makes it usable * most anywhere without the fear of include order or inclusion. @@ -29,10 +31,9 @@ extern void breakpoint(void); * It has the register image and thus may choose to resume execution * anywhere it pleases. */ -struct pt_regs; -extern int kgdb_handle_exception(int trapno, - int signo, int err_code, struct pt_regs *regs); +extern void kgdb_handle_exception(int trapno, int signo, int err_code, + struct pt_regs *regs); extern int in_kgdb(struct pt_regs *regs); #else /* CONFIG_KGDB && ! __ASSEMBLY__ ,stubs follow... */ @@ -40,8 +41,11 @@ extern int in_kgdb(struct pt_regs *regs) #define BREAKPOINT #endif #define kgdb_ts(data0,data1) -#define in_kgdb -#define kgdb_handle_exception +static inline int in_kgdb(struct pt_regs *regs) { return 0; } +static inline void kgdb_handle_exception(int trapno, int signo, + int err_code, struct pt_regs *regs) +{ +} #define breakpoint #define INIT_KGDB_INTS #endif diff -puN arch/i386/lib/kgdb_serial.c~kgdb-nmi-cleanup arch/i386/lib/kgdb_serial.c diff -L include/linux/kgdb.h -puN /dev/null /dev/null _