[patch, -rc6-mm1] irqflags tracing: fix x86_64 entry/exit

From: Ingo Molnar
Date: Fri Jun 09 2006 - 04:59:27 EST



* Paolo Ornati <ornati@xxxxxxxxxxxxx> wrote:

> Wow, now I can reproduce it easly :)
>
> Just run under "gdb" a program that segfaults:
>
> void main(void)
> {
> *(int*)(0) = 1;
> }
>
> and it will trigger.

thanks - please try the fix below - it has solved the problem on my
testbox.

Ingo

-------------
Subject: irqflags tracing: fix x86_64 entry/exit
From: Ingo Molnar <mingo@xxxxxxx>

the x86_64 portion of the irqflags code did not properly trace the
"paranoid userspace" type of syscall/ptrace exit variant.

A testcase Paolo Ornati has discovered triggers a lock validator
assert due to this bug.

Signed-off-by: Ingo Molnar <mingo@xxxxxxx>
---
arch/x86_64/kernel/entry.S | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)

Index: linux/arch/x86_64/kernel/entry.S
===================================================================
--- linux.orig/arch/x86_64/kernel/entry.S
+++ linux/arch/x86_64/kernel/entry.S
@@ -50,9 +50,10 @@
#define retint_kernel retint_restore_args
#endif

-.macro TRACE_IRQS_IRETQ
+
+.macro TRACE_IRQS_IRETQ offset=ARGOFFSET
#ifdef CONFIG_TRACE_IRQFLAGS
- bt $9,EFLAGS-ARGOFFSET(%rsp) /* interrupts off? */
+ bt $9,EFLAGS-\offset(%rsp) /* interrupts off? */
jnc 1f
TRACE_IRQS_ON
1:
@@ -809,9 +810,9 @@ error_exit:
andl %edi,%edx
jnz retint_careful
/*
- * The iret will restore flags:
+ * The iret might restore flags:
*/
- TRACE_IRQS_ON
+ TRACE_IRQS_IRETQ
swapgs
RESTORE_ARGS 0,8,0
jmp iret_label
@@ -999,6 +1000,7 @@ paranoid_exit:
testl $3,CS(%rsp)
jnz paranoid_userspace
paranoid_swapgs:
+ TRACE_IRQS_IRETQ 0
swapgs
paranoid_restore:
RESTORE_ALL 8
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/