linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] x86-64: Use normal ptregs stub for execve
@ 2010-01-25 15:47 Brian Gerst
  2010-01-27  8:39 ` [tip:x86/asm] " tip-bot for Brian Gerst
  0 siblings, 1 reply; 5+ messages in thread
From: Brian Gerst @ 2010-01-25 15:47 UTC (permalink / raw)
  To: hpa; +Cc: x86, linux-kernel

Execve historically passed regs by value, so it had a seperate stub.
This is no longer true, so change it to use a normal PTREGSCALL stub.

Signed-off-by: Brian Gerst <brgerst@gmail.com>
---
 arch/x86/kernel/entry_64.S |   17 +----------------
 1 files changed, 1 insertions(+), 16 deletions(-)

diff --git a/arch/x86/kernel/entry_64.S b/arch/x86/kernel/entry_64.S
index 0697ff1..0c31502 100644
--- a/arch/x86/kernel/entry_64.S
+++ b/arch/x86/kernel/entry_64.S
@@ -696,6 +696,7 @@ END(\label)
 	PTREGSCALL stub_clone, sys_clone, %r8
 	PTREGSCALL stub_fork, sys_fork, %rdi
 	PTREGSCALL stub_vfork, sys_vfork, %rdi
+	PTREGSCALL stub_execve, sys_execve, %rcx
 	PTREGSCALL stub_sigaltstack, sys_sigaltstack, %rdx
 	PTREGSCALL stub_iopl, sys_iopl, %rsi
 
@@ -712,22 +713,6 @@ ENTRY(ptregscall_common)
 	CFI_ENDPROC
 END(ptregscall_common)
 
-ENTRY(stub_execve)
-	CFI_STARTPROC
-	popq %r11
-	CFI_ADJUST_CFA_OFFSET -8
-	CFI_REGISTER rip, r11
-	SAVE_REST
-	FIXUP_TOP_OF_STACK %r11
-	movq %rsp, %rcx
-	call sys_execve
-	RESTORE_TOP_OF_STACK %r11
-	movq %rax,RAX(%rsp)
-	RESTORE_REST
-	jmp int_ret_from_sys_call
-	CFI_ENDPROC
-END(stub_execve)
-
 /*
  * sigreturn is special because it needs to restore all registers on return.
  * This cannot be done with SYSRET, so use the IRET return path instead.
-- 
1.6.6


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

* [tip:x86/asm] x86-64: Use normal ptregs stub for execve
  2010-01-25 15:47 [PATCH] x86-64: Use normal ptregs stub for execve Brian Gerst
@ 2010-01-27  8:39 ` tip-bot for Brian Gerst
  2010-01-27 13:07   ` Ingo Molnar
  0 siblings, 1 reply; 5+ messages in thread
From: tip-bot for Brian Gerst @ 2010-01-27  8:39 UTC (permalink / raw)
  To: linux-tip-commits; +Cc: linux-kernel, hpa, mingo, brgerst, tglx

Commit-ID:  f19a25c872b20ae4357f72687cf3e7b0da220ee2
Gitweb:     http://git.kernel.org/tip/f19a25c872b20ae4357f72687cf3e7b0da220ee2
Author:     Brian Gerst <brgerst@gmail.com>
AuthorDate: Mon, 25 Jan 2010 10:47:33 -0500
Committer:  H. Peter Anvin <hpa@zytor.com>
CommitDate: Tue, 26 Jan 2010 23:38:14 -0800

x86-64: Use normal ptregs stub for execve

Execve historically passed regs by value, so it had a seperate stub.
This is no longer true, so change it to use a normal PTREGSCALL stub.

Signed-off-by: Brian Gerst <brgerst@gmail.com>
LKML-Reference: <1264434453-2204-1-git-send-email-brgerst@gmail.com>
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
---
 arch/x86/kernel/entry_64.S |   17 +----------------
 1 files changed, 1 insertions(+), 16 deletions(-)

diff --git a/arch/x86/kernel/entry_64.S b/arch/x86/kernel/entry_64.S
index 0697ff1..0c31502 100644
--- a/arch/x86/kernel/entry_64.S
+++ b/arch/x86/kernel/entry_64.S
@@ -696,6 +696,7 @@ END(\label)
 	PTREGSCALL stub_clone, sys_clone, %r8
 	PTREGSCALL stub_fork, sys_fork, %rdi
 	PTREGSCALL stub_vfork, sys_vfork, %rdi
+	PTREGSCALL stub_execve, sys_execve, %rcx
 	PTREGSCALL stub_sigaltstack, sys_sigaltstack, %rdx
 	PTREGSCALL stub_iopl, sys_iopl, %rsi
 
@@ -712,22 +713,6 @@ ENTRY(ptregscall_common)
 	CFI_ENDPROC
 END(ptregscall_common)
 
-ENTRY(stub_execve)
-	CFI_STARTPROC
-	popq %r11
-	CFI_ADJUST_CFA_OFFSET -8
-	CFI_REGISTER rip, r11
-	SAVE_REST
-	FIXUP_TOP_OF_STACK %r11
-	movq %rsp, %rcx
-	call sys_execve
-	RESTORE_TOP_OF_STACK %r11
-	movq %rax,RAX(%rsp)
-	RESTORE_REST
-	jmp int_ret_from_sys_call
-	CFI_ENDPROC
-END(stub_execve)
-
 /*
  * sigreturn is special because it needs to restore all registers on return.
  * This cannot be done with SYSRET, so use the IRET return path instead.

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

* Re: [tip:x86/asm] x86-64: Use normal ptregs stub for execve
  2010-01-27  8:39 ` [tip:x86/asm] " tip-bot for Brian Gerst
@ 2010-01-27 13:07   ` Ingo Molnar
  2010-01-27 15:21     ` Brian Gerst
  0 siblings, 1 reply; 5+ messages in thread
