[patch, -rc5-mm1] lock validator: irqflags-trace entry.S fix

Ingo Molnar
2006-05-31T15:20:12Z

* Michal Piotrowski <michal.k.k.piotrowski@gmail.com> wrote:

> >here's the fix for the irqs-off iret irqflags-tracing problem. Does this
> >fix the bug(s) on your box?
>
> Yes. Thanks!

great! Here's the cleaned up fix for Andrew:

----------------------------
Subject: lock validator: irqflags-trace entry.S fix
From: Ingo Molnar <mingo@elte.hu>

this fixes the irqflags-tracing bug reported (and relentlessly
debugged) by Michal Piotrowski: if we took a fault while interrupts
were disabled (for example of a vmalloc area) then irqflags-tracing
mistakenly assumed that the iret would re-enable interrupts.

Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Arjan van de Ven <arjan@linux.intel.com>
---
arch/i386/kernel/entry.S | 13 +++++++++++--
1 file changed, 11 insertions(+), 2 deletions(-)

Index: linux/arch/i386/kernel/entry.S
===================================================================
--- linux.orig/arch/i386/kernel/entry.S
+++ linux/arch/i386/kernel/entry.S
@@ -84,6 +84,15 @@ VM_MASK = 0x00020000
#define resume_kernel restore_nocheck
#endif

+.macro TRACE_IRQS_IRET
+#ifdef CONFIG_TRACE_IRQFLAGS
+ testl $IF_MASK,EFLAGS(%esp) # interrupts off?
+ jz 1f
+ TRACE_IRQS_ON
+1:
+#endif
+.endm
+
#ifdef CONFIG_VM86
#define resume_userspace_sig check_userspace
#else
@@ -364,7 +373,7 @@ restore_all:
CFI_REMEMBER_STATE
je ldt_ss # returning to user-space with LDT SS
restore_nocheck:
- TRACE_IRQS_ON
+ TRACE_IRQS_IRET
restore_nocheck_notrace:
RESTORE_REGS
addl $4, %esp
@@ -404,7 +413,7 @@ ldt_ss:
* and a switch16 pointer on top of the current frame. */
call setup_x86_bogus_stack
CFI_ADJUST_CFA_OFFSET -8 # frame has moved
- TRACE_IRQS_ON
+ TRACE_IRQS_IRET
RESTORE_REGS
lss 20+4(%esp), %esp # switch to 16bit stack
1: iret