From patchwork Mon Nov 27 21:34:08 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andi Kleen X-Patchwork-Id: 10078173 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 00AD4602BD for ; Mon, 27 Nov 2017 21:35:27 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E64DB2901D for ; Mon, 27 Nov 2017 21:35:26 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DAEDA2908B; Mon, 27 Nov 2017 21:35:26 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6609C2901D for ; Mon, 27 Nov 2017 21:35:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753241AbdK0VfZ (ORCPT ); Mon, 27 Nov 2017 16:35:25 -0500 Received: from mga05.intel.com ([192.55.52.43]:65529 "EHLO mga05.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752849AbdK0Veg (ORCPT ); Mon, 27 Nov 2017 16:34:36 -0500 Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga105.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 27 Nov 2017 13:34:31 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.44,465,1505804400"; d="scan'208";a="12626820" Received: from tassilo.jf.intel.com (HELO tassilo.localdomain) ([10.7.201.35]) by orsmga002.jf.intel.com with ESMTP; 27 Nov 2017 13:34:30 -0800 Received: by tassilo.localdomain (Postfix, from userid 1000) id 82CAE300FDE; Mon, 27 Nov 2017 13:34:29 -0800 (PST) From: Andi Kleen To: linux-kernel@vger.kernel.org Cc: x86@kernel.org, samitolvanen@google.com, alxmtvv@gmail.com, linux-kbuild@vger.kernel.org, yamada.masahiro@socionext.com, akpm@linux-foundation.org, Andi Kleen Subject: [PATCH 06/21] x86/syscalls: Make x86 syscalls use real prototypes Date: Mon, 27 Nov 2017 13:34:08 -0800 Message-Id: <20171127213423.27218-7-andi@firstfloor.org> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20171127213423.27218-1-andi@firstfloor.org> References: <20171127213423.27218-1-andi@firstfloor.org> Sender: linux-kbuild-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Andi Kleen LTO complains very loudly that the x86 syscalls use their own different prototypes. Switch it to use the real prototypes instead. This requires adding a few extra prototypes to asm/syscalls.h. This is a generic cleanup, useful even without LTO. Signed-off-by: Andi Kleen --- arch/x86/entry/syscall_32.c | 13 +++++-------- arch/x86/entry/syscall_64.c | 13 +++++-------- arch/x86/include/asm/syscalls.h | 42 ++++++++++++++++++++++++++++++++++++----- 3 files changed, 47 insertions(+), 21 deletions(-) diff --git a/arch/x86/entry/syscall_32.c b/arch/x86/entry/syscall_32.c index 95c294963612..f7ffd4b100fd 100644 --- a/arch/x86/entry/syscall_32.c +++ b/arch/x86/entry/syscall_32.c @@ -6,20 +6,17 @@ #include #include #include +#include +#include +#include -#define __SYSCALL_I386(nr, sym, qual) extern asmlinkage long sym(unsigned long, unsigned long, unsigned long, unsigned long, unsigned long, unsigned long) ; -#include -#undef __SYSCALL_I386 - -#define __SYSCALL_I386(nr, sym, qual) [nr] = sym, - -extern asmlinkage long sys_ni_syscall(unsigned long, unsigned long, unsigned long, unsigned long, unsigned long, unsigned long); +#define __SYSCALL_I386(nr, sym, qual) [nr] = (sys_call_ptr_t)sym, __visible const sys_call_ptr_t ia32_sys_call_table[__NR_syscall_compat_max+1] = { /* * Smells like a compiler bug -- it doesn't work * when the & below is removed. */ - [0 ... __NR_syscall_compat_max] = &sys_ni_syscall, + [0 ... __NR_syscall_compat_max] = (sys_call_ptr_t)&sys_ni_syscall, #include }; diff --git a/arch/x86/entry/syscall_64.c b/arch/x86/entry/syscall_64.c index 9c09775e589d..1ccf4cd300a6 100644 --- a/arch/x86/entry/syscall_64.c +++ b/arch/x86/entry/syscall_64.c @@ -4,25 +4,22 @@ #include #include #include +#include +#include #include #include +#include #define __SYSCALL_64_QUAL_(sym) sym #define __SYSCALL_64_QUAL_ptregs(sym) ptregs_##sym -#define __SYSCALL_64(nr, sym, qual) extern asmlinkage long __SYSCALL_64_QUAL_##qual(sym)(unsigned long, unsigned long, unsigned long, unsigned long, unsigned long, unsigned long); -#include -#undef __SYSCALL_64 - -#define __SYSCALL_64(nr, sym, qual) [nr] = __SYSCALL_64_QUAL_##qual(sym), - -extern long sys_ni_syscall(unsigned long, unsigned long, unsigned long, unsigned long, unsigned long, unsigned long); +#define __SYSCALL_64(nr, sym, qual) [nr] = (sys_call_ptr_t)__SYSCALL_64_QUAL_##qual(sym), asmlinkage const sys_call_ptr_t sys_call_table[__NR_syscall_max+1] = { /* * Smells like a compiler bug -- it doesn't work * when the & below is removed. */ - [0 ... __NR_syscall_max] = &sys_ni_syscall, + [0 ... __NR_syscall_max] = (sys_call_ptr_t)&sys_ni_syscall, #include }; diff --git a/arch/x86/include/asm/syscalls.h b/arch/x86/include/asm/syscalls.h index bad25bb80679..76bf99c8b151 100644 --- a/arch/x86/include/asm/syscalls.h +++ b/arch/x86/include/asm/syscalls.h @@ -14,6 +14,7 @@ #include #include #include +#include /* Common in X86_32 and X86_64 */ /* kernel/ioport.c */ @@ -30,6 +31,8 @@ asmlinkage long sys_rt_sigreturn(void); asmlinkage long sys_set_thread_area(struct user_desc __user *); asmlinkage long sys_get_thread_area(struct user_desc __user *); +asmlinkage long sys_arch_prctl(int, unsigned long); + /* X86_32 only */ #ifdef CONFIG_X86_32 @@ -43,13 +46,42 @@ asmlinkage long sys_vm86(unsigned long, unsigned long); #else /* CONFIG_X86_32 */ -/* X86_64 only */ -/* kernel/process_64.c */ -asmlinkage long sys_arch_prctl(int, unsigned long); - /* kernel/sys_x86_64.c */ asmlinkage long sys_mmap(unsigned long, unsigned long, unsigned long, unsigned long, unsigned long, unsigned long); -#endif /* CONFIG_X86_32 */ +asmlinkage long ptregs_sys_rt_sigreturn(struct pt_regs *regs); +asmlinkage long ptregs_sys_fork(struct pt_regs *regs); +asmlinkage long ptregs_sys_vfork(struct pt_regs *regs); +asmlinkage long ptregs_sys_execve(const char __user *filename, + const char __user *const __user *argv, + const char __user *const __user *envp); +asmlinkage long ptregs_sys_iopl(unsigned int); +asmlinkage long ptregs_sys_execveat(int dfd, const char __user *filename, + const char __user *const __user *argv, + const char __user *const __user *envp, int flags); +asmlinkage long ptregs_sys_clone(unsigned long, unsigned long, int __user *, + int __user *, unsigned long); + +#ifdef CONFIG_COMPAT +asmlinkage long compat_sys_preadv64v2(unsigned long fd, + const struct compat_iovec __user *vec, + unsigned long vlen, loff_t pos, int flags); +asmlinkage long ptregs_compat_sys_execve(unsigned long dfd, + const char __user *filename, + const compat_uptr_t __user *argv, + const compat_uptr_t __user *envp); +asmlinkage long ptregs_compat_sys_execveat(int dfd, const char __user *filename, + const compat_uptr_t __user *argv, + const compat_uptr_t __user *envp, int flags); +asmlinkage long compat_sys_old_getrlimit(unsigned int resource, + struct compat_rlimit __user *rlim); +asmlinkage long stub32_clone(unsigned, unsigned, int __user *, + compat_uptr_t __user *, unsigned); +#endif + +asmlinkage long sys32_x32_rt_sigreturn(void); + + +#endif /* !CONFIG_X86_32 */ #endif /* _ASM_X86_SYSCALLS_H */