From daeeafecf029a05a304fa299706b3ecc90e16175 Mon Sep 17 00:00:00 2001 From: Andi Kleen Date: Sat, 16 Apr 2005 15:25:13 -0700 Subject: [PATCH] x86_64: Keep only a single debug notifier chain Calling a notifier three times in the debug handler does not make much sense, because a debugger can figure out the various conditions by itself. Remove the additional calls to DIE_DEBUG and DIE_DEBUGSTEP completely. This matches what i386 does now. This also makes sure interrupts are always still disabled when calling a debugger, which prevents: BUG: using smp_processor_id() in preemptible [00000001] code: tpopf/1470 caller is post_kprobe_handler+0x9/0x70 Call Trace:{smp_processor_id+191} {post_kpro be_handler+9} {kprobe_exceptions_notify+58} {notifier_call_chain+32} {do_debug+335} {debug+127} on preemptible debug kernels with kprobes when single stepping in user space. This was probably a bug even on non preempt kernels, this function was supposed to be running with interrupts off according to a comment there. Note to third part debugger maintainers: please double check your debugger can still single step. Cc: Cc: Cc: Cc: Cc: Signed-off-by: Andi Kleen Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- arch/x86_64/kernel/traps.c | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) (limited to 'arch') diff --git a/arch/x86_64/kernel/traps.c b/arch/x86_64/kernel/traps.c index 2f42fd5c075..f6ccf155e3e 100644 --- a/arch/x86_64/kernel/traps.c +++ b/arch/x86_64/kernel/traps.c @@ -659,9 +659,9 @@ asmlinkage void do_debug(struct pt_regs * regs, unsigned long error_code) asm("movq %%db6,%0" : "=r" (condition)); if (notify_die(DIE_DEBUG, "debug", regs, condition, error_code, - SIGTRAP) == NOTIFY_STOP) { + SIGTRAP) == NOTIFY_STOP) return; - } + conditional_sti(regs); /* Mask out spurious debug traps due to lazy DR7 setting */ @@ -674,9 +674,7 @@ asmlinkage void do_debug(struct pt_regs * regs, unsigned long error_code) tsk->thread.debugreg6 = condition; /* Mask out spurious TF errors due to lazy TF clearing */ - if ((condition & DR_STEP) && - (notify_die(DIE_DEBUGSTEP, "debugstep", regs, condition, - 1, SIGTRAP) != NOTIFY_STOP)) { + if (condition & DR_STEP) { /* * The TF error should be masked out only if the current * process is not traced and if the TRAP flag has been set @@ -711,16 +709,10 @@ asmlinkage void do_debug(struct pt_regs * regs, unsigned long error_code) force_sig_info(SIGTRAP, &info, tsk); clear_dr7: asm volatile("movq %0,%%db7"::"r"(0UL)); - notify_die(DIE_DEBUG, "debug", regs, condition, 1, SIGTRAP); return; clear_TF_reenable: set_tsk_thread_flag(tsk, TIF_SINGLESTEP); - -clear_TF: - /* RED-PEN could cause spurious errors */ - if (notify_die(DIE_DEBUG, "debug2", regs, condition, 1, SIGTRAP) - != NOTIFY_STOP) regs->eflags &= ~TF_MASK; } -- cgit v1.2.2