Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp1915239ybb; Sat, 21 Mar 2020 08:31:43 -0700 (PDT) X-Google-Smtp-Source: ADFU+vvDEwadEiFr9GUPZw01ECFlJgUEqYnvc0Q+3L2BhM3DtACgorTdV6e358+590GadCJc46IC X-Received: by 2002:a05:6830:13d5:: with SMTP id e21mr11661723otq.37.1584804703802; Sat, 21 Mar 2020 08:31:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1584804703; cv=none; d=google.com; s=arc-20160816; b=Brq03PsiwPKCoPeyC6L0VnZ+R4qDBPdXu6H3yZZC1akLzWoGM9lh4C8rf0IZUBxd7R p02mbCsN2g5q3DtpX4Ki/VOyZ8aQz3mK6vLxkXpXjneQjTIIzmjkbQP5qjO3gkOLuj77 dd0Z3VtwsT+o3G3NBpE/WcQmm5TNZ3wqOSQ6FYIW35+RdlhuHVBMq5zJJbY77evLOPh1 F0YY1e2pYjWAh0bvUzmw4M0/1DkTwYqmwUSHvP1msJBxnKGQUAotyXhS/trT310WC8Dn 5v+t6YrqnXJ6hUrUBYmReI8ER96u4Z2hGZ1zmzJab23V7vaxFSvamrodqUnTf5V9k81l +gJA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :robot-unsubscribe:robot-id:message-id:mime-version:references :in-reply-to:cc:subject:to:reply-to:from:date; bh=xK/NHvcOM8HERWvwhrrFJ9AGvJfhEYOHc+Yc5Bzq3xg=; b=Pex9wz4brbItTZK7Xpqpc/3i8C8WqEp9mh0/HLCSJd94BtJv4Wa9VmVl895TIjh7pG orOMbDPnELiAIDccqjlmYhk4eb+AaiISu15FVbz9H7opEbhre8qMV3CfCz+4o+q98Wcz 1Zwzje19rdBysCvneeGvu0GvhKwt8W7sZNxXUn5zTaI2oqXl2kv51fNuIfVjPAMvZ9IS 015guystimz/NVLtQOAK2ixDZptfwFavTqTiPRWNPWudW9UvkNxO45B9wenZ0kEv2XKB 1PoswFY1Jb3AbmEAJbnUcMLil1VeSgUUo3UnPeNY8/OwNRkWDVmbZsD2/OwhARVchX89 AocQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p126si4782387oib.73.2020.03.21.08.31.31; Sat, 21 Mar 2020 08:31:43 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727913AbgCUPaz (ORCPT + 99 others); Sat, 21 Mar 2020 11:30:55 -0400 Received: from Galois.linutronix.de ([193.142.43.55]:38954 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727749AbgCUPar (ORCPT ); Sat, 21 Mar 2020 11:30:47 -0400 Received: from [5.158.153.53] (helo=tip-bot2.lab.linutronix.de) by Galois.linutronix.de with esmtpsa (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1jFg5E-00053g-HL; Sat, 21 Mar 2020 16:30:44 +0100 Received: from [127.0.1.1] (localhost [IPv6:::1]) by tip-bot2.lab.linutronix.de (Postfix) with ESMTP id ECFCB1C22EB; Sat, 21 Mar 2020 16:30:38 +0100 (CET) Date: Sat, 21 Mar 2020 15:30:38 -0000 From: "tip-bot2 for Brian Gerst" Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: x86/entry] x86/entry: Refactor SYSCALL_DEFINE0 macros Cc: Brian Gerst , Thomas Gleixner , Dominik Brodowski , Andy Lutomirski , x86 , LKML In-Reply-To: <20200313195144.164260-3-brgerst@gmail.com> References: <20200313195144.164260-3-brgerst@gmail.com> MIME-Version: 1.0 Message-ID: <158480463855.28353.15888285041693958366.tip-bot2@tip-bot2> X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Linutronix-Spam-Score: -1.0 X-Linutronix-Spam-Level: - X-Linutronix-Spam-Status: No , -1.0 points, 5.0 required, ALL_TRUSTED=-1,SHORTCIRCUIT=-0.0001 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The following commit has been merged into the x86/entry branch of tip: Commit-ID: d2b5de495ee9838b3752806c135afd43b76b1e8f Gitweb: https://git.kernel.org/tip/d2b5de495ee9838b3752806c135afd43b76b1e8f Author: Brian Gerst AuthorDate: Fri, 13 Mar 2020 15:51:28 -04:00 Committer: Thomas Gleixner CommitterDate: Sat, 21 Mar 2020 16:03:19 +01:00 x86/entry: Refactor SYSCALL_DEFINE0 macros Pull the common code out from the SYSCALL_DEFINE0 macros into a new __SYS_STUB0 macro. Also conditionalize the X64 version in preparation for enabling syscall wrappers on 32-bit native kernels. Signed-off-by: Brian Gerst Signed-off-by: Thomas Gleixner Reviewed-by: Dominik Brodowski Reviewed-by: Andy Lutomirski Link: https://lkml.kernel.org/r/20200313195144.164260-3-brgerst@gmail.com --- arch/x86/include/asm/syscall_wrapper.h | 73 ++++++++++--------------- 1 file changed, 32 insertions(+), 41 deletions(-) diff --git a/arch/x86/include/asm/syscall_wrapper.h b/arch/x86/include/asm/syscall_wrapper.h index a1c090b..45ad605 100644 --- a/arch/x86/include/asm/syscall_wrapper.h +++ b/arch/x86/include/asm/syscall_wrapper.h @@ -21,6 +21,12 @@ struct pt_regs; ,,(unsigned int)regs->dx,,(unsigned int)regs->si \ ,,(unsigned int)regs->di,,(unsigned int)regs->bp) +#define __SYS_STUB0(abi, name) \ + asmlinkage long __##abi##_##name(const struct pt_regs *regs); \ + ALLOW_ERROR_INJECTION(__##abi##_##name, ERRNO); \ + asmlinkage long __##abi##_##name(const struct pt_regs *regs) \ + __alias(__do_##name); + #define __SYS_STUBx(abi, name, ...) \ asmlinkage long __##abi##_##name(const struct pt_regs *regs); \ ALLOW_ERROR_INJECTION(__##abi##_##name, ERRNO); \ @@ -30,10 +36,14 @@ struct pt_regs; } #ifdef CONFIG_X86_64 +#define __X64_SYS_STUB0(name) \ + __SYS_STUB0(x64, sys_##name) + #define __X64_SYS_STUBx(x, name, ...) \ __SYS_STUBx(x64, sys##name, \ SC_X86_64_REGS_TO_ARGS(x, __VA_ARGS__)) #else /* CONFIG_X86_64 */ +#define __X64_SYS_STUB0(name) #define __X64_SYS_STUBx(x, name, ...) #endif /* CONFIG_X86_64 */ @@ -46,34 +56,20 @@ struct pt_regs; * kernel/sys_ni.c and SYS_NI in kernel/time/posix-stubs.c to cover this * case as well. */ -#define __IA32_COMPAT_SYS_STUB0(x, name) \ - asmlinkage long __ia32_compat_sys_##name(const struct pt_regs *regs);\ - ALLOW_ERROR_INJECTION(__ia32_compat_sys_##name, ERRNO); \ - asmlinkage long __ia32_compat_sys_##name(const struct pt_regs *regs)\ - { \ - return __se_compat_sys_##name(); \ - } +#define __IA32_COMPAT_SYS_STUB0(name) \ + __SYS_STUB0(ia32, compat_sys_##name) #define __IA32_COMPAT_SYS_STUBx(x, name, ...) \ __SYS_STUBx(ia32, compat_sys##name, \ SC_IA32_REGS_TO_ARGS(x, __VA_ARGS__)) +#define __IA32_SYS_STUB0(name) \ + __SYS_STUB0(ia32, sys_##name) + #define __IA32_SYS_STUBx(x, name, ...) \ __SYS_STUBx(ia32, sys##name, \ SC_IA32_REGS_TO_ARGS(x, __VA_ARGS__)) -/* - * To keep the naming coherent, re-define SYSCALL_DEFINE0 to create an alias - * named __ia32_sys_*() - */ - -#define SYSCALL_DEFINE0(sname) \ - SYSCALL_METADATA(_##sname, 0); \ - asmlinkage long __x64_sys_##sname(const struct pt_regs *__unused);\ - ALLOW_ERROR_INJECTION(__x64_sys_##sname, ERRNO); \ - SYSCALL_ALIAS(__ia32_sys_##sname, __x64_sys_##sname); \ - asmlinkage long __x64_sys_##sname(const struct pt_regs *__unused) - #define COND_SYSCALL(name) \ asmlinkage __weak long __x64_sys_##name(const struct pt_regs *__unused) \ { \ @@ -89,7 +85,9 @@ struct pt_regs; SYSCALL_ALIAS(__ia32_sys_##name, sys_ni_posix_timers) #else /* CONFIG_IA32_EMULATION */ +#define __IA32_COMPAT_SYS_STUB0(name) #define __IA32_COMPAT_SYS_STUBx(x, name, ...) +#define __IA32_SYS_STUB0(name) #define __IA32_SYS_STUBx(x, name, ...) #endif /* CONFIG_IA32_EMULATION */ @@ -100,20 +98,15 @@ struct pt_regs; * of the x86-64-style parameter ordering of x32 syscalls. The syscalls common * with x86_64 obviously do not need such care. */ -#define __X32_COMPAT_SYS_STUB0(x, name, ...) \ - asmlinkage long __x32_compat_sys_##name(const struct pt_regs *regs);\ - ALLOW_ERROR_INJECTION(__x32_compat_sys_##name, ERRNO); \ - asmlinkage long __x32_compat_sys_##name(const struct pt_regs *regs)\ - { \ - return __se_compat_sys_##name();\ - } +#define __X32_COMPAT_SYS_STUB0(name) \ + __SYS_STUB0(x32, compat_sys_##name) #define __X32_COMPAT_SYS_STUBx(x, name, ...) \ __SYS_STUBx(x32, compat_sys##name, \ SC_X86_64_REGS_TO_ARGS(x, __VA_ARGS__)) #else /* CONFIG_X86_X32 */ -#define __X32_COMPAT_SYS_STUB0(x, name) +#define __X32_COMPAT_SYS_STUB0(name) #define __X32_COMPAT_SYS_STUBx(x, name, ...) #endif /* CONFIG_X86_X32 */ @@ -125,15 +118,12 @@ struct pt_regs; * of them. */ #define COMPAT_SYSCALL_DEFINE0(name) \ - static long __se_compat_sys_##name(void); \ - static inline long __do_compat_sys_##name(void); \ - __IA32_COMPAT_SYS_STUB0(x, name) \ - __X32_COMPAT_SYS_STUB0(x, name) \ - static long __se_compat_sys_##name(void) \ - { \ - return __do_compat_sys_##name(); \ - } \ - static inline long __do_compat_sys_##name(void) + static asmlinkage long \ + __do_compat_sys_##name(const struct pt_regs *__unused); \ + __IA32_COMPAT_SYS_STUB0(name) \ + __X32_COMPAT_SYS_STUB0(name) \ + static asmlinkage long \ + __do_compat_sys_##name(const struct pt_regs *__unused) #define COMPAT_SYSCALL_DEFINEx(x, name, ...) \ static long __se_compat_sys##name(__MAP(x,__SC_LONG,__VA_ARGS__)); \ @@ -216,13 +206,14 @@ struct pt_regs; * SYSCALL_DEFINEx() -- which is essential for the COND_SYSCALL() and SYS_NI() * macros to work correctly. */ -#ifndef SYSCALL_DEFINE0 #define SYSCALL_DEFINE0(sname) \ SYSCALL_METADATA(_##sname, 0); \ - asmlinkage long __x64_sys_##sname(const struct pt_regs *__unused);\ - ALLOW_ERROR_INJECTION(__x64_sys_##sname, ERRNO); \ - asmlinkage long __x64_sys_##sname(const struct pt_regs *__unused) -#endif + static asmlinkage long \ + __do_sys_##sname(const struct pt_regs *__unused); \ + __X64_SYS_STUB0(sname) \ + __IA32_SYS_STUB0(sname) \ + static asmlinkage long \ + __do_sys_##sname(const struct pt_regs *__unused) #ifndef COND_SYSCALL #define COND_SYSCALL(name) \