From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932143AbcA2Lhb (ORCPT ); Fri, 29 Jan 2016 06:37:31 -0500 Received: from terminus.zytor.com ([198.137.202.10]:56536 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756082AbcA2Lh0 (ORCPT ); Fri, 29 Jan 2016 06:37:26 -0500 Date: Fri, 29 Jan 2016 03:36:31 -0800 From: tip-bot for Andy Lutomirski Message-ID: Cc: linux-kernel@vger.kernel.org, bp@alien8.de, fweisbec@gmail.com, torvalds@linux-foundation.org, luto@kernel.org, tglx@linutronix.de, brgerst@gmail.com, mingo@kernel.org, luto@amacapital.net, dvlasenk@redhat.com, hpa@zytor.com, peterz@infradead.org Reply-To: bp@alien8.de, linux-kernel@vger.kernel.org, torvalds@linux-foundation.org, tglx@linutronix.de, luto@kernel.org, fweisbec@gmail.com, luto@amacapital.net, mingo@kernel.org, dvlasenk@redhat.com, brgerst@gmail.com, peterz@infradead.org, hpa@zytor.com In-Reply-To: References: To: linux-tip-commits@vger.kernel.org Subject: [tip:x86/asm] x86/entry/64: Stop using int_ret_from_sys_call in ret_from_fork Git-Commit-ID: 24d978b76ffd20ecff8a8d1c21b16fe740f8b119 X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit-ID: 24d978b76ffd20ecff8a8d1c21b16fe740f8b119 Gitweb: http://git.kernel.org/tip/24d978b76ffd20ecff8a8d1c21b16fe740f8b119 Author: Andy Lutomirski AuthorDate: Thu, 28 Jan 2016 15:11:27 -0800 Committer: Ingo Molnar CommitDate: Fri, 29 Jan 2016 09:46:38 +0100 x86/entry/64: Stop using int_ret_from_sys_call in ret_from_fork 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 Cc: Andy Lutomirski Cc: Borislav Petkov Cc: Brian Gerst Cc: Denys Vlasenko Cc: Frederic Weisbecker Cc: H. Peter Anvin Cc: Linus Torvalds Cc: Peter Zijlstra Cc: Thomas Gleixner Link: http://lkml.kernel.org/r/a0747e2a5e47084655a1e96351c545b755c41fa7.1454022279.git.luto@kernel.org Signed-off-by: Ingo Molnar --- 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 f7050a5..cb5d940 100644 --- a/arch/x86/entry/entry_64.S +++ b/arch/x86/entry/entry_64.S @@ -390,7 +390,6 @@ END(ptregs_\func) * rdi: prev task we switched from */ ENTRY(ret_from_fork) - LOCK ; btr $TIF_FORK, TI_flags(%r8) pushq $0x0002 @@ -398,28 +397,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) /*