All of lore.kernel.org
 help / color / mirror / Atom feed
* [RESEND][PATCH] x86: don't destroy %rbp on kernel-mode faults
@ 2008-06-27 15:22 Vegard Nossum
  2008-06-27 15:46 ` Ingo Molnar
  2008-06-27 16:12 ` Andi Kleen
  0 siblings, 2 replies; 3+ messages in thread
From: Vegard Nossum @ 2008-06-27 15:22 UTC (permalink / raw)
  To: Ingo Molnar, Thomas Gleixner
  Cc: Arjan van de Ven, Andi Kleen, Pekka Enberg, x86, linux-kernel

Hi,

I sent this patch earlier, but it was never queued. It has been acked by
Arjan and acked informally by Andi. I hope this can make it for 2.6.27.

(It's been tested on two x86_64s.)


Vegard


From: Vegard Nossum <vegard.nossum@gmail.com>
Date: Thu, 26 Jun 2008 13:26:50 +0200
Subject: [PATCH] x86: don't destroy %rbp on kernel-mode faults

>From the code:

    "B stepping K8s sometimes report an truncated RIP for IRET exceptions
    returning to compat mode. Check for these here too."

The code then proceeds to truncate the upper 32 bits of %rbp. This means
that when do_page_fault() is finally called, its prologue,

    do_page_fault:
        push %rbp
        movl %rsp, %rbp

will put the truncated base pointer on the stack. This means that the
stack tracer will not be able to follow the base-pointer changes and
will see all subsequent stack frames as unreliable.

This patch changes the code to use a different register (%rcx) for the
checking and leaves %rbp untouched.

Cc: Andi Kleen <andi@firstfloor.org>
Cc: Ingo Molnar <mingo@elte.hu>
Acked-by: Arjan van de Ven <arjan@linux.intel.com>
Signed-off-by: Pekka Enberg <penberg@cs.helsinki.fi>
Signed-off-by: Vegard Nossum <vegard.nossum@gmail.com>
---
 arch/x86/kernel/entry_64.S |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/arch/x86/kernel/entry_64.S b/arch/x86/kernel/entry_64.S
index 556a8df..fa1c9eb 100644
--- a/arch/x86/kernel/entry_64.S
+++ b/arch/x86/kernel/entry_64.S
@@ -926,11 +926,11 @@ error_kernelspace:
 	   iret run with kernel gs again, so don't set the user space flag.
 	   B stepping K8s sometimes report an truncated RIP for IRET 
 	   exceptions returning to compat mode. Check for these here too. */
-	leaq irq_return(%rip),%rbp
-	cmpq %rbp,RIP(%rsp) 
+	leaq irq_return(%rip),%rcx
+	cmpq %rcx,RIP(%rsp)
 	je   error_swapgs
-	movl %ebp,%ebp	/* zero extend */
-	cmpq %rbp,RIP(%rsp) 
+	movl %ecx,%ecx	/* zero extend */
+	cmpq %rcx,RIP(%rsp)
 	je   error_swapgs
 	cmpq $gs_change,RIP(%rsp)
         je   error_swapgs
-- 
1.5.4.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [RESEND][PATCH] x86: don't destroy %rbp on kernel-mode faults
  2008-06-27 15:22 [RESEND][PATCH] x86: don't destroy %rbp on kernel-mode faults Vegard Nossum
@ 2008-06-27 15:46 ` Ingo Molnar
  2008-06-27 16:12 ` Andi Kleen
  1 sibling, 0 replies; 3+ messages in thread
From: Ingo Molnar @ 2008-06-27 15:46 UTC (permalink / raw)
  To: Vegard Nossum
  Cc: Thomas Gleixner, Arjan van de Ven, Andi Kleen, Pekka Enberg, x86,
	linux-kernel


* Vegard Nossum <vegard.nossum@gmail.com> wrote:

> >From the code:
> 
>     "B stepping K8s sometimes report an truncated RIP for IRET exceptions
>     returning to compat mode. Check for these here too."
> 
> The code then proceeds to truncate the upper 32 bits of %rbp. This means
> that when do_page_fault() is finally called, its prologue,
> 
>     do_page_fault:
>         push %rbp
>         movl %rsp, %rbp
> 
> will put the truncated base pointer on the stack. This means that the
> stack tracer will not be able to follow the base-pointer changes and
> will see all subsequent stack frames as unreliable.
> 
> This patch changes the code to use a different register (%rcx) for the
> checking and leaves %rbp untouched.

applied to tip/x86/debug - thanks Vegard!

	Ingo

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [RESEND][PATCH] x86: don't destroy %rbp on kernel-mode faults
  2008-06-27 15:22 [RESEND][PATCH] x86: don't destroy %rbp on kernel-mode faults Vegard Nossum
  2008-06-27 15:46 ` Ingo Molnar
@ 2008-06-27 16:12 ` Andi Kleen
  1 sibling, 0 replies; 3+ messages in thread
From: Andi Kleen @ 2008-06-27 16:12 UTC (permalink / raw)
  To: Vegard Nossum
  Cc: Ingo Molnar, Thomas Gleixner, Arjan van de Ven, Pekka Enberg, x86,
	linux-kernel

Vegard Nossum <vegard.nossum@gmail.com> writes:

> Hi,
>
> I sent this patch earlier, but it was never queued. It has been acked by
> Arjan and acked informally by Andi. I hope this can make it for 2.6.27.

Just to clarify the "informal ack" was (paraphrased): 

All the .S code was always designed to support dwarf2 unwinding and
not frame pointers and there are a lot more places that don't care
about frame pointers. So even if you fix it here it'll still break in
other places.

-Andi


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2008-06-27 16:13 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-06-27 15:22 [RESEND][PATCH] x86: don't destroy %rbp on kernel-mode faults Vegard Nossum
2008-06-27 15:46 ` Ingo Molnar
2008-06-27 16:12 ` Andi Kleen

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.