Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1285997
| From | Andy Lutomirski <luto@kernel.org> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | [PATCH 09/12] x86/entry/64: Stop using int_ret_from_sys_call in ret_from_fork |
| Date | 2015-12-07 23:00 +0100 |
| Message-ID | <qDbZa-1Mo-75@gated-at.bofh.it> (permalink) |
| References | <qDbZ7-1Mo-3@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
ret_from_fork is now open-coded and is no longer tangled up with the syscall code. This isn't so bad -- this adds very little code, and IMO the result is much easier to understand. Signed-off-by: Andy Lutomirski <luto@kernel.org> --- arch/x86/entry/entry_64.S | 35 +++++++++++++++++++---------------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/arch/x86/entry/entry_64.S b/arch/x86/entry/entry_64.S index 8a6b7ce2beff..81b0944708c5 100644 --- a/arch/x86/entry/entry_64.S +++ b/arch/x86/entry/entry_64.S @@ -363,7 +363,6 @@ END(stub_ptregs_64) * rdi: prev task we switched from */ ENTRY(ret_from_fork) - LOCK ; btr $TIF_FORK, TI_flags(%r8) pushq $0x0002 @@ -371,28 +370,32 @@ ENTRY(ret_from_fork) call schedule_tail /* rdi: 'prev' task parameter */ - RESTORE_EXTRA_REGS - testb $3, CS(%rsp) /* from kernel_thread? */ + jnz 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 32-bit compat paths. - * Use IRET code path to return, since it can safely handle - * all of the above. + * We came from kernel_thread. This code path is quite twisted, and + * someone should clean it up. + * + * copy_thread_tls stashes the function pointer in RBX and the + * parameter to be passed in RBP. The called function is permitted + * to call do_execve and thereby jump to user mode. */ - jnz int_ret_from_sys_call + movq RBP(%rsp), %rdi + call *RBX(%rsp) + movl $0, RAX(%rsp) /* - * We came from kernel_thread - * nb: we depend on RESTORE_EXTRA_REGS above + * Fall through as though we're exiting a syscall. This makes a + * twisted sort of sense if we just called do_execve. */ - movq %rbp, %rdi - call *%rbx - movl $0, RAX(%rsp) - RESTORE_EXTRA_REGS - jmp int_ret_from_sys_call + +1: + movq %rsp, %rdi + call syscall_return_slowpath /* returns with IRQs disabled */ + TRACE_IRQS_ON /* user mode is traced as IRQS on */ + SWAPGS + jmp restore_regs_and_iret END(ret_from_fork) /* -- 2.5.0 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCH 00/12] x86: Rewrite 64-bit syscall code Andy Lutomirski <luto@kernel.org> - 2015-12-07 23:00 +0100
[PATCH 09/12] x86/entry/64: Stop using int_ret_from_sys_call in ret_from_fork Andy Lutomirski <luto@kernel.org> - 2015-12-07 23:00 +0100
Re: [PATCH 00/12] x86: Rewrite 64-bit syscall code Andy Lutomirski <luto@amacapital.net> - 2015-12-08 00:00 +0100
Re: [PATCH 00/12] x86: Rewrite 64-bit syscall code Ingo Molnar <mingo@kernel.org> - 2015-12-08 05:50 +0100
Re: [PATCH 00/12] x86: Rewrite 64-bit syscall code Andy Lutomirski <luto@amacapital.net> - 2015-12-08 06:50 +0100
Re: [PATCH 00/12] x86: Rewrite 64-bit syscall code Ingo Molnar <mingo@kernel.org> - 2015-12-08 08:10 +0100
csiph-web