From: Ingo Molnar @ 2010-01-27 13:07 UTC (permalink / raw)
  To: mingo, hpa, linux-kernel, brgerst, tglx; +Cc: linux-tip-commits


* tip-bot for Brian Gerst <brgerst@gmail.com> wrote:

> Commit-ID:  f19a25c872b20ae4357f72687cf3e7b0da220ee2
> Gitweb:     http://git.kernel.org/tip/f19a25c872b20ae4357f72687cf3e7b0da220ee2
> Author:     Brian Gerst <brgerst@gmail.com>
> AuthorDate: Mon, 25 Jan 2010 10:47:33 -0500
> Committer:  H. Peter Anvin <hpa@zytor.com>
> CommitDate: Tue, 26 Jan 2010 23:38:14 -0800
> 
> x86-64: Use normal ptregs stub for execve
> 
> Execve historically passed regs by value, so it had a seperate stub.
> This is no longer true, so change it to use a normal PTREGSCALL stub.
> 
> Signed-off-by: Brian Gerst <brgerst@gmail.com>
> LKML-Reference: <1264434453-2204-1-git-send-email-brgerst@gmail.com>
> Signed-off-by: H. Peter Anvin <hpa@zytor.com>
> ---
>  arch/x86/kernel/entry_64.S |   17 +----------------
>  1 files changed, 1 insertions(+), 16 deletions(-)

FYI, -tip testing found that this commit breaks the grub binary on 64-bit, 
simply running /sbin/grub causes it to segfault:

[ 3145.999766] grub[6706] general protection ip:805c481 sp:ff95629c error:0 in 
grub[8048000+8c000]

i've excluded this commit for now.

	Ingo


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

* Re: [tip:x86/asm] x86-64: Use normal ptregs stub for execve
  2010-01-27 13:07   ` Ingo Molnar
@ 2010-01-27 15:21     ` Brian Gerst
  2010-01-27 16:28       ` H. Peter Anvin
  0 siblings, 1 reply; 5+ messages in thread
From: Brian Gerst @ 2010-01-27 15:21 UTC (permalink / raw)
  To: Ingo Molnar; +Cc: mingo, hpa, linux-kernel, tglx, linux-tip-commits

On Wed, Jan 27, 2010 at 8:07 AM, Ingo Molnar <mingo@elte.hu> wrote:
>
> * tip-bot for Brian Gerst <brgerst@gmail.com> wrote:
>
>> Commit-ID:  f19a25c872b20ae4357f72687cf3e7b0da220ee2
>> Gitweb:     http://git.kernel.org/tip/f19a25c872b20ae4357f72687cf3e7b0da220ee2
>> Author:     Brian Gerst <brgerst@gmail.com>
>> AuthorDate: Mon, 25 Jan 2010 10:47:33 -0500
>> Committer:  H. Peter Anvin <hpa@zytor.com>
>> CommitDate: Tue, 26 Jan 2010 23:38:14 -0800
>>
>> x86-64: Use normal ptregs stub for execve
>>
>> Execve historically passed regs by value, so it had a seperate stub.
>> This is no longer true, so change it to use a normal PTREGSCALL stub.
>>
>> Signed-off-by: Brian Gerst <brgerst@gmail.com>
>> LKML-Reference: <1264434453-2204-1-git-send-email-brgerst@gmail.com>
>> Signed-off-by: H. Peter Anvin <hpa@zytor.com>
>> ---
>>  arch/x86/kernel/entry_64.S |   17 +----------------
>>  1 files changed, 1 insertions(+), 16 deletions(-)
>
> FYI, -tip testing found that this commit breaks the grub binary on 64-bit,
> simply running /sbin/grub causes it to segfault:
>
> [ 3145.999766] grub[6706] general protection ip:805c481 sp:ff95629c error:0 in
> grub[8048000+8c000]
>
> i've excluded this commit for now.
>
>        Ingo
>
>

I see what is going on.  Grub is a 32-bit statically linked executable
even on a 64-bit distro.  The old execve stub forced return to
userspace via iret, but PTREGSCALL apparently doesn't.  This means
that the 32-bit %cs isn't getting set.  Drop this patch for now.

--
Brian Gerst

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

* Re: [tip:x86/asm] x86-64: Use normal ptregs stub for execve
  2010-01-27 15:21     ` Brian Gerst
@ 2010-01-27 16:28       ` H. Peter Anvin
  0 siblings, 0 replies; 5+ messages in thread
From: H. Peter Anvin @ 2010-01-27 16:28 UTC (permalink / raw)
  To: Brian Gerst; +Cc: Ingo Molnar, mingo, linux-kernel, tglx, linux-tip-commits

On 01/27/2010 07:21 AM, Brian Gerst wrote:
> 
> I see what is going on.  Grub is a 32-bit statically linked executable
> even on a 64-bit distro.  The old execve stub forced return to
> userspace via iret, but PTREGSCALL apparently doesn't.  This means
> that the 32-bit %cs isn't getting set.  Drop this patch for now.
> 

OK, I presume that breaks execing any 32-bit app, not just statically
linked (eww...)

Yet one more case of Grub making me shudder, though :-/

	-hpa

-- 
H. Peter Anvin, Intel Open Source Technology Center
I work for Intel.  I don't speak on their behalf.


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

end of thread, other threads:[~2010-01-27 16:28 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-01-25 15:47 [PATCH] x86-64: Use normal ptregs stub for execve Brian Gerst
2010-01-27  8:39 ` [tip:x86/asm] " tip-bot for Brian Gerst
2010-01-27 13:07   ` Ingo Molnar
2010-01-27 15:21     ` Brian Gerst
2010-01-27 16:28       ` H. Peter Anvin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).