From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754207AbbIAWrU (ORCPT ); Tue, 1 Sep 2015 18:47:20 -0400 Received: from mail.kernel.org ([198.145.29.136]:47648 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753372AbbIAWmP (ORCPT ); Tue, 1 Sep 2015 18:42:15 -0400 From: Andy Lutomirski To: x86@kernel.org, linux-kernel@vger.kernel.org Cc: Brian Gerst , Denys Vlasenko , Linus Torvalds , Borislav Petkov , Andy Lutomirski Subject: [RFC 20/30] x86/entry: Add C code for fast system call entries Date: Tue, 1 Sep 2015 15:41:20 -0700 Message-Id: <5c30cead35e9a70bf08413cb2072b48b2e43fcf6.1441146105.git.luto@kernel.org> X-Mailer: git-send-email 2.4.3 In-Reply-To: References: In-Reply-To: References: Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This handles both SYSENTER and SYSCALL. The asm glue will take care of the differences. Signed-off-by: Andy Lutomirski --- arch/x86/entry/common.c | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/arch/x86/entry/common.c b/arch/x86/entry/common.c index 41d17508cf46..5725cdcec4de 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,41 @@ __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 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. 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 -- 2.4.3