x86/asm/entry/64: Use common code for rt_sigreturn epilogue
PATCH 1/8 x86/asm/entry/64: Use common code for rt_sigreturn epilogue
Similarly to stub_execve, we can reuse the epilogue in stub_rt_sigreturn and stub_x32_rt_sigreturn.
Add a comment explaining why we can't eliminage SAVE_EXTRA_REGS here.
--- arch/x86/kernel/entry_64.S | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-)
arch/x86/kernel/entry_64.S +16 -10
@@ -450,12 +450,21 @@ END(stub_execveat) */ ENTRY(stub_rt_sigreturn) CFI_STARTPROC - addq $8, %rsp - DEFAULT_FRAME 0 - SAVE_EXTRA_REGS + DEFAULT_FRAME 0, 8 + /* + * SAVE_EXTRA_REGS result is not normally needed: + * sigreturn overwrites all pt_regs->GPREGS. + * But sigreturn can fail (!), and there is no easy way to detect that. + * To make sure RESTORE_EXTRA_REGS doesn't restore garbage on error, + * we SAVE_EXTRA_REGS here. + */ + SAVE_EXTRA_REGS 8 call sys_rt_sigreturn - movq %rax,RAX(%rsp) # fixme, this could be done at the higher layer +return_from_stub: + addq $8, %rsp + CFI_ADJUST_CFA_OFFSET -8 RESTORE_EXTRA_REGS + movq %rax,RAX(%rsp) jmp int_ret_from_sys_call CFI_ENDPROC END(stub_rt_sigreturn)
@@ -463,13 +472,10 @@ END(stub_rt_sigreturn) #ifdef CONFIG_X86_X32_ABI ENTRY(stub_x32_rt_sigreturn) CFI_STARTPROC - addq $8, %rsp - DEFAULT_FRAME 0 - SAVE_EXTRA_REGS + DEFAULT_FRAME 0, 8 + SAVE_EXTRA_REGS 8 call sys32_x32_rt_sigreturn - movq %rax,RAX(%rsp) # fixme, this could be done at the higher layer - RESTORE_EXTRA_REGS - jmp int_ret_from_sys_call + jmp return_from_stub CFI_ENDPROC END(stub_x32_rt_sigreturn)
Signature · 1 line
1.8.1.4
PATCH 2/8 x86/asm/entry/64: Move stub_x32_execve[at] closer to stub_execveat
This is a preparatory patch for moving stub32_execve[at] to this file. It makes sense to have all execve stubs in one place, so that they can reuse code.
--- arch/x86/kernel/entry_64.S | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-)
arch/x86/kernel/entry_64.S +17 -17
@@ -444,6 +444,23 @@ ENTRY(stub_execveat) CFI_ENDPROC END(stub_execveat) +#ifdef CONFIG_X86_X32_ABI +ENTRY(stub_x32_execve) + CFI_STARTPROC + DEFAULT_FRAME 0, 8 + call compat_sys_execve + jmp return_from_execve + CFI_ENDPROC +END(stub_x32_execve) +ENTRY(stub_x32_execveat) + CFI_STARTPROC + DEFAULT_FRAME 0, 8 + call compat_sys_execveat + jmp return_from_execve + CFI_ENDPROC +END(stub_x32_execveat) +#endif + /* * 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.
@@ -478,23 +495,6 @@ ENTRY(stub_x32_rt_sigreturn) jmp return_from_stub CFI_ENDPROC END(stub_x32_rt_sigreturn) - -ENTRY(stub_x32_execve) - CFI_STARTPROC - DEFAULT_FRAME 0, 8 - call compat_sys_execve - jmp return_from_execve - CFI_ENDPROC -END(stub_x32_execve) - -ENTRY(stub_x32_execveat) - CFI_STARTPROC - DEFAULT_FRAME 0, 8 - call compat_sys_execveat - jmp return_from_execve - CFI_ENDPROC -END(stub_x32_execveat) - #endif /*
Signature · 1 line
1.8.1.4
tip-bot for Denys Vlasenko
merge bot[tip:x86/asm] x86/asm/entry/64: Move stub_x32_execvecloser() to stub_execveat()
x86/asm/entry/64: Move stub_x32_execvecloser() to stub_execveat()
Commit-ID: 05f1752d195c145d02ae40881d0985c2cfbee473 Gitweb: http://git.kernel.org/tip/05f1752d195c145d02ae40881d0985c2cfbee473 Author: Denys Vlasenko <[email protected]> AuthorDate: Tue, 7 Apr 2015 22:43:38 +0200 Committer: Ingo Molnar <[email protected]> CommitDate: Thu, 9 Apr 2015 10:31:24 +0200
x86/asm/entry/64: Move stub_x32_execvecloser() to stub_execveat()
This is a preparatory patch for moving stub32_execve[at]() to this file. It makes sense to have all execve stubs in one place, so that they can reuse code.
--- arch/x86/kernel/entry_64.S | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-)
arch/x86/kernel/entry_64.S +17 -17
@@ -521,6 +521,23 @@ ENTRY(stub_execveat) CFI_ENDPROC END(stub_execveat) +#ifdef CONFIG_X86_X32_ABI +ENTRY(stub_x32_execve) + CFI_STARTPROC + DEFAULT_FRAME 0, 8 + call compat_sys_execve + jmp return_from_execve + CFI_ENDPROC +END(stub_x32_execve) +ENTRY(stub_x32_execveat) + CFI_STARTPROC + DEFAULT_FRAME 0, 8 + call compat_sys_execveat + jmp return_from_execve + CFI_ENDPROC +END(stub_x32_execveat) +#endif + /* * 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.
@@ -555,23 +572,6 @@ ENTRY(stub_x32_rt_sigreturn) jmp return_from_stub CFI_ENDPROC END(stub_x32_rt_sigreturn) - -ENTRY(stub_x32_execve) - CFI_STARTPROC - DEFAULT_FRAME 0, 8 - call compat_sys_execve - jmp return_from_execve - CFI_ENDPROC -END(stub_x32_execve) - -ENTRY(stub_x32_execveat) - CFI_STARTPROC - DEFAULT_FRAME 0, 8 - call compat_sys_execveat - jmp return_from_execve - CFI_ENDPROC -END(stub_x32_execveat) - #endif /*
PATCH 3/8 x86/asm/entry: Zero EXTRA_REGS for stub32_execve[at] too
In reply to Denys VlasenkoThe change which affected how execve clears EXTRA_REGS missed 32-bit execve syscalls.
Fix this by using 64-bit execve stub epilogue for them too.
Run-tested.
--- arch/x86/ia32/ia32entry.S | 2 -- arch/x86/kernel/entry_64.S | 15 +++++++++++++++ 2 files changed, 15 insertions(+), 2 deletions(-)
arch/x86/ia32/ia32entry.S +0 -2
@@ -571,8 +571,6 @@ GLOBAL(\label) PTREGSCALL stub32_rt_sigreturn, sys32_rt_sigreturn PTREGSCALL stub32_sigreturn, sys32_sigreturn - PTREGSCALL stub32_execve, compat_sys_execve - PTREGSCALL stub32_execveat, compat_sys_execveat PTREGSCALL stub32_fork, sys_fork PTREGSCALL stub32_vfork, sys_vfork
arch/x86/kernel/entry_64.S +15 -0
@@ -461,6 +461,21 @@ ENTRY(stub_x32_execveat) END(stub_x32_execveat) #endif +#ifdef CONFIG_IA32_EMULATION +ENTRY(stub32_execve) + CFI_STARTPROC + call compat_sys_execve + jmp return_from_execve + CFI_ENDPROC +END(stub32_execve) +ENTRY(stub32_execveat) + CFI_STARTPROC + call compat_sys_execveat + jmp return_from_execve + CFI_ENDPROC +END(stub32_execveat) +#endif + /* * 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.
Signature · 1 line
1.8.1.4
Re: [PATCH 3/8] x86/asm/entry: Zero EXTRA_REGS for stub32_execve[at] too
Quoted 55 lines · Denys Vlasenko
The change which affected how execve clears
EXTRA_REGSmissed 32-bit execve syscalls.Fix this by using 64-bit execve stub epilogue for them too.
Run-tested.
Signed-off-by Denys Vlasenko <[email protected]>CC Linus Torvalds <[email protected]>CC Steven Rostedt <[email protected]>CC Ingo Molnar <[email protected]>CC Borislav Petkov <[email protected]>CC "H. Peter Anvin" <[email protected]>CC Andy Lutomirski <[email protected]>CC Oleg Nesterov <[email protected]>CC Frederic Weisbecker <[email protected]>CC Alexei Starovoitov <[email protected]>CC Will Drewry <[email protected]>CC Kees Cook <[email protected]>--- arch/x86/ia32/ia32entry.S | 2 -- arch/x86/kernel/entry_64.S | 15 +++++++++++++++ 2 files changed, 15 insertions(+), 2 deletions(-)arch/x86/ia32/ia32entry.S +0
-2@@ -571,8 +571,6 @@ GLOBAL(\label) PTREGSCALL stub32_rt_sigreturn, sys32_rt_sigreturn PTREGSCALL stub32_sigreturn, sys32_sigreturn - PTREGSCALL stub32_execve, compat_sys_execve - PTREGSCALL stub32_execveat, compat_sys_execveat PTREGSCALL stub32_fork, sys_fork PTREGSCALL stub32_vfork, sys_vforkarch/x86/kernel/entry_64.S +8
-0@@ -461,6 +461,21 @@ ENTRY(stub_x32_execveat) END(stub_x32_execveat) #endif +#ifdef CONFIG_IA32_EMULATION +ENTRY(stub32_execve) + CFI_STARTPROC + call compat_sys_execve + jmp return_from_execve + CFI_ENDPROC +END(stub32_execve) +ENTRY(stub32_execveat)
arch/x86/kernel/entry_64.S ENTRY(stub_x32_execveat) · line 481
Quoted 10 lines
arch/x86/kernel/entry_64.S +7
-0+ CFI_STARTPROC + call compat_sys_execveat + jmp return_from_execve + CFI_ENDPROC +END(stub32_execveat) +#endif + /* * 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.
The X32 and IA32 stubs are now identical and should be merged.
--
Brian Gerst
tip-bot for Denys Vlasenko
merge bot[tip:x86/asm] x86/asm/entry: Zero EXTRA_REGS for stub32_execve() too
In reply to Denys Vlasenkox86/asm/entry: Zero EXTRA_REGS for stub32_execve() too
Commit-ID: 0f90fb979d7b53d80a6d5cb6e127b4b4b249907e Gitweb: http://git.kernel.org/tip/0f90fb979d7b53d80a6d5cb6e127b4b4b249907e Author: Denys Vlasenko <[email protected]> AuthorDate: Tue, 7 Apr 2015 22:43:39 +0200 Committer: Ingo Molnar <[email protected]> CommitDate: Thu, 9 Apr 2015 10:31:24 +0200
x86/asm/entry: Zero EXTRA_REGS for stub32_execve() too
The change which affected how execve clears EXTRA_REGS missed 32-bit execve syscalls.
Fix this by using 64-bit execve stub epilogue for them too.
Run-tested.
--- arch/x86/ia32/ia32entry.S | 2 -- arch/x86/kernel/entry_64.S | 15 +++++++++++++++ 2 files changed, 15 insertions(+), 2 deletions(-)
arch/x86/ia32/ia32entry.S +0 -2
@@ -571,8 +571,6 @@ GLOBAL(\label) PTREGSCALL stub32_rt_sigreturn, sys32_rt_sigreturn PTREGSCALL stub32_sigreturn, sys32_sigreturn - PTREGSCALL stub32_execve, compat_sys_execve - PTREGSCALL stub32_execveat, compat_sys_execveat PTREGSCALL stub32_fork, sys_fork PTREGSCALL stub32_vfork, sys_vfork
arch/x86/kernel/entry_64.S +15 -0
@@ -538,6 +538,21 @@ ENTRY(stub_x32_execveat) END(stub_x32_execveat) #endif +#ifdef CONFIG_IA32_EMULATION +ENTRY(stub32_execve) + CFI_STARTPROC + call compat_sys_execve + jmp return_from_execve + CFI_ENDPROC +END(stub32_execve) +ENTRY(stub32_execveat) + CFI_STARTPROC + call compat_sys_execveat + jmp return_from_execve + CFI_ENDPROC +END(stub32_execveat) +#endif + /* * 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.
PATCH 4/8 x86/asm/entry/64: optimize [v]fork/clone stubs
In reply to Denys VlasenkoReplace "call func; ret" with "jmp func".
Run-tested.
--- arch/x86/kernel/entry_64.S | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
arch/x86/kernel/entry_64.S +1 -2
@@ -407,8 +407,7 @@ ENTRY(stub_\func) CFI_STARTPROC DEFAULT_FRAME 0, 8 /* offset 8: return address */ SAVE_EXTRA_REGS 8 - call sys_\func - ret + jmp sys_\func CFI_ENDPROC END(stub_\func) .endm
Signature · 1 line
1.8.1.4
tip-bot for Denys Vlasenko
merge bot[tip:x86/asm] x86/asm/entry/64: Optimize [v]fork/clone stubs
x86/asm/entry/64: Optimize [v]fork/clone stubs
Commit-ID: 772951c4e4b06cdffeff499259dba07b544f3166 Gitweb: http://git.kernel.org/tip/772951c4e4b06cdffeff499259dba07b544f3166 Author: Denys Vlasenko <[email protected]> AuthorDate: Tue, 7 Apr 2015 22:43:40 +0200 Committer: Ingo Molnar <[email protected]> CommitDate: Thu, 9 Apr 2015 10:31:25 +0200
x86/asm/entry/64: Optimize [v]fork/clone stubs
Replace "call func; ret" with "jmp func".
Run-tested.
--- arch/x86/kernel/entry_64.S | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
arch/x86/kernel/entry_64.S +1 -2
@@ -484,8 +484,7 @@ ENTRY(stub_\func) CFI_STARTPROC DEFAULT_FRAME 0, 8 /* offset 8: return address */ SAVE_EXTRA_REGS 8 - call sys_\func - ret + jmp sys_\func CFI_ENDPROC END(stub_\func) .endm
PATCH 5/8 x86/asm/entry/64: remove a redundant jump
In reply to Denys VlasenkoJumping to the very next instruction is not very useful:
jmp label
label:
Removing the jump.
--- arch/x86/kernel/entry_64.S | 1 - 1 file changed, 1 deletion(-)
arch/x86/kernel/entry_64.S +0 -1
@@ -1455,7 +1455,6 @@ ENTRY(nmi) /* If it is below the NMI stack, it is a normal NMI */ jb first_nmi /* Ah, it is within the NMI stack, treat it as nested */ - jmp nested_nmi CFI_REMEMBER_STATE
Signature · 1 line
1.8.1.4
tip-bot for Denys Vlasenko
merge bot[tip:x86/asm] x86/asm/entry/64: Remove a redundant jump
x86/asm/entry/64: Remove a redundant jump
Commit-ID: a30b0085f54efae11f6256df4e4a16af7eefc1c4 Gitweb: http://git.kernel.org/tip/a30b0085f54efae11f6256df4e4a16af7eefc1c4 Author: Denys Vlasenko <[email protected]> AuthorDate: Tue, 7 Apr 2015 22:43:41 +0200 Committer: Ingo Molnar <[email protected]> CommitDate: Thu, 9 Apr 2015 10:31:25 +0200
x86/asm/entry/64: Remove a redundant jump
Jumping to the very next instruction is not very useful:
jmp label
label:
Removing the jump.
--- arch/x86/kernel/entry_64.S | 1 - 1 file changed, 1 deletion(-)
arch/x86/kernel/entry_64.S +0 -1
@@ -1448,7 +1448,6 @@ ENTRY(nmi) /* If it is below the NMI stack, it is a normal NMI */ jb first_nmi /* Ah, it is within the NMI stack, treat it as nested */ - jmp nested_nmi CFI_REMEMBER_STATE
PATCH 6/8 x86/asm/entry/64: simplify jumps in ret_from_fork
In reply to Denys VlasenkoReplace
test
jz 1f
jmp label
1:with
test
jnz label
Run-tested.
--- arch/x86/kernel/entry_64.S | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
arch/x86/kernel/entry_64.S +4 -4
@@ -531,18 +531,18 @@ ENTRY(ret_from_fork) RESTORE_EXTRA_REGS testl $3,CS(%rsp) # from kernel_thread? - jz 1f /* * By the time we get here, we have no idea whether our pt_regs, * ti flags, and ti status came from the 64-bit SYSCALL fast path, * the slow path, or one of the ia32entry paths. - * Use int_ret_from_sys_call to return, since it can safely handle + * Use IRET code path to return, since it can safely handle * all of the above. */ - jmp int_ret_from_sys_call + jnz int_ret_from_sys_call -1: + /* We came from kernel_thread */ + /* nb: we depend on RESTORE_EXTRA_REGS above */ movq %rbp, %rdi call *%rbx movl $0, RAX(%rsp)
Signature · 1 line
1.8.1.4
tip-bot for Denys Vlasenko
merge bot[tip:x86/asm] x86/asm/entry/64: Simplify jumps in ret_from_fork
x86/asm/entry/64: Simplify jumps in ret_from_fork
Commit-ID: 66ad4efa51805964521db03d8aa827a8dd9058b9 Gitweb: http://git.kernel.org/tip/66ad4efa51805964521db03d8aa827a8dd9058b9 Author: Denys Vlasenko <[email protected]> AuthorDate: Tue, 7 Apr 2015 22:43:42 +0200 Committer: Ingo Molnar <[email protected]> CommitDate: Thu, 9 Apr 2015 10:31:25 +0200
x86/asm/entry/64: Simplify jumps in ret_from_fork
Replace
test
jz 1f
jmp label
1:with
test
jnz label
Run-tested.
--- arch/x86/kernel/entry_64.S | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
arch/x86/kernel/entry_64.S +4 -4
@@ -608,18 +608,18 @@ ENTRY(ret_from_fork) RESTORE_EXTRA_REGS testl $3,CS(%rsp) # from kernel_thread? - jz 1f /* * By the time we get here, we have no idea whether our pt_regs, * ti flags, and ti status came from the 64-bit SYSCALL fast path, * the slow path, or one of the ia32entry paths. - * Use int_ret_from_sys_call to return, since it can safely handle + * Use IRET code path to return, since it can safely handle * all of the above. */ - jmp int_ret_from_sys_call + jnz int_ret_from_sys_call -1: + /* We came from kernel_thread */ + /* nb: we depend on RESTORE_EXTRA_REGS above */ movq %rbp, %rdi call *%rbx movl $0, RAX(%rsp)
PATCH 7/8 x86/asm/entry/64: Remove GET_THREAD_INFO in ret_from_fork
In reply to Denys VlasenkoIt used to be used to check for _TIF_IA32, but the check has been removed.
Remove GET_THREAD_INFO too.
Run-tested.
--- arch/x86/kernel/entry_64.S | 2 -- 1 file changed, 2 deletions(-)
arch/x86/kernel/entry_64.S +0 -2
@@ -526,8 +526,6 @@ ENTRY(ret_from_fork) call schedule_tail # rdi: 'prev' task parameter - GET_THREAD_INFO(%rcx) - RESTORE_EXTRA_REGS testl $3,CS(%rsp) # from kernel_thread?
Signature · 1 line
1.8.1.4
tip-bot for Denys Vlasenko
merge bot[tip:x86/asm] x86/asm/entry/64: Remove GET_THREAD_INFO() in ret_from_fork
x86/asm/entry/64: Remove GET_THREAD_INFO() in ret_from_fork
Commit-ID: 54a81e914b2432a86dd49cf611b0f71ef44ca7ad Gitweb: http://git.kernel.org/tip/54a81e914b2432a86dd49cf611b0f71ef44ca7ad Author: Denys Vlasenko <[email protected]> AuthorDate: Tue, 7 Apr 2015 22:43:43 +0200 Committer: Ingo Molnar <[email protected]> CommitDate: Thu, 9 Apr 2015 10:31:26 +0200
x86/asm/entry/64: Remove GET_THREAD_INFO() in ret_from_fork
It used to be used to check for _TIF_IA32, but the check has been removed.
Remove GET_THREAD_INFO() too.
Run-tested.
--- arch/x86/kernel/entry_64.S | 2 -- 1 file changed, 2 deletions(-)
arch/x86/kernel/entry_64.S +0 -2
@@ -603,8 +603,6 @@ ENTRY(ret_from_fork) call schedule_tail # rdi: 'prev' task parameter - GET_THREAD_INFO(%rcx) - RESTORE_EXTRA_REGS testl $3,CS(%rsp) # from kernel_thread?
PATCH 8/8 x86/asm/entry/64: Reduce padding in execve stubs
In reply to Denys Vlasenkoexecve stubs are 7 bytes only. Padding them to 16 bytes is a waste.
text data bss dec hex filename
12594 0 0 12594 3132 entry_64.o.before 12530 0 0 12530 30f2 entry_64.o
Run-tested.
--- arch/x86/kernel/entry_64.S | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-)
arch/x86/kernel/entry_64.S +14 -6
@@ -434,8 +434,12 @@ return_from_execve: jmp int_ret_from_sys_call CFI_ENDPROC END(stub_execve) - -ENTRY(stub_execveat) +/* + * Remaining execve stubs are only 7 bytes long. + * ENTRY() often aligns to 16 bytes, which in this case has no benefits. + */ + .align 8 +GLOBAL(stub_execveat) CFI_STARTPROC DEFAULT_FRAME 0, 8 call sys_execveat
@@ -444,14 +448,16 @@ ENTRY(stub_execveat) END(stub_execveat) #ifdef CONFIG_X86_X32_ABI -ENTRY(stub_x32_execve) + .align 8 +GLOBAL(stub_x32_execve) CFI_STARTPROC DEFAULT_FRAME 0, 8 call compat_sys_execve jmp return_from_execve CFI_ENDPROC END(stub_x32_execve) -ENTRY(stub_x32_execveat) + .align 8 +GLOBAL(stub_x32_execveat) CFI_STARTPROC DEFAULT_FRAME 0, 8 call compat_sys_execveat
@@ -461,13 +467,15 @@ END(stub_x32_execveat) #endif #ifdef CONFIG_IA32_EMULATION -ENTRY(stub32_execve) + .align 8 +GLOBAL(stub32_execve) CFI_STARTPROC call compat_sys_execve jmp return_from_execve CFI_ENDPROC END(stub32_execve) -ENTRY(stub32_execveat) + .align 8 +GLOBAL(stub32_execveat) CFI_STARTPROC call compat_sys_execveat jmp return_from_execve
Signature · 1 line
1.8.1.4
tip-bot for Denys Vlasenko
merge bot[tip:x86/asm] x86/asm/entry/64: Reduce padding in execve stubs
x86/asm/entry/64: Reduce padding in execve stubs
Commit-ID: a37f34a325d90856314ccd4994e1070dcc6bdcc4 Gitweb: http://git.kernel.org/tip/a37f34a325d90856314ccd4994e1070dcc6bdcc4 Author: Denys Vlasenko <[email protected]> AuthorDate: Tue, 7 Apr 2015 22:43:44 +0200 Committer: Ingo Molnar <[email protected]> CommitDate: Thu, 9 Apr 2015 10:31:26 +0200
x86/asm/entry/64: Reduce padding in execve stubs
execve stubs are 7 bytes only. Padding them to 16 bytes is a waste.
text data bss dec hex filename
12594 0 0 12594 3132 entry_64.o.before 12530 0 0 12530 30f2 entry_64.o
Run-tested.
--- arch/x86/kernel/entry_64.S | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-)
arch/x86/kernel/entry_64.S +14 -6
@@ -511,8 +511,12 @@ return_from_execve: jmp int_ret_from_sys_call CFI_ENDPROC END(stub_execve) - -ENTRY(stub_execveat) +/* + * Remaining execve stubs are only 7 bytes long. + * ENTRY() often aligns to 16 bytes, which in this case has no benefits. + */ + .align 8 +GLOBAL(stub_execveat) CFI_STARTPROC DEFAULT_FRAME 0, 8 call sys_execveat
@@ -521,14 +525,16 @@ ENTRY(stub_execveat) END(stub_execveat) #ifdef CONFIG_X86_X32_ABI -ENTRY(stub_x32_execve) + .align 8 +GLOBAL(stub_x32_execve) CFI_STARTPROC DEFAULT_FRAME 0, 8 call compat_sys_execve jmp return_from_execve CFI_ENDPROC END(stub_x32_execve) -ENTRY(stub_x32_execveat) + .align 8 +GLOBAL(stub_x32_execveat) CFI_STARTPROC DEFAULT_FRAME 0, 8 call compat_sys_execveat
@@ -538,13 +544,15 @@ END(stub_x32_execveat) #endif #ifdef CONFIG_IA32_EMULATION -ENTRY(stub32_execve) + .align 8 +GLOBAL(stub32_execve) CFI_STARTPROC call compat_sys_execve jmp return_from_execve CFI_ENDPROC END(stub32_execve) -ENTRY(stub32_execveat) + .align 8 +GLOBAL(stub32_execveat) CFI_STARTPROC call compat_sys_execveat jmp return_from_execve
tip-bot for Denys Vlasenko
merge bot[tip:x86/asm] x86/asm/entry/64: Use common code for rt_sigreturn( ) epilogue
In reply to Denys Vlasenkox86/asm/entry/64: Use common code for rt_sigreturn() epilogue
Commit-ID: 31f0119b817f6474a7b4c48fed7588af1b62c543 Gitweb: http://git.kernel.org/tip/31f0119b817f6474a7b4c48fed7588af1b62c543 Author: Denys Vlasenko <[email protected]> AuthorDate: Tue, 7 Apr 2015 22:43:37 +0200 Committer: Ingo Molnar <[email protected]> CommitDate: Thu, 9 Apr 2015 10:31:24 +0200
x86/asm/entry/64: Use common code for rt_sigreturn() epilogue
Similarly to stub_execve, we can reuse the epilogue in stub_rt_sigreturn() and stub_x32_rt_sigreturn().
Add a comment explaining why we can't eliminage SAVE_EXTRA_REGS here.
--- arch/x86/kernel/entry_64.S | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-)
arch/x86/kernel/entry_64.S +16 -10
@@ -527,12 +527,21 @@ END(stub_execveat) */ ENTRY(stub_rt_sigreturn) CFI_STARTPROC - addq $8, %rsp - DEFAULT_FRAME 0 - SAVE_EXTRA_REGS + DEFAULT_FRAME 0, 8 + /* + * SAVE_EXTRA_REGS result is not normally needed: + * sigreturn overwrites all pt_regs->GPREGS. + * But sigreturn can fail (!), and there is no easy way to detect that. + * To make sure RESTORE_EXTRA_REGS doesn't restore garbage on error, + * we SAVE_EXTRA_REGS here. + */ + SAVE_EXTRA_REGS 8 call sys_rt_sigreturn - movq %rax,RAX(%rsp) # fixme, this could be done at the higher layer +return_from_stub: + addq $8, %rsp + CFI_ADJUST_CFA_OFFSET -8 RESTORE_EXTRA_REGS + movq %rax,RAX(%rsp) jmp int_ret_from_sys_call CFI_ENDPROC END(stub_rt_sigreturn)
@@ -540,13 +549,10 @@ END(stub_rt_sigreturn) #ifdef CONFIG_X86_X32_ABI ENTRY(stub_x32_rt_sigreturn) CFI_STARTPROC - addq $8, %rsp - DEFAULT_FRAME 0 - SAVE_EXTRA_REGS + DEFAULT_FRAME 0, 8 + SAVE_EXTRA_REGS 8 call sys32_x32_rt_sigreturn - movq %rax,RAX(%rsp) # fixme, this could be done at the higher layer - RESTORE_EXTRA_REGS - jmp int_ret_from_sys_call + jmp return_from_stub CFI_ENDPROC END(stub_x32_rt_sigreturn)