Received: by 2002:a25:e7d8:0:0:0:0:0 with SMTP id e207csp2103927ybh; Fri, 13 Mar 2020 12:55:25 -0700 (PDT) X-Google-Smtp-Source: ADFU+vuR56UDW2quGnWlhupYmHEnKX3fRCH1dBNSVNfdCOBYu5s/6afSafcApEzl5DticrwlfLE5 X-Received: by 2002:a05:6808:1cf:: with SMTP id x15mr8596674oic.44.1584129324945; Fri, 13 Mar 2020 12:55:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1584129324; cv=none; d=google.com; s=arc-20160816; b=Gm1RCI8PA/NPC8vZ1yJBc/wymZj09wEyl+p9QcJZNY1k8R5WyJ+SbVR+edQcIwWymK P+S70bI2D+FZK5vH/Qs0DJ8qwmwNXjsh56dBCiq8avZNHP4QZqHffbRV794yQrixV5Ow YbIOEibsRDZaNFDD2PIept2RzHNL+oc8uQtKCX9ja5uDbCGgPxzL9HDOAJVFP+A8cbHN HSXMWYGND+kMLiPIWBNiTnWUHBWhcrawGrDnebWKXj9xm23d0tVRWOHFXcty+pDbsQgX 60dIx82ULZLcGI2AeZIUWVGRGhLGJ34bVIoLLI0dkqT0a2NXjYIeRNM4iH4UBKVe48rJ vzLQ== 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:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=G29QVsSkkUqrG7r9BJsozRWYfilk+qJH9OFfvcUGx+c=; b=bbEfj30KjpXES1UZohl6Oy4Ohh7uUyaBDFaw2xuSAjy8mLEjHO7QmsXeiTc5e3R8zG pbMqXK+lAX2xN8shHzDwag3ob0OtAc5oO649E6/OjtNNf3zLbUeoo4VP9S2OpBqXFsOv D3ucCjaxmyENAOrM4CzWm3LmXKHqfxdmLtRekYzWp8vlj4IyEiyCXitVYsQyJx9k1icf gOstuGm4HVqKlJrkxvXoXL15cAbNxdAzzRpXzyIdZqqN2o+WNYeGxVFmIW7yhlfA74QH EU3WNRPplcYBBlrycGTj/LdcTcAkbspnBde2phlJoeb3ZrHwO+htfOiXg6J3udR9wMY+ Ia4Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=uuks+c+i; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z2si4603276oix.100.2020.03.13.12.55.12; Fri, 13 Mar 2020 12:55:24 -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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=uuks+c+i; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727241AbgCMTxV (ORCPT + 99 others); Fri, 13 Mar 2020 15:53:21 -0400 Received: from mail-qv1-f68.google.com ([209.85.219.68]:43872 "EHLO mail-qv1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726526AbgCMTwL (ORCPT ); Fri, 13 Mar 2020 15:52:11 -0400 Received: by mail-qv1-f68.google.com with SMTP id c28so5274913qvb.10 for ; Fri, 13 Mar 2020 12:52:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=G29QVsSkkUqrG7r9BJsozRWYfilk+qJH9OFfvcUGx+c=; b=uuks+c+iko6sK8gAZ8x2eh2lvkTkLwTmS9U3SJvMU6EAK1/al8QkfMh5M6EZY/7IOg 32r+IVU18h2vtfcYUrccGZXE89MYw7xaKPvkeY/91K1hALW5NCQFsREAhXfAdo4jPubo aM9TPm1SRF4Qv0ropbwj5wZQg3sxtVYqxj8NX0HHxdD5V/SRD/gyF4HPA8OGYTfD7eWo K71/aq5FwQxXme3d9n3Ql0EdYetIGPdAztXuouU+YOKAaUE9ORDALGJ5wuFCw5dtdNnQ kLB67HRgj2bRpKNW8iq96W35UGZU0tdBEB0v+vWu5y5LuYPZ2q6fhhfwvSZfs3yKWDAN rDEQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=G29QVsSkkUqrG7r9BJsozRWYfilk+qJH9OFfvcUGx+c=; b=dIldqxqhrbkP7S/83p6nIXmwgg/abnXjcSEyHhFHCYU9Xg8FOA5QxDlyMjY92AJn+0 gwKDjVRl8JijoKl2bDJZDGdcO6yc7BnmCd1Bkn0Xg1uV/CwdTjZujsoYH6MBro5MG8av F4buXNf1yHRpgd+f6r7Zcb9GQjXApwuCKOhdf3b7mkn8Mwlmi2qU3M6YxCl+sd1OdXjD y7lr9JECqcFLZ6sggneyKBPi8wLsh5Gofx7rjqtp1oOBMY2KzfgFoG6/RR43n7jWTMQ/ xH6ZL7JtyILTJEvhM/Rk8gyN6/0mMo44Jb9J7ZI3dz0R26gDVc+qTOnwzd5wUN96is/2 eSzA== X-Gm-Message-State: ANhLgQ031UpjnnFwrQvzwtZOTjMvUrHqxs2p3CnIFx/bmhByzVRNjRGV 8wj2ktO/70Gfbzd4ymeNitJa6KY= X-Received: by 2002:a05:6214:10c1:: with SMTP id r1mr14164281qvs.70.1584129130249; Fri, 13 Mar 2020 12:52:10 -0700 (PDT) Received: from localhost.localdomain (174-084-153-250.res.spectrum.com. [174.84.153.250]) by smtp.gmail.com with ESMTPSA id i28sm31475599qtc.57.2020.03.13.12.52.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Mar 2020 12:52:09 -0700 (PDT) From: Brian Gerst To: linux-kernel@vger.kernel.org, x86@kernel.org Cc: Thomas Gleixner , Ingo Molnar , Borislav Petkov , "H . Peter Anvin" , Andy Lutomirski , Dominik Brodowski , Brian Gerst Subject: [PATCH v4 01/18] x86, syscalls: Refactor SYSCALL_DEFINEx macros Date: Fri, 13 Mar 2020 15:51:27 -0400 Message-Id: <20200313195144.164260-2-brgerst@gmail.com> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200313195144.164260-1-brgerst@gmail.com> References: <20200313195144.164260-1-brgerst@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Pull the common code out from the SYSCALL_DEFINEx macros into a new __SYS_STUBx macro. Also conditionalize the X64 version in preparation for enabling syscall wrappers on 32-bit native kernels. Signed-off-by: Brian Gerst Reviewed-by: Dominik Brodowski Reviewed-by: Andy Lutomirski --- arch/x86/include/asm/syscall_wrapper.h | 49 +++++++++++++------------- 1 file changed, 24 insertions(+), 25 deletions(-) diff --git a/arch/x86/include/asm/syscall_wrapper.h b/arch/x86/include/asm/syscall_wrapper.h index e2389ce9bf58..a1c090bde063 100644 --- a/arch/x86/include/asm/syscall_wrapper.h +++ b/arch/x86/include/asm/syscall_wrapper.h @@ -21,6 +21,22 @@ struct pt_regs; ,,(unsigned int)regs->dx,,(unsigned int)regs->si \ ,,(unsigned int)regs->di,,(unsigned int)regs->bp) +#define __SYS_STUBx(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) \ + { \ + return __se_##name(__VA_ARGS__); \ + } + +#ifdef CONFIG_X86_64 +#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_STUBx(x, name, ...) +#endif /* CONFIG_X86_64 */ + #ifdef CONFIG_IA32_EMULATION /* * For IA32 emulation, we need to handle "compat" syscalls *and* create @@ -39,20 +55,12 @@ struct pt_regs; } #define __IA32_COMPAT_SYS_STUBx(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(SC_IA32_REGS_TO_ARGS(x,__VA_ARGS__));\ - } + __SYS_STUBx(ia32, compat_sys##name, \ + SC_IA32_REGS_TO_ARGS(x, __VA_ARGS__)) #define __IA32_SYS_STUBx(x, name, ...) \ - asmlinkage long __ia32_sys##name(const struct pt_regs *regs); \ - ALLOW_ERROR_INJECTION(__ia32_sys##name, ERRNO); \ - asmlinkage long __ia32_sys##name(const struct pt_regs *regs) \ - { \ - return __se_sys##name(SC_IA32_REGS_TO_ARGS(x,__VA_ARGS__));\ - } + __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 @@ -82,7 +90,7 @@ struct pt_regs; #else /* CONFIG_IA32_EMULATION */ #define __IA32_COMPAT_SYS_STUBx(x, name, ...) -#define __IA32_SYS_STUBx(x, fullname, name, ...) +#define __IA32_SYS_STUBx(x, name, ...) #endif /* CONFIG_IA32_EMULATION */ @@ -101,12 +109,8 @@ struct pt_regs; } #define __X32_COMPAT_SYS_STUBx(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(SC_X86_64_REGS_TO_ARGS(x,__VA_ARGS__));\ - } + __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) @@ -192,14 +196,9 @@ struct pt_regs; * to the i386 calling convention (bx, cx, dx, si, di, bp). */ #define __SYSCALL_DEFINEx(x, name, ...) \ - asmlinkage long __x64_sys##name(const struct pt_regs *regs); \ - ALLOW_ERROR_INJECTION(__x64_sys##name, ERRNO); \ static long __se_sys##name(__MAP(x,__SC_LONG,__VA_ARGS__)); \ static inline long __do_sys##name(__MAP(x,__SC_DECL,__VA_ARGS__));\ - asmlinkage long __x64_sys##name(const struct pt_regs *regs) \ - { \ - return __se_sys##name(SC_X86_64_REGS_TO_ARGS(x,__VA_ARGS__));\ - } \ + __X64_SYS_STUBx(x, name, __VA_ARGS__) \ __IA32_SYS_STUBx(x, name, __VA_ARGS__) \ static long __se_sys##name(__MAP(x,__SC_LONG,__VA_ARGS__)) \ { \ -- 2.24.1