Index: linux-2.6.16.16/drivers/serial/8250_kgdb.c =================================================================== --- linux-2.6.16.16.orig/drivers/serial/8250_kgdb.c +++ linux-2.6.16.16/drivers/serial/8250_kgdb.c @@ -301,6 +301,10 @@ static void __init kgdb8250_late_init(vo "GDB-stub", current_port) < 0) printk(KERN_ERR "KGDB failed to request the serial IRQ (%d)\n", current_port->irq); +#ifdef CONFIG_IPIPE + ipipe_control_irq(current_port->irq, 0, + IPIPE_HANDLE_MASK|IPIPE_STICKY_MASK|IPIPE_SYSTEM_MASK); +#endif /* CONFIG_IPIPE */ } static __init int kgdb_init_io(void) Index: linux-2.6.16.16/include/linux/kgdb.h =================================================================== --- linux-2.6.16.16.orig/include/linux/kgdb.h +++ linux-2.6.16.16/include/linux/kgdb.h @@ -270,6 +270,9 @@ extern int kgdb_handle_exception(int ex_ extern void kgdb_nmihook(int cpu, void *regs); extern int debugger_step; extern atomic_t debugger_active; + +struct task_struct *ipipe_default_current(void); +extern struct task_struct *(*ipipe_safe_current)(void); #else /* Stubs for when KGDB is not set. */ static const atomic_t debugger_active = ATOMIC_INIT(0); Index: linux-2.6.16.16/kernel/kgdb.c =================================================================== --- linux-2.6.16.16.orig/kernel/kgdb.c +++ linux-2.6.16.16/kernel/kgdb.c @@ -740,12 +740,12 @@ static void kgdb_wait(struct pt_regs *re unsigned long flags; int processor; - local_irq_save(flags); - processor = smp_processor_id(); + local_irq_save_hw(flags); + processor = ipipe_processor_id(); kgdb_info[processor].debuggerinfo = regs; - kgdb_info[processor].task = current; + kgdb_info[processor].task = ipipe_safe_current(); atomic_set(&procindebug[processor], 1); - atomic_set(&kgdb_sync_softlockup[smp_processor_id()], 1); + atomic_set(&kgdb_sync_softlockup[processor], 1); /* Wait till master processor goes completely into the debugger. * FIXME: this looks racy */ @@ -770,7 +770,7 @@ static void kgdb_wait(struct pt_regs *re /* Signal the master processor that we are done */ atomic_set(&procindebug[processor], 0); spin_unlock(&slavecpulocks[processor]); - local_irq_restore(flags); + local_irq_restore_hw(flags); } #endif @@ -821,7 +821,8 @@ int kgdb_activate_sw_breakpoints(void) return error; if (CACHE_FLUSH_IS_SAFE) { - if (current->mm && addr < TASK_SIZE) + if (ipipe_safe_current() == current && + current->mm && addr < TASK_SIZE) flush_cache_range(current->mm->mmap_cache, addr, addr + BREAK_INSTR_SIZE); else @@ -884,8 +885,8 @@ int kgdb_deactivate_sw_breakpoints(void) kgdb_break[i].saved_instr))) return error; - if (CACHE_FLUSH_IS_SAFE && current->mm && - addr < TASK_SIZE) + if (CACHE_FLUSH_IS_SAFE && ipipe_safe_current() == current && + current->mm && addr < TASK_SIZE) flush_cache_range(current->mm->mmap_cache, addr, addr + BREAK_INSTR_SIZE); else if (CACHE_FLUSH_IS_SAFE) @@ -950,7 +951,7 @@ static inline int shadow_pid(int realpid if (realpid) { return realpid; } - return pid_max + smp_processor_id(); + return pid_max + ipipe_processor_id(); } static char gdbmsgbuf[BUFMAX + 1]; @@ -1014,11 +1015,11 @@ int kgdb_handle_exception(int ex_vector, long kgdb_usethreadid = 0; int error = 0, all_cpus_synced = 0; struct pt_regs *shadowregs; - int processor = smp_processor_id(); + int processor = ipipe_processor_id(); void *local_debuggerinfo; /* Panic on recursive debugger calls. */ - if (atomic_read(&debugger_active) == smp_processor_id() + 1) + if (atomic_read(&debugger_active) == ipipe_processor_id() + 1) return 0; acquirelock: @@ -1033,10 +1034,10 @@ int kgdb_handle_exception(int ex_vector, * Interrupts will be restored by the 'trap return' code, except when * single stepping. */ - local_irq_save(flags); + local_irq_save_hw(flags); /* Hold debugger_active */ - procid = smp_processor_id(); + procid = ipipe_processor_id(); while (cmpxchg(&atomic_read(&debugger_active), 0, (procid + 1)) != 0) { int i = 25; /* an arbitrary number */ @@ -1049,7 +1050,7 @@ int kgdb_handle_exception(int ex_vector, udelay(1); } - atomic_set(&kgdb_sync_softlockup[smp_processor_id()], 1); + atomic_set(&kgdb_sync_softlockup[procid], 1); /* * Don't enter if the last instance of the exception handler wanted to @@ -1058,7 +1059,7 @@ int kgdb_handle_exception(int ex_vector, if (atomic_read(&cpu_doing_single_step) != -1 && atomic_read(&cpu_doing_single_step) != procid) { atomic_set(&debugger_active, 0); - local_irq_restore(flags); + local_irq_restore_hw(flags); goto acquirelock; } @@ -1069,7 +1070,7 @@ int kgdb_handle_exception(int ex_vector, goto kgdb_restore; kgdb_info[processor].debuggerinfo = linux_regs; - kgdb_info[processor].task = current; + kgdb_info[processor].task = ipipe_safe_current(); kgdb_disable_hw_debug(linux_regs); @@ -1121,7 +1122,8 @@ int kgdb_handle_exception(int ex_vector, *ptr++ = hexchars[(signo >> 4) % 16]; *ptr++ = hexchars[signo % 16]; ptr += strlen(strcpy(ptr, "thread:")); - int_to_threadref(&thref, shadow_pid(current->pid)); + int_to_threadref(&thref, + shadow_pid(ipipe_safe_current()->pid)); ptr = pack_threadid(ptr, &thref); *ptr++ = ';'; @@ -1213,7 +1215,8 @@ int kgdb_handle_exception(int ex_vector, kgdb_hex2mem(&remcom_in_buffer[1], (char *)gdb_regs, NUMREGBYTES); - if (kgdb_usethread && kgdb_usethread != current) + if (kgdb_usethread && + kgdb_usethread != ipipe_safe_current()) error_packet(remcom_out_buffer, -EINVAL); else { gdb_regs_to_regs(gdb_regs, linux_regs); @@ -1334,7 +1337,8 @@ int kgdb_handle_exception(int ex_vector, /* Current thread id */ strcpy(remcom_out_buffer, "QC"); - threadid = shadow_pid(current->pid); + threadid = + shadow_pid(ipipe_safe_current()->pid); int_to_threadref(&thref, threadid); pack_threadid(remcom_out_buffer + 2, &thref); @@ -1488,7 +1492,8 @@ int kgdb_handle_exception(int ex_vector, break; case 'c': case 's': - if (kgdb_contthread && kgdb_contthread != current) { + if (kgdb_contthread && + kgdb_contthread != ipipe_safe_current()) { /* Can't switch threads in kgdb */ error_packet(remcom_out_buffer, -EINVAL); break; @@ -1556,7 +1561,7 @@ int kgdb_handle_exception(int ex_vector, kgdb_restore: /* Free debugger_active */ atomic_set(&debugger_active, 0); - local_irq_restore(flags); + local_irq_restore_hw(flags); return error; } @@ -1925,9 +1930,9 @@ static int kgdb_notify_reboot(struct not if (!kgdb_connected || atomic_read(&debugger_active) != 0) return 0; if ((code == SYS_RESTART) || (code == SYS_HALT) || (code == SYS_POWER_OFF)){ - local_irq_save(flags); + local_irq_save_hw(flags); put_packet("X00"); - local_irq_restore(flags); + local_irq_restore_hw(flags); } return NOTIFY_DONE; } @@ -1942,9 +1947,9 @@ void kgdb_console_write(struct console * if (!kgdb_connected || atomic_read(&debugger_active) != 0) return; - local_irq_save(flags); + local_irq_save_hw(flags); kgdb_msg_write(s, count); - local_irq_restore(flags); + local_irq_restore_hw(flags); } struct console kgdbcons = { @@ -1974,3 +1979,12 @@ static int __init opt_kgdb_enter(char *s } early_param("kgdbwait", opt_kgdb_enter); + +struct task_struct *ipipe_default_current(void) +{ + return current; +} +EXPORT_SYMBOL(ipipe_default_current); + +struct task_struct *(*ipipe_safe_current)(void) = ipipe_default_current; +EXPORT_SYMBOL(ipipe_safe_current); Index: linux-2.6.16.16/lib/Kconfig.debug =================================================================== --- linux-2.6.16.16.orig/lib/Kconfig.debug +++ linux-2.6.16.16/lib/Kconfig.debug @@ -273,7 +273,7 @@ choice config KGDB_ONLY_MODULES bool "KGDB: Use only kernel modules for I/O" - depends on MODULES + depends on MODULES && !IPIPE help Use only kernel modules to configure KGDB I/O after the kernel is booted. @@ -318,7 +318,7 @@ config KGDB_SIBYTE endchoice config KGDBOE - tristate "KGDB: On ethernet" if !KGDBOE_NOMODULE + tristate "KGDB: On ethernet" if !KGDBOE_NOMODULE && !IPIPE depends on m && KGDB select NETPOLL select NETPOLL_TRAP