[PATCH] lockdep: annotate kprobes irq fiddling

!MAILaRCHIVE_VOTE_RePLACE
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: Andrew Morton <akpm@...>, Linus Torvalds <torvalds@...>, linux-kernel <linux-kernel@...>
Cc: Prasanna S Panchamukhi <prasanna@...>, Ananth N Mavinakayanahalli <ananth@...>, Anil S Keshavamurthy <anil.s.keshavamurthy@...>, David S. Miller <davem@...>, Ingo Molnar <mingo@...>
Date: Wednesday, October 3, 2007 - 6:42 am

Hi,

The below patch fixes a lockdep error in 2.6.23-rc9 when using tcp_probe.

---

Subject: lockdep: annotate kprobes irq fiddling

kprobes disables irqs for jprobes, but does not tell lockdep about it.

CC: Prasanna S Panchamukhi <prasanna@in.ibm.com>
CC: Ananth N Mavinakayanahalli <ananth@in.ibm.com>
CC: Anil S Keshavamurthy <anil.s.keshavamurthy@intel.com>
CC: David S. Miller <davem@davemloft.net>
Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
---
 arch/i386/kernel/kprobes.c   |    8 ++++++++
 arch/x86_64/kernel/kprobes.c |    8 ++++++++
 2 files changed, 16 insertions(+)

Index: linux-2.6-2/arch/i386/kernel/kprobes.c
===================================================================
--- linux-2.6-2.orig/arch/i386/kernel/kprobes.c
+++ linux-2.6-2/arch/i386/kernel/kprobes.c
@@ -558,6 +558,13 @@ static int __kprobes post_kprobe_handler
 
 	resume_execution(cur, regs, kcb);
 	regs->eflags |= kcb->kprobe_saved_eflags;
+#ifdef CONFIG_TRACE_IRQFLAGS_SUPPORT
+	if (raw_irqs_disabled_flags(regs->eflags)) {
+		trace_hardirqs_off();
+	} else {
+		trace_hardirqs_on();
+	}
+#endif
 
 	/*Restore back the original saved kprobes variables and continue. */
 	if (kcb->kprobe_status == KPROBE_REENTER) {
@@ -695,6 +702,7 @@ int __kprobes setjmp_pre_handler(struct 
 	memcpy(kcb->jprobes_stack, (kprobe_opcode_t *)addr,
 			MIN_STACK_SIZE(addr));
 	regs->eflags &= ~IF_MASK;
+	trace_hardirqs_off();
 	regs->eip = (unsigned long)(jp->entry);
 	return 1;
 }
Index: linux-2.6-2/arch/x86_64/kernel/kprobes.c
===================================================================
--- linux-2.6-2.orig/arch/x86_64/kernel/kprobes.c
+++ linux-2.6-2/arch/x86_64/kernel/kprobes.c
@@ -545,6 +545,13 @@ int __kprobes post_kprobe_handler(struct
 
 	resume_execution(cur, regs, kcb);
 	regs->eflags |= kcb->kprobe_saved_rflags;
+#ifdef CONFIG_TRACE_IRQFLAGS_SUPPORT
+	if (raw_irqs_disabled_flags(regs->eflags)) {
+		trace_hardirqs_off();
+	} else {
+		trace_hardirqs_on();
+	}
+#endif
 
 	/* Restore the original saved kprobes variables and continue. */
 	if (kcb->kprobe_status == KPROBE_REENTER) {
@@ -685,6 +692,7 @@ int __kprobes setjmp_pre_handler(struct 
 	memcpy(kcb->jprobes_stack, (kprobe_opcode_t *)addr,
 			MIN_STACK_SIZE(addr));
 	regs->eflags &= ~IF_MASK;
+	trace_hardirqs_off();
 	regs->rip = (unsigned long)(jp->entry);
 	return 1;
 }


-
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH] lockdep: annotate kprobes irq fiddling, Peter Zijlstra, (Wed Oct 3, 6:42 am)
Re: [PATCH] lockdep: annotate kprobes irq fiddling, Ingo Molnar, (Wed Oct 3, 6:52 am)