From: Peter Zijlstra Date: Mon, 26 Nov 2007 19:42:19 +0000 (+0100) Subject: lockdep: annotate do_debug() trap handler X-Git-Tag: v2.6.24-rc4~94^2~6 X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=000f4a9e718a665fd706500199a3f0c11fea30c1;p=linux-2.6 lockdep: annotate do_debug() trap handler Ensure the hardirq state is consistent before using locks. Use the rare trace_hardirqs_fixup() because the trap can happen in any context. resolves this rare lockdep warning: WARNING: at kernel/lockdep.c:2658 check_flags() [] check_flags+0x90/0x140 [] lock_release+0x4b/0x1d0 [] notifier_call_chain+0x2a/0x47 [] __atomic_notifier_call_chain+0x64/0x6d [] __atomic_notifier_call_chain+0x0/0x6d [] atomic_notifier_call_chain+0x17/0x1a [] notify_die+0x30/0x34 [] do_debug+0x3e/0xd4 [] debug_stack_correct+0x27/0x2c [] tcp_rcv_established+0x1/0x620 [] tcp_v4_do_rcv+0x2b/0x313 [] tcp_v4_rcv+0x467/0x85d [] _spin_lock_nested+0x27/0x32 [] tcp_v4_rcv+0x7fe/0x85d [] tcp_v4_rcv+0x3bf/0x85d [] ip_local_deliver_finish+0x11b/0x1b0 [] ip_local_deliver_finish+0x2e/0x1b0 [] ip_rcv_finish+0x27b/0x29a [] netif_receive_skb+0xfb/0x2a6 [] ip_rcv+0x0/0x1fb [] netif_receive_skb+0x26a/0x2a6 [] netif_receive_skb+0xfb/0x2a6 [] process_backlog+0x7f/0xc6 [] net_rx_action+0xb9/0x1ac [] net_rx_action+0x47/0x1ac [] trace_hardirqs_on+0x118/0x16b [] __do_softirq+0x49/0xa2 [] do_softirq+0x60/0xdd [] _spin_unlock_irq+0x20/0x2c [] restore_nocheck+0x12/0x15 [] handle_fasteoi_irq+0x0/0x9b [] do_IRQ+0x94/0xaa [] _spin_unlock_irq+0x20/0x2c [] common_interrupt+0x2e/0x34 [] native_safe_halt+0x2/0x3 [] default_idle+0x44/0x65 [] cpu_idle+0x42/0x50 [] start_kernel+0x26b/0x270 [] unknown_bootoption+0x0/0x196 ======================= irq event stamp: 559190 hardirqs last enabled at (559190): [] kprobe_exceptions_notify+0x299/0x305 hardirqs last disabled at (559189): [] do_int3+0x1d/0x95 softirqs last enabled at (559172): [] do_softirq+0x60/0xdd softirqs last disabled at (559181): [] do_softirq+0x60/0xdd Signed-off-by: Peter Zijlstra Signed-off-by: Ingo Molnar Signed-off-by: Thomas Gleixner --- diff --git a/arch/x86/kernel/traps_32.c b/arch/x86/kernel/traps_32.c index 0a4c893824..ef60102625 100644 --- a/arch/x86/kernel/traps_32.c +++ b/arch/x86/kernel/traps_32.c @@ -833,6 +833,8 @@ fastcall void __kprobes do_debug(struct pt_regs * regs, long error_code) unsigned int condition; struct task_struct *tsk = current; + trace_hardirqs_fixup(); + get_debugreg(condition, 6); if (notify_die(DIE_DEBUG, "debug", regs, condition, error_code, diff --git a/arch/x86/kernel/traps_64.c b/arch/x86/kernel/traps_64.c index 1384e34a65..d11525ad81 100644 --- a/arch/x86/kernel/traps_64.c +++ b/arch/x86/kernel/traps_64.c @@ -853,6 +853,8 @@ asmlinkage void __kprobes do_debug(struct pt_regs * regs, struct task_struct *tsk = current; siginfo_t info; + trace_hardirqs_fixup(); + get_debugreg(condition, 6); if (notify_die(DIE_DEBUG, "debug", regs, condition, error_code,