Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp2722313ybv; Mon, 24 Feb 2020 10:18:43 -0800 (PST) X-Google-Smtp-Source: APXvYqx4yuN+Uo39yYfHF78q8o7ztJnD6beIddkB7/3oTCQRFTDLkRGyXPFj/za9AcJdTf6jZwJ0 X-Received: by 2002:aca:c401:: with SMTP id u1mr315133oif.62.1582568323600; Mon, 24 Feb 2020 10:18:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582568323; cv=none; d=google.com; s=arc-20160816; b=UQVXen+BXg1RdKPzk9+euJTbfcBntMcUC+LyHld2ZXJXZNqBRFVHdzoJVL4KV2oYO5 ioIgjn+fhTqbaDmWLUnM1fhR/RmOVWLmZvZAvPdZttcGy4CpN5CcnZ4iPgAiejeJRv7w k4ofcEvlcDsSf67KrZ5H/5Tt5ovzIlmdKa4Lpni1PDFU/NWsB1p6EIoCXA3if3NdFrTi 0Vk0zemIUvwIVADHuLm3Vd+Yg3SyvlgubMSL8gkT3vQHrvqKYBa9Y/T/wKxe6Ld1BXll oN7SbD3425B4ssxx8504VloeraMr6zraeugkJpOkQH+AFeV0j8qog19XIKIswqUruJYn Z0zQ== 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=CNGI++LCtmWKqhI75KNMOUUrisxGISxEFr9CPvfqxm0=; b=Fr/lrLwWMo36obaRtL8rk1Cts/KbBG0FL2eWZGdrj9EubPVaGJUz1nUH37/8ib0gl8 EmdJGAE2SASJdyyernP2/6lfKx25rXMFxNoGGWp/YqQ2awNKXcGntOOQTx4TXFcIlCff CRTz6ZW8vwAlLWd+accS+bNzDNTjGuxtsxwlFWXPpM7S4jY6DpfdOo2f16G7yvim9uXR yLjdwY7MVZTZWwVAfVf7kZj0HUeEuca/XUDKH0nYC/oABLsEb4/jfwJm2RIcSzjgXw8J i6YYOo3Kx+SU/mnzpikwCIwyQ9f2QxyNB0HALFVWmSWJirROEXfYOa7OOgPqYjVuiBNp NU5A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=khOVId9p; 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 c18si9299636ots.317.2020.02.24.10.18.31; Mon, 24 Feb 2020 10:18:43 -0800 (PST) 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=khOVId9p; 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 S1727950AbgBXSST (ORCPT + 99 others); Mon, 24 Feb 2020 13:18:19 -0500 Received: from mail-yw1-f67.google.com ([209.85.161.67]:35055 "EHLO mail-yw1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726208AbgBXSSS (ORCPT ); Mon, 24 Feb 2020 13:18:18 -0500 Received: by mail-yw1-f67.google.com with SMTP id i190so5655655ywc.2 for ; Mon, 24 Feb 2020 10:18:17 -0800 (PST) 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=CNGI++LCtmWKqhI75KNMOUUrisxGISxEFr9CPvfqxm0=; b=khOVId9pGjxaXOPTQWWdErrpLrGR5UOdQWa1Samy6zEYPgy/r1SKKuBMsUPvIXVKnX KX4E3qDoZNnuEQR46lAyYE6IOubMyQ+LhB7z/LXLvA7J5LEng0p90/VZKnrsJ2SHCAkJ WTr8RNgcuLtgSn/jMal9FubiN9tCx1i85db0spKMf50819/yqIhIN7Hq2c8EQ58xP6fi Z6rr71cU1Qies4g8dja52ZfScxjrx5T2JjFiG2fT/O8RwkhAE8SLIahYeq+i4cnN+N// 7+Sfhwb1mQiW7NzxhrdkZBvfmfQ1ZWu5IxbrEF+ePzaMXfAYWQwnGJkVW2LRNHqXXtLn 75Kw== 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=CNGI++LCtmWKqhI75KNMOUUrisxGISxEFr9CPvfqxm0=; b=nSBQG4eoso7u1sBfLh2hgw/jLuadThu5oCMwrJAL4IhlF2IaUeJtXhTn6seq23k/m3 NV3XlXD4XR0+IizpPe1fFL92a6VQtnCsRqMrCaGuNeACxPFR0e/TTCqnO8dBvGQA1Rpe Sq8L8ZNUJri8fpjQavvSiE6LOXQwykhi0JIGm5uzrH2hNanJGTbc/qCi5+GuRUEUSJ1G A01cWGUlbXK/Zk3AI2zzIjzr/81kEpH8UFqq1QplC6qHOeDr24+nQY1vQ92fsDSokgmD lQAwg+4Nt9pzQ1Uh9kjqAMVPBUL3OoBn/eo0fy6GQ0BR4lbEesjlRqEvtH1x564bwW4f 6hkg== X-Gm-Message-State: APjAAAV2rBQSnKWumNGzyrSe/Vrw3fPrWPIlY7roXQTplW3z/DxXRztg C8Z3bcNXCDfQIheAQpUVqluhyOk= X-Received: by 2002:a81:3944:: with SMTP id g65mr39555260ywa.169.1582568296758; Mon, 24 Feb 2020 10:18:16 -0800 (PST) Received: from localhost.localdomain (174-084-153-250.res.spectrum.com. [174.84.153.250]) by smtp.gmail.com with ESMTPSA id i66sm5632383ywa.74.2020.02.24.10.18.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Feb 2020 10:18:16 -0800 (PST) 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 v2 3/8] x86, syscalls: Refactor COND_SYSCALL macros Date: Mon, 24 Feb 2020 13:17:52 -0500 Message-Id: <20200224181757.724961-4-brgerst@gmail.com> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200224181757.724961-1-brgerst@gmail.com> References: <20200224181757.724961-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 COND_SYSCALL macros into a new __COND_SYSCALL macro. Also conditionalize the X64 version in preparation for enabling syscall wrappers on 32-bit native kernels. Signed-off-by: Brian Gerst --- arch/x86/include/asm/syscall_wrapper.h | 44 +++++++++++++++----------- 1 file changed, 26 insertions(+), 18 deletions(-) diff --git a/arch/x86/include/asm/syscall_wrapper.h b/arch/x86/include/asm/syscall_wrapper.h index c13be057865f..781adf7f611f 100644 --- a/arch/x86/include/asm/syscall_wrapper.h +++ b/arch/x86/include/asm/syscall_wrapper.h @@ -35,6 +35,13 @@ struct pt_regs; return __se_##name(__VA_ARGS__); \ } +#define __COND_SYSCALL(abi, name) \ + asmlinkage __weak long \ + __##abi##_##name(const struct pt_regs *__unused) \ + { \ + return sys_ni_syscall(); \ + } + #ifdef CONFIG_X86_64 #define __X64_SYS_STUB0(sys_name) \ __SYS_STUB0(x64, sys_name) @@ -42,9 +49,13 @@ struct pt_regs; #define __X64_SYS_STUBx(x, sys_name, ...) \ __SYS_STUBx(x64, sys_name, \ SC_X86_64_REGS_TO_ARGS(x, __VA_ARGS__)) + +#define __X64_COND_SYSCALL(sys_name) \ + __COND_SYSCALL(x64, sys_name) #else /* CONFIG_X86_64 */ #define __X64_SYS_STUB0(sys_name) #define __X64_SYS_STUBx(x, sys_name, ...) +#define __X64_COND_SYSCALL(sys_name) #endif /* CONFIG_X86_64 */ #ifdef CONFIG_IA32_EMULATION @@ -63,6 +74,9 @@ struct pt_regs; __SYS_STUBx(ia32, compat_sys_name, \ SC_IA32_REGS_TO_ARGS(x, __VA_ARGS__)) +#define __IA32_COMPAT_COND_SYSCALL(compat_sys_name) \ + __COND_SYSCALL(ia32, compat_sys_name) + #define __IA32_SYS_STUB0(sys_name) \ __SYS_STUB0(ia32, sys_name) @@ -70,15 +84,8 @@ struct pt_regs; __SYS_STUBx(ia32, sys_name, \ SC_IA32_REGS_TO_ARGS(x, __VA_ARGS__)) -#define COND_SYSCALL(name) \ - asmlinkage __weak long __x64_sys_##name(const struct pt_regs *__unused) \ - { \ - return sys_ni_syscall(); \ - } \ - asmlinkage __weak long __ia32_sys_##name(const struct pt_regs *__unused)\ - { \ - return sys_ni_syscall(); \ - } +#define __IA32_COND_SYSCALL(sys_name) \ + __COND_SYSCALL(ia32, sys_name) #define SYS_NI(name) \ SYSCALL_ALIAS(__x64_sys_##name, sys_ni_posix_timers); \ @@ -87,8 +94,10 @@ struct pt_regs; #else /* CONFIG_IA32_EMULATION */ #define __IA32_COMPAT_SYS_STUB0(compat_sys_name) #define __IA32_COMPAT_SYS_STUBx(x, compat_sys_name, ...) +#define __IA32_COMPAT_COND_SYSCALL(compat_sys_name) #define __IA32_SYS_STUB0(sys_name) #define __IA32_SYS_STUBx(x, sys_name, ...) +#define __IA32_COND_SYSCALL(sys_name) #endif /* CONFIG_IA32_EMULATION */ @@ -105,9 +114,12 @@ struct pt_regs; __SYS_STUBx(x32, compat_sys_name, \ SC_X86_64_REGS_TO_ARGS(x, __VA_ARGS__)) +#define __X32_COMPAT_COND_SYSCALL(compat_sys_name) \ + __COND_SYSCALL(x32, compat_sys_name) #else /* CONFIG_X86_X32 */ #define __X32_COMPAT_SYS_STUB0(compat_sys_name) #define __X32_COMPAT_SYS_STUBx(x, compat_sys_name, ...) +#define __X32_COMPAT_COND_SYSCALL(compat_sys_name) #endif /* CONFIG_X86_X32 */ @@ -147,8 +159,8 @@ struct pt_regs; * kernel/time/posix-stubs.c to cover this case as well. */ #define COND_SYSCALL_COMPAT(name) \ - cond_syscall(__ia32_compat_sys_##name); \ - cond_syscall(__x32_compat_sys_##name) + __IA32_COMPAT_COND_SYSCALL(compat_sys_##name) \ + __X32_COMPAT_COND_SYSCALL(compat_sys_##name) #define COMPAT_SYS_NI(name) \ SYSCALL_ALIAS(__ia32_compat_sys_##name, sys_ni_posix_timers); \ @@ -220,13 +232,9 @@ struct pt_regs; static asmlinkage long \ __do_sys_##sname(const struct pt_regs *__unused) -#ifndef COND_SYSCALL -#define COND_SYSCALL(name) \ - asmlinkage __weak long __x64_sys_##name(const struct pt_regs *__unused) \ - { \ - return sys_ni_syscall(); \ - } -#endif +#define COND_SYSCALL(name) \ + __X64_COND_SYSCALL(sys_##name) \ + __IA32_COND_SYSCALL(sys_##name) #ifndef SYS_NI #define SYS_NI(name) SYSCALL_ALIAS(__x64_sys_##name, sys_ni_posix_timers); -- 2.24.1