From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758750AbbJINLq (ORCPT ); Fri, 9 Oct 2015 09:11:46 -0400 Received: from terminus.zytor.com ([198.137.202.10]:46034 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751269AbbJINLo (ORCPT ); Fri, 9 Oct 2015 09:11:44 -0400 Date: Fri, 9 Oct 2015 06:10:40 -0700 From: tip-bot for Andy Lutomirski Message-ID: Cc: luto@kernel.org, torvalds@linux-foundation.org, luto@amacapital.net, peterz@infradead.org, bp@alien8.de, linux-kernel@vger.kernel.org, hpa@zytor.com, tglx@linutronix.de, dvlasenk@redhat.com, mingo@kernel.org, brgerst@gmail.com Reply-To: peterz@infradead.org, luto@amacapital.net, bp@alien8.de, linux-kernel@vger.kernel.org, hpa@zytor.com, dvlasenk@redhat.com, tglx@linutronix.de, mingo@kernel.org, brgerst@gmail.com, luto@kernel.org, torvalds@linux-foundation.org In-Reply-To: References: To: linux-tip-commits@vger.kernel.org Subject: [tip:x86/asm] x86/entry: Add do_syscall_32(), a C function to do 32-bit syscalls Git-Commit-ID: bd2d3a3ba67ac580f6e809aac36bf942f5447f91 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: bd2d3a3ba67ac580f6e809aac36bf942f5447f91 Gitweb: http://git.kernel.org/tip/bd2d3a3ba67ac580f6e809aac36bf942f5447f91 Author: Andy Lutomirski AuthorDate: Mon, 5 Oct 2015 17:48:08 -0700 Committer: Ingo Molnar CommitDate: Fri, 9 Oct 2015 09:41:08 +0200 x86/entry: Add do_syscall_32(), a C function to do 32-bit syscalls System calls are really quite simple. Add a helper to call a 32-bit system call. 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/a77ed179834c27da436fb4a7fb23c8ee77abc11c.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 d94a60c..41d1750 100644 --- a/arch/x86/entry/common.c +++ b/arch/x86/entry/common.c @@ -318,3 +318,46 @@ __visible void syscall_return_slowpath(struct pt_regs *regs) local_irq_disable(); prepare_exit_to_usermode(regs); } + +#if defined(CONFIG_X86_32) || defined(CONFIG_IA32_EMULATION) +/* + * Does a 32-bit syscall. Called with IRQs off and does all entry and + * exit work. + */ +__visible void do_int80_syscall_32(struct pt_regs *regs) +{ + struct thread_info *ti = pt_regs_to_thread_info(regs); + unsigned int nr = (unsigned int)regs->orig_ax; + +#ifdef CONFIG_IA32_EMULATION + ti->status |= TS_COMPAT; +#endif + + local_irq_enable(); + + if (READ_ONCE(ti->flags) & _TIF_WORK_SYSCALL_ENTRY) { + /* + * Subtlety here: if ptrace pokes something larger than + * 2^32-1 into orig_ax, this truncates it. This may or + * may not be necessary, but it matches the old asm + * behavior. + */ + nr = syscall_trace_enter(regs); + } + + if (nr < IA32_NR_syscalls) { + /* + * It's possible that a 32-bit syscall implementation + * takes a 64-bit parameter but nonetheless assumes that + * the high bits are zero. Make sure we zero-extend all + * of the args. + */ + regs->ax = ia32_sys_call_table[nr]( + (unsigned int)regs->bx, (unsigned int)regs->cx, + (unsigned int)regs->dx, (unsigned int)regs->si, + (unsigned int)regs->di, (unsigned int)regs->bp); + } + + syscall_return_slowpath(regs); +} +#endif