From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758793AbbJINMU (ORCPT ); Fri, 9 Oct 2015 09:12:20 -0400 Received: from terminus.zytor.com ([198.137.202.10]:46066 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754597AbbJINMR (ORCPT ); Fri, 9 Oct 2015 09:12:17 -0400 Date: Fri, 9 Oct 2015 06:11:23 -0700 From: tip-bot for Andy Lutomirski Message-ID: Cc: tglx@linutronix.de, bp@alien8.de, hpa@zytor.com, mingo@kernel.org, linux-kernel@vger.kernel.org, brgerst@gmail.com, dvlasenk@redhat.com, luto@amacapital.net, peterz@infradead.org, luto@kernel.org, torvalds@linux-foundation.org Reply-To: dvlasenk@redhat.com, brgerst@gmail.com, luto@amacapital.net, luto@kernel.org, peterz@infradead.org, torvalds@linux-foundation.org, bp@alien8.de, tglx@linutronix.de, hpa@zytor.com, mingo@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <6041a58a9b8ef6d2522ab4350deb1a1945eb563f.1444091585.git.luto@kernel.org> References: <6041a58a9b8ef6d2522ab4350deb1a1945eb563f.1444091585.git.luto@kernel.org> To: linux-tip-commits@vger.kernel.org Subject: [tip:x86/asm] x86/entry: Add C code for fast system call entries Git-Commit-ID: 710246df58041106b7de645f4b45770f8a59a269 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: 710246df58041106b7de645f4b45770f8a59a269 Gitweb: http://git.kernel.org/tip/710246df58041106b7de645f4b45770f8a59a269 Author: Andy Lutomirski AuthorDate: Mon, 5 Oct 2015 17:48:10 -0700 Committer: Ingo Molnar CommitDate: Fri, 9 Oct 2015 09:41:09 +0200 x86/entry: Add C code for fast system call entries This handles both SYSENTER and SYSCALL. The asm glue will take care of the differences. Signed-off-by: Andy Lutomirski Cc: Andy Lutomirski Cc: Borislav Petkov Cc: Brian Gerst Cc: Denys Vlasenko Cc: H. Peter Anvin Cc: Linus Torvalds Cc: Peter Zijlstra Cc: Thomas Gleixner Cc: linux-kernel@vger.kernel.org Link: http://lkml.kernel.org/r/6041a58a9b8ef6d2522ab4350deb1a1945eb563f.1444091585.git.luto@kernel.org Signed-off-by: Ingo Molnar --- arch/x86/entry/common.c | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/arch/x86/entry/common.c b/arch/x86/entry/common.c index 41d1750..1b2606e 100644 --- a/arch/x86/entry/common.c +++ b/arch/x86/entry/common.c @@ -24,6 +24,8 @@ #include #include +#include +#include #define CREATE_TRACE_POINTS #include @@ -360,4 +362,45 @@ __visible void do_int80_syscall_32(struct pt_regs *regs) syscall_return_slowpath(regs); } + +__visible void do_fast_syscall_32(struct pt_regs *regs) +{ + /* + * Called using the internal vDSO SYSENTER/SYSCALL32 calling + * convention. Adjust regs so it looks like we entered using int80. + */ + + unsigned long landing_pad = (unsigned long)current->mm->context.vdso + + vdso_image_32.sym_int80_landing_pad; + + /* + * SYSENTER loses EIP, and even SYSCALL32 needs us to skip forward + * so that 'regs->ip -= 2' lands back on an int $0x80 instruction. + * Fix it up. + */ + regs->ip = landing_pad; + + /* + * Fetch ECX from where the vDSO stashed it. + * + * WARNING: We are in CONTEXT_USER and RCU isn't paying attention! + */ + local_irq_enable(); + if (get_user(*(u32 *)®s->cx, + (u32 __user __force *)(unsigned long)(u32)regs->sp)) { + /* User code screwed up. */ + local_irq_disable(); + regs->ax = -EFAULT; +#ifdef CONFIG_CONTEXT_TRACKING + enter_from_user_mode(); +#endif + prepare_exit_to_usermode(regs); + return; + } + local_irq_disable(); + + /* Now this is just like a normal syscall. */ + do_int80_syscall_32(regs); + return; +} #endif