提交 737a460f 编写于 作者: J Jason Wessel 提交者: Ingo Molnar

kgdb: fix several kgdb regressions

kgdb core fixes:
- Check to see that mm->mmap_cache is not null before calling
  flush_cache_range(), else on arch=ARM it will cause a fatal
  fault.

- Breakpoints should only be restored if they are in the BP_ACTIVE
  state.

- Fix a typo in comments to "kgdb_register_io_module"

x86 kgdb fixes:
- Fix the x86 arch handler such that on a kill or detach that the
  appropriate cleanup on the single stepping flags gets run.

- Add in the DIE_NMIWATCHDOG call for x86_64

- Touch the nmi watchdog before returning the system to normal
  operation after performing any kind of kgdb operation, else
  the possibility exists to trigger the watchdog.
Signed-off-by: NJason Wessel <jason.wessel@windriver.com>
Signed-off-by: NIngo Molnar <mingo@elte.hu>
上级 84b5ae15
...@@ -370,6 +370,8 @@ int kgdb_arch_handle_exception(int e_vector, int signo, int err_code, ...@@ -370,6 +370,8 @@ int kgdb_arch_handle_exception(int e_vector, int signo, int err_code,
ptr = &remcomInBuffer[1]; ptr = &remcomInBuffer[1];
if (kgdb_hex2long(&ptr, &addr)) if (kgdb_hex2long(&ptr, &addr))
linux_regs->ip = addr; linux_regs->ip = addr;
case 'D':
case 'k':
newPC = linux_regs->ip; newPC = linux_regs->ip;
/* clear the trace bit */ /* clear the trace bit */
...@@ -480,6 +482,8 @@ static int __kgdb_notify(struct die_args *args, unsigned long cmd) ...@@ -480,6 +482,8 @@ static int __kgdb_notify(struct die_args *args, unsigned long cmd)
if (kgdb_handle_exception(args->trapnr, args->signr, args->err, regs)) if (kgdb_handle_exception(args->trapnr, args->signr, args->err, regs))
return NOTIFY_DONE; return NOTIFY_DONE;
/* Must touch watchdog before return to normal operation */
touch_nmi_watchdog();
return NOTIFY_STOP; return NOTIFY_STOP;
} }
......
...@@ -600,8 +600,13 @@ void die(const char * str, struct pt_regs * regs, long err) ...@@ -600,8 +600,13 @@ void die(const char * str, struct pt_regs * regs, long err)
void __kprobes die_nmi(char *str, struct pt_regs *regs, int do_panic) void __kprobes die_nmi(char *str, struct pt_regs *regs, int do_panic)
{ {
unsigned long flags = oops_begin(); unsigned long flags;
if (notify_die(DIE_NMIWATCHDOG, str, regs, 0, 2, SIGINT) ==
NOTIFY_STOP)
return;
flags = oops_begin();
/* /*
* We are in trouble anyway, lets at least try * We are in trouble anyway, lets at least try
* to get a message out. * to get a message out.
......
...@@ -600,7 +600,7 @@ static void kgdb_flush_swbreak_addr(unsigned long addr) ...@@ -600,7 +600,7 @@ static void kgdb_flush_swbreak_addr(unsigned long addr)
if (!CACHE_FLUSH_IS_SAFE) if (!CACHE_FLUSH_IS_SAFE)
return; return;
if (current->mm) { if (current->mm && current->mm->mmap_cache) {
flush_cache_range(current->mm->mmap_cache, flush_cache_range(current->mm->mmap_cache,
addr, addr + BREAK_INSTR_SIZE); addr, addr + BREAK_INSTR_SIZE);
} else { } else {
...@@ -729,14 +729,16 @@ int remove_all_break(void) ...@@ -729,14 +729,16 @@ int remove_all_break(void)
/* Clear memory breakpoints. */ /* Clear memory breakpoints. */
for (i = 0; i < KGDB_MAX_BREAKPOINTS; i++) { for (i = 0; i < KGDB_MAX_BREAKPOINTS; i++) {
if (kgdb_break[i].state != BP_SET) if (kgdb_break[i].state != BP_ACTIVE)
continue; goto setundefined;
addr = kgdb_break[i].bpt_addr; addr = kgdb_break[i].bpt_addr;
error = kgdb_arch_remove_breakpoint(addr, error = kgdb_arch_remove_breakpoint(addr,
kgdb_break[i].saved_instr); kgdb_break[i].saved_instr);
if (error) if (error)
return error; printk(KERN_ERR "KGDB: breakpoint remove failed: %lx\n",
kgdb_break[i].state = BP_REMOVED; addr);
setundefined:
kgdb_break[i].state = BP_UNDEFINED;
} }
/* Clear hardware breakpoints. */ /* Clear hardware breakpoints. */
...@@ -1605,7 +1607,7 @@ static void kgdb_initial_breakpoint(void) ...@@ -1605,7 +1607,7 @@ static void kgdb_initial_breakpoint(void)
} }
/** /**
* kkgdb_register_io_module - register KGDB IO module * kgdb_register_io_module - register KGDB IO module
* @new_kgdb_io_ops: the io ops vector * @new_kgdb_io_ops: the io ops vector
* *
* Register it with the KGDB core. * Register it with the KGDB core.
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册