Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp1916720ybb; Sat, 21 Mar 2020 08:33:16 -0700 (PDT) X-Google-Smtp-Source: ADFU+vtL5blnYFAI9sXRigm/PbCa6T184KroiXl+s7dlzg5ywzY1CQAB+cv7K2iCecUCsnfnAvYf X-Received: by 2002:a9d:2028:: with SMTP id n37mr11971145ota.127.1584804796208; Sat, 21 Mar 2020 08:33:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1584804796; cv=none; d=google.com; s=arc-20160816; b=MLDSGCzJYxzbrrUXcgM0YcNwfxXgwjI3vX8ZntNbPzosJtux2faM8ncfMzG11lQkLu vCpkdOnJB/eNP5cjE3Jyl+YNvCQFjT57zQ+ZvHNMtJIVhhEc/VbNKnEKou2wiR9cGeGq N8K3gQwDmewtMzmHrjUwQ4PF4oLqDvXL6pdTG0I67Qg0gqfExBWDuCJne2gpOVAjL7xG DU2sHckxCDRAbsh192T8bU+ZzdjjOJ7YUtuOZTgMvV1fYb/VsvNChkNsHgpuOiYtdV1p SmicOLQvrAViSdcywDm+oqwJg+vsUF729EFdetG+JrMUujQxRulAYsgWSUSNy/1FMPLv Va+Q== 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=z+/SdumSeAxsfbkB1RsIw74WFbPKlh/H8Kg8ineHOUM=; b=gNnN9HiBq2LDoiBMj3RC1OpqdNI6bUMU48LIMRz0ucoTnIjMyVcCNhsxpw9czgi/MR JMcmXZVJn0O1Ry/N5g3WpDHBVLaLjnX+QAzSXqft3Ztn7i8XaDay3CeHRyJQit6B2Eu9 2MbotoXn7554ZjpeLrSqirlAWcs2RXE1q2yjH7uPd+lUtA9ibUkbCTm+b9U3oF58QSBG IQ8R0Ergb542Uj+W0OrRGpD/mc4zN4BXhMDEsVC89EMnnUpEGY7LL1v2bdpflgCe3KTn /GV3qt4aH8GE2bXQDauL16XZeJHHcVHL8qQyYYy3yHLmzN2Rk9GN6awxStfbKWBB5TP/ Arbw== 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 x202si4070315oix.199.2020.03.21.08.33.03; Sat, 21 Mar 2020 08:33:16 -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 S1727995AbgCUPbX (ORCPT + 99 others); Sat, 21 Mar 2020 11:31:23 -0400 Received: from Galois.linutronix.de ([193.142.43.55]:38902 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727630AbgCUPak (ORCPT ); Sat, 21 Mar 2020 11:30:40 -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 1jFg56-00050i-OI; Sat, 21 Mar 2020 16:30:36 +0100 Received: from [127.0.1.1] (localhost [IPv6:::1]) by tip-bot2.lab.linutronix.de (Postfix) with ESMTP id 3E83E1C22E4; Sat, 21 Mar 2020 16:30:36 +0100 (CET) Date: Sat, 21 Mar 2020 15:30:35 -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: Move max syscall number calculation to syscallhdr.sh Cc: Brian Gerst , Thomas Gleixner , x86 , LKML In-Reply-To: <20200313195144.164260-9-brgerst@gmail.com> References: <20200313195144.164260-9-brgerst@gmail.com> MIME-Version: 1.0 Message-ID: <158480463590.28353.3002123379230133878.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: 0872098804b5f44bab91f80b6df55df32894fee3 Gitweb: https://git.kernel.org/tip/0872098804b5f44bab91f80b6df55df32894fee3 Author: Brian Gerst AuthorDate: Fri, 13 Mar 2020 15:51:34 -04:00 Committer: Thomas Gleixner CommitterDate: Sat, 21 Mar 2020 16:03:21 +01:00 x86/entry: Move max syscall number calculation to syscallhdr.sh Instead of using an array in asm-offsets to calculate the max syscall number, calculate it when writing out the syscall headers. Signed-off-by: Brian Gerst Signed-off-by: Thomas Gleixner Link: https://lkml.kernel.org/r/20200313195144.164260-9-brgerst@gmail.com --- arch/x86/entry/syscall_32.c | 6 +-- arch/x86/entry/syscall_64.c | 2 +- arch/x86/entry/syscall_x32.c | 6 +-- arch/x86/entry/syscalls/syscallhdr.sh | 7 ++++- arch/x86/entry/vdso/vdso32/vclock_gettime.c | 1 +- arch/x86/include/asm/syscall.h | 3 +-- arch/x86/include/asm/unistd.h | 7 ++++- arch/x86/kernel/asm-offsets_32.c | 9 +----- arch/x86/kernel/asm-offsets_64.c | 36 +-------------------- arch/x86/um/sys_call_table_32.c | 2 +- arch/x86/um/sys_call_table_64.c | 2 +- arch/x86/um/user-offsets.c | 15 +-------- 12 files changed, 24 insertions(+), 72 deletions(-) diff --git a/arch/x86/entry/syscall_32.c b/arch/x86/entry/syscall_32.c index 7d17b3a..3207cf6 100644 --- a/arch/x86/entry/syscall_32.c +++ b/arch/x86/entry/syscall_32.c @@ -4,7 +4,7 @@ #include #include #include -#include +#include #include #ifdef CONFIG_IA32_EMULATION @@ -22,11 +22,11 @@ extern asmlinkage long sys_ni_syscall(unsigned long, unsigned long, unsigned lon #define __SYSCALL_I386(nr, sym, qual) [nr] = sym, -__visible const sys_call_ptr_t ia32_sys_call_table[__NR_syscall_compat_max+1] = { +__visible const sys_call_ptr_t ia32_sys_call_table[__NR_ia32_syscall_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_ia32_syscall_max] = &__sys_ni_syscall, #include }; diff --git a/arch/x86/entry/syscall_64.c b/arch/x86/entry/syscall_64.c index efb85c6..5dc6846 100644 --- a/arch/x86/entry/syscall_64.c +++ b/arch/x86/entry/syscall_64.c @@ -5,7 +5,7 @@ #include #include #include -#include +#include #include #define __SYSCALL_X32(nr, sym, qual) diff --git a/arch/x86/entry/syscall_x32.c b/arch/x86/entry/syscall_x32.c index d144ced..95abb6d 100644 --- a/arch/x86/entry/syscall_x32.c +++ b/arch/x86/entry/syscall_x32.c @@ -5,7 +5,7 @@ #include #include #include -#include +#include #include #define __SYSCALL_64(nr, sym, qual) @@ -16,11 +16,11 @@ #define __SYSCALL_X32(nr, sym, qual) [nr] = sym, -asmlinkage const sys_call_ptr_t x32_sys_call_table[__NR_syscall_x32_max+1] = { +asmlinkage const sys_call_ptr_t x32_sys_call_table[__NR_x32_syscall_max+1] = { /* * Smells like a compiler bug -- it doesn't work * when the & below is removed. */ - [0 ... __NR_syscall_x32_max] = &__x64_sys_ni_syscall, + [0 ... __NR_x32_syscall_max] = &__x64_sys_ni_syscall, #include }; diff --git a/arch/x86/entry/syscalls/syscallhdr.sh b/arch/x86/entry/syscalls/syscallhdr.sh index 12fbbcf..cc1e638 100644 --- a/arch/x86/entry/syscalls/syscallhdr.sh +++ b/arch/x86/entry/syscalls/syscallhdr.sh @@ -15,14 +15,21 @@ grep -E "^[0-9A-Fa-fXx]+[[:space:]]+${my_abis}" "$in" | sort -n | ( echo "#define ${fileguard} 1" echo "" + max=0 while read nr abi name entry ; do if [ -z "$offset" ]; then echo "#define __NR_${prefix}${name} $nr" else echo "#define __NR_${prefix}${name} ($offset + $nr)" fi + + max=$nr done echo "" + echo "#ifdef __KERNEL__" + echo "#define __NR_${prefix}syscall_max $max" + echo "#endif" + echo "" echo "#endif /* ${fileguard} */" ) > "$out" diff --git a/arch/x86/entry/vdso/vdso32/vclock_gettime.c b/arch/x86/entry/vdso/vdso32/vclock_gettime.c index 9242b28..1e82bd4 100644 --- a/arch/x86/entry/vdso/vdso32/vclock_gettime.c +++ b/arch/x86/entry/vdso/vdso32/vclock_gettime.c @@ -13,6 +13,7 @@ */ #undef CONFIG_64BIT #undef CONFIG_X86_64 +#undef CONFIG_COMPAT #undef CONFIG_PGTABLE_LEVELS #undef CONFIG_ILLEGAL_POINTER_VALUE #undef CONFIG_SPARSEMEM_VMEMMAP diff --git a/arch/x86/include/asm/syscall.h b/arch/x86/include/asm/syscall.h index 8db3fdb..1ef8d7b 100644 --- a/arch/x86/include/asm/syscall.h +++ b/arch/x86/include/asm/syscall.h @@ -13,7 +13,6 @@ #include #include #include -#include /* For NR_syscalls */ #include /* for TS_COMPAT */ #include @@ -28,8 +27,6 @@ extern const sys_call_ptr_t sys_call_table[]; #if defined(CONFIG_X86_32) #define ia32_sys_call_table sys_call_table -#define __NR_syscall_compat_max __NR_syscall_max -#define IA32_NR_syscalls NR_syscalls #endif #if defined(CONFIG_IA32_EMULATION) diff --git a/arch/x86/include/asm/unistd.h b/arch/x86/include/asm/unistd.h index a7dd080..c1c3d31 100644 --- a/arch/x86/include/asm/unistd.h +++ b/arch/x86/include/asm/unistd.h @@ -13,10 +13,13 @@ # define __ARCH_WANT_SYS_OLD_MMAP # define __ARCH_WANT_SYS_OLD_SELECT +# define __NR_ia32_syscall_max __NR_syscall_max + # else # include # include +# include # define __ARCH_WANT_SYS_TIME # define __ARCH_WANT_SYS_UTIME # define __ARCH_WANT_COMPAT_SYS_PREADV64 @@ -26,6 +29,10 @@ # endif +# define NR_syscalls (__NR_syscall_max + 1) +# define X32_NR_syscalls (__NR_x32_syscall_max + 1) +# define IA32_NR_syscalls (__NR_ia32_syscall_max + 1) + # define __ARCH_WANT_NEW_STAT # define __ARCH_WANT_OLD_READDIR # define __ARCH_WANT_OLD_STAT diff --git a/arch/x86/kernel/asm-offsets_32.c b/arch/x86/kernel/asm-offsets_32.c index 82826f2..0dcac42 100644 --- a/arch/x86/kernel/asm-offsets_32.c +++ b/arch/x86/kernel/asm-offsets_32.c @@ -5,11 +5,6 @@ #include -#define __SYSCALL_I386(nr, sym, qual) [nr] = 1, -static char syscalls[] = { -#include -}; - /* workaround for a warning with -Wmissing-prototypes */ void foo(void); @@ -60,8 +55,4 @@ void foo(void) BLANK(); OFFSET(stack_canary_offset, stack_canary, canary); #endif - - BLANK(); - DEFINE(__NR_syscall_max, sizeof(syscalls) - 1); - DEFINE(NR_syscalls, sizeof(syscalls)); } diff --git a/arch/x86/kernel/asm-offsets_64.c b/arch/x86/kernel/asm-offsets_64.c index 24d2fde..c2a4701 100644 --- a/arch/x86/kernel/asm-offsets_64.c +++ b/arch/x86/kernel/asm-offsets_64.c @@ -5,30 +5,6 @@ #include -#define __SYSCALL_64(nr, sym, qual) [nr] = 1, -#define __SYSCALL_X32(nr, sym, qual) -static char syscalls_64[] = { -#include -}; -#undef __SYSCALL_64 -#undef __SYSCALL_X32 - -#ifdef CONFIG_X86_X32_ABI -#define __SYSCALL_64(nr, sym, qual) -#define __SYSCALL_X32(nr, sym, qual) [nr] = 1, -static char syscalls_x32[] = { -#include -}; -#undef __SYSCALL_64 -#undef __SYSCALL_X32 -#endif - -#define __SYSCALL_I386(nr, sym, qual) [nr] = 1, -static char syscalls_ia32[] = { -#include -}; -#undef __SYSCALL_I386 - #if defined(CONFIG_KVM_GUEST) && defined(CONFIG_PARAVIRT_SPINLOCKS) #include #endif @@ -90,17 +66,5 @@ int main(void) DEFINE(stack_canary_offset, offsetof(struct fixed_percpu_data, stack_canary)); BLANK(); #endif - - DEFINE(__NR_syscall_max, sizeof(syscalls_64) - 1); - DEFINE(NR_syscalls, sizeof(syscalls_64)); - -#ifdef CONFIG_X86_X32_ABI - DEFINE(__NR_syscall_x32_max, sizeof(syscalls_x32) - 1); - DEFINE(X32_NR_syscalls, sizeof(syscalls_x32)); -#endif - - DEFINE(__NR_syscall_compat_max, sizeof(syscalls_ia32) - 1); - DEFINE(IA32_NR_syscalls, sizeof(syscalls_ia32)); - return 0; } diff --git a/arch/x86/um/sys_call_table_32.c b/arch/x86/um/sys_call_table_32.c index 9649b5a..a0d75c5 100644 --- a/arch/x86/um/sys_call_table_32.c +++ b/arch/x86/um/sys_call_table_32.c @@ -7,7 +7,7 @@ #include #include #include -#include +#include #include #define __NO_STUBS diff --git a/arch/x86/um/sys_call_table_64.c b/arch/x86/um/sys_call_table_64.c index c8bc7fb..fa97740 100644 --- a/arch/x86/um/sys_call_table_64.c +++ b/arch/x86/um/sys_call_table_64.c @@ -7,7 +7,7 @@ #include #include #include -#include +#include #include #define __NO_STUBS diff --git a/arch/x86/um/user-offsets.c b/arch/x86/um/user-offsets.c index 5b37b7f..c51dd83 100644 --- a/arch/x86/um/user-offsets.c +++ b/arch/x86/um/user-offsets.c @@ -9,18 +9,6 @@ #include #include -#ifdef __i386__ -#define __SYSCALL_I386(nr, sym, qual) [nr] = 1, -static char syscalls[] = { -#include -}; -#else -#define __SYSCALL_64(nr, sym, qual) [nr] = 1, -static char syscalls[] = { -#include -}; -#endif - #define DEFINE(sym, val) \ asm volatile("\n->" #sym " %0 " #val : : "i" (val)) @@ -94,7 +82,4 @@ void foo(void) DEFINE(UM_PROT_READ, PROT_READ); DEFINE(UM_PROT_WRITE, PROT_WRITE); DEFINE(UM_PROT_EXEC, PROT_EXEC); - - DEFINE(__NR_syscall_max, sizeof(syscalls) - 1); - DEFINE(NR_syscalls, sizeof(syscalls)); }