From patchwork Mon Sep 25 22:35:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhangjin Wu X-Patchwork-Id: 13398519 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8033BE6FE31 for ; Mon, 25 Sep 2023 22:35:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232973AbjIYWfc (ORCPT ); Mon, 25 Sep 2023 18:35:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49482 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232992AbjIYWfb (ORCPT ); Mon, 25 Sep 2023 18:35:31 -0400 Received: from bg4.exmail.qq.com (bg4.exmail.qq.com [43.155.65.254]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4F8E1192; Mon, 25 Sep 2023 15:35:24 -0700 (PDT) X-QQ-mid: bizesmtp69t1695681314trhnno76 Received: from linux-lab-host.localdomain ( [116.30.124.152]) by bizesmtp.qq.com (ESMTP) with id ; Tue, 26 Sep 2023 06:35:13 +0800 (CST) X-QQ-SSF: 01200000002000E0Y000B00A0000000 X-QQ-FEAT: 5q30pvLz2ifym5SLIzsh144Znm6wRlu+bPV0w9peTQtfsIPVYY0hXdp41PdCD qNzUX3VU0ZbZvFxqzdl781ox5Wff3pzWuKKNI6Te1Y8Odq1dErSA2qLbFA/SMI2cKUrzOVs JqSkwphfZ1OdgeG+SXhsqzaC3EdPtZ01WiX3xWijTjjHsIaAgg69GAJkp+9VvBK+LXtqy1j nrLN7pG00O3beVVn6nNJXOacEGL+QVJsdzrevmusz0g8QdKt9Gmkrc6JmfWCThmyuCXGiVh gjxq5yWAioV+s2WgKuEpfsGOozhlcqRN+oC8EBu5Z9jN5LH+6xf8e1VBtfxSu4YLC8kyaQi XdE5S4RGw+7MohBQiYCuUk9wCwPZJByKg1RLiR97lDnE03vxkhVdJMeJFQ4NQ== X-QQ-GoodBg: 0 X-BIZMAIL-ID: 1656431424344420643 From: Zhangjin Wu To: linux-kernel@vger.kernel.org, linux-mips@vger.kernel.org, linux-riscv@lists.infradead.org, Arnd Bergmann Cc: falcon@tinylab.org, palmer@rivosinc.com, paul.walmsley@sifive.com, paulburton@kernel.org, paulmck@kernel.org, tsbogend@alpha.franken.de, w@1wt.eu, =?utf-8?q?Thomas_Wei=C3=9Fschuh?= , Tim Bird Subject: [PATCH v1 1/7] DCE: add debug support Date: Tue, 26 Sep 2023 06:35:11 +0800 Message-Id: <36d7ee5122e3a9c2b307cf6ab1a9508860fd7710.1695679700.git.falcon@tinylab.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 X-QQ-SENDSIZE: 520 Feedback-ID: bizesmtp:tinylab.org:qybglogicsvrgz:qybglogicsvrgz5a-1 Precedence: bulk List-ID: X-Mailing-List: linux-mips@vger.kernel.org Enable --print-gc-sections for --gc-sections to monitor which sections are really eliminated. Signed-off-by: Zhangjin Wu --- Makefile | 3 +++ init/Kconfig | 7 +++++++ 2 files changed, 10 insertions(+) diff --git a/Makefile b/Makefile index 57698d048e2c..a4e522b747cb 100644 --- a/Makefile +++ b/Makefile @@ -938,6 +938,9 @@ ifdef CONFIG_LD_DEAD_CODE_DATA_ELIMINATION KBUILD_CFLAGS_KERNEL += -ffunction-sections -fdata-sections KBUILD_RUSTFLAGS_KERNEL += -Zfunction-sections=y LDFLAGS_vmlinux += --gc-sections +ifdef CONFIG_LD_DEAD_CODE_DATA_ELIMINATION_DEBUG +LDFLAGS_vmlinux += --print-gc-sections +endif endif ifdef CONFIG_SHADOW_CALL_STACK diff --git a/init/Kconfig b/init/Kconfig index 6d35728b94b2..4350d8ba7db4 100644 --- a/init/Kconfig +++ b/init/Kconfig @@ -1404,6 +1404,13 @@ config LD_DEAD_CODE_DATA_ELIMINATION present. This option is not well tested yet, so use at your own risk. +config LD_DEAD_CODE_DATA_ELIMINATION_DEBUG + bool "Debug dead code and data elimination (EXPERIMENTAL)" + depends on LD_DEAD_CODE_DATA_ELIMINATION + default n + help + Enable --print-gc-sections for --gc-sections + config LD_ORPHAN_WARN def_bool y depends on ARCH_WANT_LD_ORPHAN_WARN From patchwork Mon Sep 25 22:36:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhangjin Wu X-Patchwork-Id: 13398520 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id AEF15CE79A7 for ; Mon, 25 Sep 2023 22:36:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229509AbjIYWgq (ORCPT ); Mon, 25 Sep 2023 18:36:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40556 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233263AbjIYWgo (ORCPT ); Mon, 25 Sep 2023 18:36:44 -0400 Received: from bg4.exmail.qq.com (bg4.exmail.qq.com [43.154.54.12]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D8EE91BF; Mon, 25 Sep 2023 15:36:34 -0700 (PDT) X-QQ-mid: bizesmtp66t1695681384tmochcm2 Received: from linux-lab-host.localdomain ( [116.30.124.152]) by bizesmtp.qq.com (ESMTP) with id ; Tue, 26 Sep 2023 06:36:22 +0800 (CST) X-QQ-SSF: 01200000002000E0Y000B00A0000000 X-QQ-FEAT: TVZM0Uoyj00JUk8OvUcLIPa/EY8r7PpEQ1C4lcN0OuATw0N34N96kW+oYTtBN Jaai4dDH6wtD7ZkDRGpxrDXJs8kGC6i0K1xINYbt7WEradLvwu7MjA6BcfUnB7FQ28vLUNE oQHy3mNLduqnMVzzsi6WBKxgK0AAM3INML+mLcNbhvWg2TzhqPZTKPUYjS11nZRjvZcUiuD NRW/R54I/WUXENzteFZ23F0t6lmXK5Gg+8WdV//S+i7xLiuIrZryziyd/4peU2qgsix+rev 4q/4iJniLeeMCnq1PbhyWM3hk3jVoJGyF2rmv3i3bq3HesUqB4dLD5mRubDvLJZ1TV80lce ETiR3coFd9RGXByeptpmtL7fTDNYSIbW6nDutyAuvYsEvMnBnNwa0HvNQHDPey2/Yz4tq+W X-QQ-GoodBg: 0 X-BIZMAIL-ID: 16786486805464770233 From: Zhangjin Wu To: linux-kernel@vger.kernel.org, linux-mips@vger.kernel.org, linux-riscv@lists.infradead.org, Arnd Bergmann Cc: falcon@tinylab.org, palmer@rivosinc.com, paul.walmsley@sifive.com, paulburton@kernel.org, paulmck@kernel.org, tsbogend@alpha.franken.de, w@1wt.eu, =?utf-8?q?Thomas_Wei=C3=9Fschuh?= , Tim Bird Subject: [PATCH v1 2/7] DCE/DSE: add unused syscalls elimination configure support Date: Tue, 26 Sep 2023 06:36:21 +0800 Message-Id: <3f0eaf5fcb19f1c70cab075a97f067846f36f736.1695679700.git.falcon@tinylab.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 X-QQ-SENDSIZE: 520 Feedback-ID: bizesmtp:tinylab.org:qybglogicsvrgz:qybglogicsvrgz5a-1 Precedence: bulk List-ID: X-Mailing-List: linux-mips@vger.kernel.org A minimal embedded Linux system may only has a very few of functions and only uses a minimal subset of the posix syscalls, the unused syscalls will never be used and eventually in a dead status, that also means disk storage and memory footprint waste. Based on dead code elimination support, it is able to further eliminate the above dead or unused syscalls. Firstly, both a new common CONFIG_TRIM_UNUSED_SYSCALLS option and a new architecture specific HAVE_TRIM_UNUSED_SYSCALLS are added to enable or disable such feature. Secondly, a new CONFIG_USED_SYSCALLS option is added to allow configure the syscalls used in a target system. CONFIG_USED_SYSCALLS can be a list of the used syscalls or a file to store such a list. Based on the above options, it is able to only reserve the used syscalls and let CONFIG_LD_DEAD_CODE_DATA_ELIMINATION trim the unused ones for us automatically. Signed-off-by: Zhangjin Wu --- init/Kconfig | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/init/Kconfig b/init/Kconfig index 4350d8ba7db4..aa648ce8bca1 100644 --- a/init/Kconfig +++ b/init/Kconfig @@ -1457,6 +1457,11 @@ config BPF bool select CRYPTO_LIB_SHA1 +config HAVE_TRIM_UNUSED_SYSCALLS + bool + depends on HAVE_LD_DEAD_CODE_DATA_ELIMINATION + default n + menuconfig EXPERT bool "Configure standard kernel features (expert users)" # Unhide debug options, to make the on-by-default options visible @@ -1683,6 +1688,43 @@ config MEMBARRIER If unsure, say Y. +config TRIM_UNUSED_SYSCALLS + bool "Trim unused syscalls (EXPERIMENTAL)" if EXPERT + default n + depends on HAVE_TRIM_UNUSED_SYSCALLS + depends on HAVE_LD_DEAD_CODE_DATA_ELIMINATION + select LD_DEAD_CODE_DATA_ELIMINATION + help + Say Y here to trim all of the unused syscalls for a target system. + + Note, this is only for minimal embedded systems, please don't use it + for generic Linux distributions. + + If unsure, say N. + +config USED_SYSCALLS + string "Configure used syscalls (EXPERIMENTAL)" if EXPERT + depends on TRIM_UNUSED_SYSCALLS + default "" + help + This option allows to configure the syscalls used in a target system, + the unused ones will be disabled and trimmed by TRIM_UNUSED_SYSCALLS. + + The used syscalls should be listed one by one like this: + + write exit reboot + + Or put them into a file specified by this option, one syscall per + line is recommended for such a config file: + + write + exit + reboot + + Note, If keep this empty, all of the syscalls will be trimmed. + + If unsure, please disable TRIM_UNUSED_SYSCALLS. + config KALLSYMS bool "Load all symbols for debugging/ksymoops" if EXPERT default y From patchwork Mon Sep 25 22:38:56 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhangjin Wu X-Patchwork-Id: 13398524 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C70BAE6FE31 for ; Mon, 25 Sep 2023 22:39:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229882AbjIYWjT (ORCPT ); Mon, 25 Sep 2023 18:39:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42582 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229585AbjIYWjT (ORCPT ); Mon, 25 Sep 2023 18:39:19 -0400 Received: from bg4.exmail.qq.com (bg4.exmail.qq.com [43.154.54.12]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F0EBB9C; Mon, 25 Sep 2023 15:39:11 -0700 (PDT) X-QQ-mid: bizesmtp62t1695681542tdrh3qq7 Received: from linux-lab-host.localdomain ( [116.30.124.152]) by bizesmtp.qq.com (ESMTP) with id ; Tue, 26 Sep 2023 06:38:56 +0800 (CST) X-QQ-SSF: 01200000002000E0Y000B00A0000000 X-QQ-FEAT: SFhf6fKhx//PtbsvyVYEL/gCYQ5xMD8J6LwaCKhulpVEfmJppGRkMmjMj3Bxv 8wdytKPzLVFJlPA82FjC2Ti02tsIHXGhP+Tb7KY7NXZeQX14PHTRUwY1uNtWxj7nVvdw5N8 ypB+bBYPZTiHwLTOfPVZ2o3kvUQu/slgqaqTTvxwiXKKuRoubwr8vyOsZC+zpBmOn8ghMQm AG5bLu8EeQJF77jcZcCDh8tBPzUgxyBcq+ybkOO584JaaHxdkRqP9QMqdLVLQkwKUzkpjRx 8jfcH0gidHmiUdV76m98gNAlJ0swOV9yXGIUaa85PdpJ4c+AiLAPLqrLnY0hvGmFDffugib /YpU8n7ZB5APg72lHoVQhLN1V/LOaRguiP/XLXevf0Z/Nx5UZypKAyBjtff2CMVyBvswmd1 X-QQ-GoodBg: 0 X-BIZMAIL-ID: 11640928319628299727 From: Zhangjin Wu To: linux-kernel@vger.kernel.org, linux-mips@vger.kernel.org, linux-riscv@lists.infradead.org, Arnd Bergmann Cc: falcon@tinylab.org, palmer@rivosinc.com, paul.walmsley@sifive.com, paulburton@kernel.org, paulmck@kernel.org, tsbogend@alpha.franken.de, w@1wt.eu, =?utf-8?q?Thomas_Wei=C3=9Fschuh?= , Tim Bird Subject: [PATCH v1 3/7] DCE/DSE: Add a new scripts/Makefile.syscalls Date: Tue, 26 Sep 2023 06:38:56 +0800 Message-Id: X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 X-QQ-SENDSIZE: 520 Feedback-ID: bizesmtp:tinylab.org:qybglogicsvrgz:qybglogicsvrgz5a-1 Precedence: bulk List-ID: X-Mailing-List: linux-mips@vger.kernel.org When CONFIG_TRIM_UNUSED_SYSCALLS is enabled, get used syscalls from CONFIG_USED_SYSCALLS. CONFIG_USED_SYSCALLS may be a list of used syscalls or a file to store such a list. If CONFIG_USED_SYSCALLS is configured as a list of the used syscalls, directly record them in a used_syscalls variable, if it is a file to store the list, record the file name to the used_syscalls_file variable and put its content to the used_syscalls variable. Signed-off-by: Zhangjin Wu --- scripts/Makefile.syscalls | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 scripts/Makefile.syscalls diff --git a/scripts/Makefile.syscalls b/scripts/Makefile.syscalls new file mode 100644 index 000000000000..5864d3a85996 --- /dev/null +++ b/scripts/Makefile.syscalls @@ -0,0 +1,29 @@ +# SPDX-License-Identifier: GPL-2.0 + +ifndef SCRIPTS_MAKEFILE_SYSCALLS + SCRIPTS_MAKEFILE_SYSCALLS = 1 + + ifdef CONFIG_TRIM_UNUSED_SYSCALLS + ifneq ($(wildcard $(CONFIG_USED_SYSCALLS)),) + used_syscalls_file = $(CONFIG_USED_SYSCALLS) + ifeq ($(shell test -s $(used_syscalls_file); echo $$?),0) + used_syscalls != cat $(CONFIG_USED_SYSCALLS) + endif + else + ifeq ($(subst /,,$(CONFIG_USED_SYSCALLS)),$(CONFIG_USED_SYSCALLS)) + used_syscalls = $(CONFIG_USED_SYSCALLS) + else + $(error No such file: $(CONFIG_USED_SYSCALLS)) + endif + endif + + ifneq ($(used_syscalls),) + used_syscalls := $(subst $(space),|,$(strip $(used_syscalls))) + endif + + used_syscalls_deps = $(used_syscalls_file) $(objtree)/.config + + export used_syscalls used_syscalls_deps + endif # CONFIG_TRIM_UNUSED_SYSCALLS + +endif # SCRIPTS_MAKEFILE_SYSCALLS From patchwork Mon Sep 25 22:40:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhangjin Wu X-Patchwork-Id: 13398525 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B9720CE79A7 for ; Mon, 25 Sep 2023 22:40:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229882AbjIYWke (ORCPT ); Mon, 25 Sep 2023 18:40:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49580 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229585AbjIYWkd (ORCPT ); Mon, 25 Sep 2023 18:40:33 -0400 Received: from bg4.exmail.qq.com (bg4.exmail.qq.com [43.155.65.254]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5C9F411C; Mon, 25 Sep 2023 15:40:26 -0700 (PDT) X-QQ-mid: bizesmtp71t1695681610tqhm377b Received: from linux-lab-host.localdomain ( [116.30.124.152]) by bizesmtp.qq.com (ESMTP) with id ; Tue, 26 Sep 2023 06:40:09 +0800 (CST) X-QQ-SSF: 01200000002000E0Y000B00A0000000 X-QQ-FEAT: ILHsT53NKPin+kzqQGfU4qqx5molDA0iqJ3SZWTXpJi8+ENQI9pVCgAqlBSkC SjaN45XpIk1N9BymYSuAA4tz+X2z3zeBDA68WsFY96RT+Gd5cHXvtB6jom5TT127giJhM/5 NYjRyHFFjFr7/hKz8hqmz7lUIJCz8p8INNxMNWVVYxrjS0fuOZ5lBCOitOCifwkKQ2qkq/I nFPp5yuzK7Fnnkzj05IDOOvyimA3DAoPmo/UDJuESVDQxMoEe1bta55YWtBEQh2u0eRdKYa CcWdvrTVxLfhg/EvuGTLSB6+7PHrTRo028EKuirSNFGWhIltAikvPVrYhLU+GAeDrJileEI B81pLKgvY0EFjP/WeutX5VCs8Rl7koPFER6fhRF5u0+6q2v/AytMFxAeFoecYN84j7q+8BB X-QQ-GoodBg: 0 X-BIZMAIL-ID: 17594093605146210017 From: Zhangjin Wu To: linux-kernel@vger.kernel.org, linux-mips@vger.kernel.org, linux-riscv@lists.infradead.org, Arnd Bergmann Cc: falcon@tinylab.org, palmer@rivosinc.com, paul.walmsley@sifive.com, paulburton@kernel.org, paulmck@kernel.org, tsbogend@alpha.franken.de, w@1wt.eu, =?utf-8?q?Thomas_Wei=C3=9Fschuh?= , Tim Bird Subject: [PATCH v1 4/7] DCE/DSE: mips: add HAVE_TRIM_UNUSED_SYSCALLS support Date: Tue, 26 Sep 2023 06:40:08 +0800 Message-Id: <3042b32a13aecbf8f3c8bedee34a4ca8c7d7cb2e.1695679700.git.falcon@tinylab.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 X-QQ-SENDSIZE: 520 Feedback-ID: bizesmtp:tinylab.org:qybglogicsvrgz:qybglogicsvrgz5a-1 Precedence: bulk List-ID: X-Mailing-List: linux-mips@vger.kernel.org For HAVE_TRIM_UNUSED_SYSCALLS, the syscall tables are hacked with the input used syscalls. Based on the used syscalls information, a new version of tbl file is generated from the original tbl file and named with a 'used' suffix. With this new tbl file, both unistd_nr_*.h and syscall_table_*.h files are updated to only include the used syscalls. $ grep _Linux_syscalls -ur arch/mips/include/generated/asm/ arch/mips/include/generated/asm/unistd_nr_n64.h:#define __NR_64_Linux_syscalls 165 arch/mips/include/generated/asm/unistd_nr_n32.h:#define __NR_N32_Linux_syscalls 165 arch/mips/include/generated/asm/unistd_nr_o32.h:#define __NR_O32_Linux_syscalls 89 $ grep -vr sys_ni_syscall arch/mips/include/generated/asm/syscall_table_*.h arch/mips/include/generated/asm/syscall_table_n32.h:__SYSCALL(58, sys_exit) arch/mips/include/generated/asm/syscall_table_n32.h:__SYSCALL(164, sys_reboot) arch/mips/include/generated/asm/syscall_table_n64.h:__SYSCALL(58, sys_exit) arch/mips/include/generated/asm/syscall_table_n64.h:__SYSCALL(164, sys_reboot) arch/mips/include/generated/asm/syscall_table_o32.h:__SYSCALL(1, sys_exit) arch/mips/include/generated/asm/syscall_table_o32.h:__SYSCALL(88, sys_reboot) Signed-off-by: Zhangjin Wu --- arch/mips/Kconfig | 1 + arch/mips/kernel/syscalls/Makefile | 23 +++++++++++++++++++++-- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig index bc8421859006..8a6927eff23d 100644 --- a/arch/mips/Kconfig +++ b/arch/mips/Kconfig @@ -89,6 +89,7 @@ config MIPS select HAVE_SPARSE_SYSCALL_NR select HAVE_STACKPROTECTOR select HAVE_SYSCALL_TRACEPOINTS + select HAVE_TRIM_UNUSED_SYSCALLS if HAVE_LD_DEAD_CODE_DATA_ELIMINATION select HAVE_VIRT_CPU_ACCOUNTING_GEN if 64BIT || !SMP select IRQ_FORCED_THREADING select ISA if EISA diff --git a/arch/mips/kernel/syscalls/Makefile b/arch/mips/kernel/syscalls/Makefile index e6b21de65cca..1e292a9f84a0 100644 --- a/arch/mips/kernel/syscalls/Makefile +++ b/arch/mips/kernel/syscalls/Makefile @@ -26,10 +26,29 @@ sysnr_pfx_unistd_nr_n32 := N32 sysnr_pfx_unistd_nr_n64 := 64 sysnr_pfx_unistd_nr_o32 := O32 -$(kapi)/unistd_nr_%.h: $(src)/syscall_%.tbl $(sysnr) FORCE +ifndef CONFIG_TRIM_UNUSED_SYSCALLS +tbl = $(src)/syscall_%.tbl +else + +include $(srctree)/scripts/Makefile.syscalls + +orig_tbl = $(src)/syscall_%.tbl + tbl_dir = arch/$(SRCARCH)/include/generated/tbl + tbl = $(tbl_dir)/syscall_used_%.tbl + +quiet_cmd_used = USED $@ + cmd_used = sed -E -e "/^[0-9]*[[:space:]]/{/(^($(used_syscalls))[[:space:]]|[[:space:]]($(used_syscalls))[[:space:]]|[[:space:]]($(used_syscalls))$$)/!{s/^/\#/g}}" $< > $@; + +$(tbl): $(orig_tbl) $(used_syscalls_deps) FORCE + $(Q)mkdir -p $(tbl_dir) + $(call cmd,used) + +endif + +$(kapi)/unistd_nr_%.h: $(tbl) $(sysnr) FORCE $(call if_changed,sysnr) -$(kapi)/syscall_table_%.h: $(src)/syscall_%.tbl $(systbl) FORCE +$(kapi)/syscall_table_%.h: $(tbl) $(systbl) FORCE $(call if_changed,systbl) uapisyshdr-y += unistd_n32.h \ From patchwork Mon Sep 25 22:41:16 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhangjin Wu X-Patchwork-Id: 13398526 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 13049E6FE31 for ; Mon, 25 Sep 2023 22:41:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229585AbjIYWlj (ORCPT ); Mon, 25 Sep 2023 18:41:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33964 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229481AbjIYWli (ORCPT ); Mon, 25 Sep 2023 18:41:38 -0400 Received: from bg4.exmail.qq.com (bg4.exmail.qq.com [43.155.65.254]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A4F8111C; Mon, 25 Sep 2023 15:41:31 -0700 (PDT) X-QQ-mid: bizesmtp64t1695681678tnvf3nwx Received: from linux-lab-host.localdomain ( [116.30.124.152]) by bizesmtp.qq.com (ESMTP) with id ; Tue, 26 Sep 2023 06:41:16 +0800 (CST) X-QQ-SSF: 01200000002000E0Y000B00A0000000 X-QQ-FEAT: 3M0okmaRx3gfsSflpNrVeZ3sLICSqSaF1U3sraXTLgAlViLSauDfSqqDtpoNW SpJ9yhtzh6PzBUapWeOX0uRrrOAx/YDjuGcAV/ElqISXdLVJrgKYLDHpCpA9o8pTr1UJmAp TZpLJKkg5BgsLqXJA7AyPqGQd4uo4wJ9kG/PcrwaYQDKWoXQAHmyI48DbJyB9TrgDn6MwV1 xAbDs/bktubgubuWpp3z5BZzxdTfsdxIyMEd653QAHjXk0VSw0QgkTt/ZwID4tddHr20MU5 IBenNgCrBRJGf1SYzfyD/v+sJ8AofWpCIgALXUucwYI6Z1XoKE8OaZJ5OVSdOUqOPo7jhE0 8L83kEBlrjALbS9Xe1VQFAawPyge85zIGnGGzgYOddDAkAAqjslJdveiZm9lYGNaojrQbrE X-QQ-GoodBg: 0 X-BIZMAIL-ID: 2541803507469492191 From: Zhangjin Wu To: linux-kernel@vger.kernel.org, linux-mips@vger.kernel.org, linux-riscv@lists.infradead.org, Arnd Bergmann Cc: falcon@tinylab.org, palmer@rivosinc.com, paul.walmsley@sifive.com, paulburton@kernel.org, paulmck@kernel.org, tsbogend@alpha.franken.de, w@1wt.eu, =?utf-8?q?Thomas_Wei=C3=9Fschuh?= , Tim Bird Subject: [PATCH v1 5/7] DCE/DSE: riscv: move syscall tables to syscalls/ Date: Tue, 26 Sep 2023 06:41:16 +0800 Message-Id: X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 X-QQ-SENDSIZE: 520 Feedback-ID: bizesmtp:tinylab.org:qybglogicsvrgz:qybglogicsvrgz5a-1 Precedence: bulk List-ID: X-Mailing-List: linux-mips@vger.kernel.org Both syscall table and compat syscall table share some dead syscalls elimination code, to avoid cluttering the main RISC-V kernel Makefile, let's move these tables and the corresponding compile settings to syscalls/. Signed-off-by: Zhangjin Wu --- arch/riscv/kernel/Makefile | 5 +---- arch/riscv/kernel/syscalls/Makefile | 10 ++++++++++ .../riscv/kernel/{ => syscalls}/compat_syscall_table.c | 0 arch/riscv/kernel/{ => syscalls}/syscall_table.c | 0 4 files changed, 11 insertions(+), 4 deletions(-) create mode 100644 arch/riscv/kernel/syscalls/Makefile rename arch/riscv/kernel/{ => syscalls}/compat_syscall_table.c (100%) rename arch/riscv/kernel/{ => syscalls}/syscall_table.c (100%) diff --git a/arch/riscv/kernel/Makefile b/arch/riscv/kernel/Makefile index 95cf25d48405..40aebbf06880 100644 --- a/arch/riscv/kernel/Makefile +++ b/arch/riscv/kernel/Makefile @@ -8,8 +8,6 @@ CFLAGS_REMOVE_ftrace.o = $(CC_FLAGS_FTRACE) CFLAGS_REMOVE_patch.o = $(CC_FLAGS_FTRACE) CFLAGS_REMOVE_sbi.o = $(CC_FLAGS_FTRACE) endif -CFLAGS_syscall_table.o += $(call cc-option,-Wno-override-init,) -CFLAGS_compat_syscall_table.o += $(call cc-option,-Wno-override-init,) ifdef CONFIG_KEXEC AFLAGS_kexec_relocate.o := -mcmodel=medany $(call cc-option,-mno-relax) @@ -48,7 +46,7 @@ obj-y += ptrace.o obj-y += reset.o obj-y += setup.o obj-y += signal.o -obj-y += syscall_table.o +obj-y += syscalls/ obj-y += sys_riscv.o obj-y += time.o obj-y += traps.o @@ -95,7 +93,6 @@ obj-$(CONFIG_JUMP_LABEL) += jump_label.o obj-$(CONFIG_CFI_CLANG) += cfi.o obj-$(CONFIG_EFI) += efi.o -obj-$(CONFIG_COMPAT) += compat_syscall_table.o obj-$(CONFIG_COMPAT) += compat_signal.o obj-$(CONFIG_COMPAT) += compat_vdso/ diff --git a/arch/riscv/kernel/syscalls/Makefile b/arch/riscv/kernel/syscalls/Makefile new file mode 100644 index 000000000000..65abd0871ee5 --- /dev/null +++ b/arch/riscv/kernel/syscalls/Makefile @@ -0,0 +1,10 @@ +# SPDX-License-Identifier: GPL-2.0-only +# +# Makefile for the RISC-V syscall tables +# + +CFLAGS_syscall_table.o += $(call cc-option,-Wno-override-init,) +CFLAGS_compat_syscall_table.o += $(call cc-option,-Wno-override-init,) + +obj-y += syscall_table.o +obj-$(CONFIG_COMPAT) += compat_syscall_table.o diff --git a/arch/riscv/kernel/compat_syscall_table.c b/arch/riscv/kernel/syscalls/compat_syscall_table.c similarity index 100% rename from arch/riscv/kernel/compat_syscall_table.c rename to arch/riscv/kernel/syscalls/compat_syscall_table.c diff --git a/arch/riscv/kernel/syscall_table.c b/arch/riscv/kernel/syscalls/syscall_table.c similarity index 100% rename from arch/riscv/kernel/syscall_table.c rename to arch/riscv/kernel/syscalls/syscall_table.c From patchwork Mon Sep 25 22:42:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhangjin Wu X-Patchwork-Id: 13398527 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7A15DCE79A7 for ; Mon, 25 Sep 2023 22:42:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232611AbjIYWmo (ORCPT ); Mon, 25 Sep 2023 18:42:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37074 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229481AbjIYWmn (ORCPT ); Mon, 25 Sep 2023 18:42:43 -0400 Received: from bg4.exmail.qq.com (bg4.exmail.qq.com [43.155.65.254]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 42DCD11C; Mon, 25 Sep 2023 15:42:36 -0700 (PDT) X-QQ-mid: bizesmtp62t1695681747tvn9b2gn Received: from linux-lab-host.localdomain ( [116.30.124.152]) by bizesmtp.qq.com (ESMTP) with id ; Tue, 26 Sep 2023 06:42:25 +0800 (CST) X-QQ-SSF: 01200000002000E0Y000B00A0000000 X-QQ-FEAT: QityeSR92A0MQJVv5nuCC9DWB6NqRLzb0Nt00+7+ZdZFXtQd+tI7WSyL9WNOC fnkFG8BxSL4z+x4KtcNrcR8seOIuPOURUulAxrpJmjQqP1LnskZEYIQeAh7TqLbJQrlD4li 3VuACOa9fnkngcsF3KIGbIynUc0D2IWpUdjKYODzIYUXgIz+zmPiduG6OYqUjSeaFRhNVQi R0HbuNW/24Z5vZZir3noOwSkUHoulzJ2+O4FYOOXwupxn1hyjRia4sJ2NT5RJM4nXc0e8Iv 7hAGFtYtbhAxrGb58x8hDMLmYTvcInpLmnftQdn3m6DI7DS6SGVCJU/ULhGp1PpyhutLM3N Q/G4gGWqnZP9rqGdHPsdsDiBO/RURWwjE7Drreilih2jBFRvf5O1ZdfOFTpH5AMIwzf0aLr X-QQ-GoodBg: 0 X-BIZMAIL-ID: 2348411404682298682 From: Zhangjin Wu To: linux-kernel@vger.kernel.org, linux-mips@vger.kernel.org, linux-riscv@lists.infradead.org, Arnd Bergmann Cc: falcon@tinylab.org, palmer@rivosinc.com, paul.walmsley@sifive.com, paulburton@kernel.org, paulmck@kernel.org, tsbogend@alpha.franken.de, w@1wt.eu, =?utf-8?q?Thomas_Wei=C3=9Fschuh?= , Tim Bird Subject: [PATCH v1 6/7] DCE/DSE: riscv: add HAVE_TRIM_UNUSED_SYSCALLS support Date: Tue, 26 Sep 2023 06:42:23 +0800 Message-Id: X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 X-QQ-SENDSIZE: 520 Feedback-ID: bizesmtp:tinylab.org:qybglogicsvrgz:qybglogicsvrgz5a-1 Precedence: bulk List-ID: X-Mailing-List: linux-mips@vger.kernel.org For HAVE_TRIM_UNUSED_SYSCALLS, the syscall tables are hacked with the inputing unused_syscalls. Firstly, the intermediate preprocessed .i files are generated from the original C version of syscall tables respectively, and named with a 'used' suffix: syscall_table_used.i, compat_syscall_table_used.i. Secondly, all of the unused syscalls are commented. At last, two new objective files sufixed with 'used' are generated from the hacked .i files and they are linked into the eventual kernel image. Signed-off-by: Zhangjin Wu --- arch/riscv/Kconfig | 1 + arch/riscv/kernel/syscalls/Makefile | 37 +++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+) diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig index d607ab0f7c6d..b5e726b49a6f 100644 --- a/arch/riscv/Kconfig +++ b/arch/riscv/Kconfig @@ -140,6 +140,7 @@ config RISCV select HAVE_RSEQ select HAVE_STACKPROTECTOR select HAVE_SYSCALL_TRACEPOINTS + select HAVE_TRIM_UNUSED_SYSCALLS if HAVE_LD_DEAD_CODE_DATA_ELIMINATION select HOTPLUG_CORE_SYNC_DEAD if HOTPLUG_CPU select IRQ_DOMAIN select IRQ_FORCED_THREADING diff --git a/arch/riscv/kernel/syscalls/Makefile b/arch/riscv/kernel/syscalls/Makefile index 65abd0871ee5..3b5969aaa9e8 100644 --- a/arch/riscv/kernel/syscalls/Makefile +++ b/arch/riscv/kernel/syscalls/Makefile @@ -3,8 +3,45 @@ # Makefile for the RISC-V syscall tables # +ifndef CONFIG_TRIM_UNUSED_SYSCALLS + CFLAGS_syscall_table.o += $(call cc-option,-Wno-override-init,) CFLAGS_compat_syscall_table.o += $(call cc-option,-Wno-override-init,) obj-y += syscall_table.o obj-$(CONFIG_COMPAT) += compat_syscall_table.o +else # CONFIG_TRIM_UNUSED_SYSCALLS + +include $(srctree)/scripts/Makefile.syscalls + +CFLAGS_syscall_table_used.o += $(call cc-option,-Wno-override-init,) +CFLAGS_compat_syscall_table_used.o += $(call cc-option,-Wno-override-init,) + +obj-y += syscall_table_used.o +obj-$(CONFIG_COMPAT) += compat_syscall_table_used.o + +# comment the unused syscalls +quiet_cmd_used = USED $@ + cmd_used = sed -E -e '/^\[([0-9]+|\([0-9]+ \+ [0-9]+\))\] = /{/= *__riscv_(__sys_|sys_|compat_)*($(used_syscalls)),/!{s%^%/* %g;s%$$% */%g}}' -i $@; + +$(obj)/syscall_table_used.c: $(src)/syscall_table.c + $(Q)cp $< $@ + +$(obj)/syscall_table_used.i: $(src)/syscall_table_used.c $(used_syscalls_deps) FORCE + $(call if_changed_dep,cpp_i_c) + $(call cmd,used) + +$(obj)/syscall_table_used.o: $(obj)/syscall_table_used.i FORCE + $(call if_changed,cc_o_c) + +$(obj)/compat_syscall_table_used.c: $(src)/compat_syscall_table.c + $(Q)cp $< $@ + +$(obj)/compat_syscall_table_used.i: $(src)/compat_syscall_table_used.c $(used_syscalls_deps) FORCE + $(call if_changed_dep,cpp_i_c) + $(call cmd,used) + +$(obj)/compat_syscall_table_used.o: $(obj)/compat_syscall_table_used.i FORCE + $(call if_changed,cc_o_c) + +endif # CONFIG_TRIM_UNUSED_SYSCALLS From patchwork Mon Sep 25 22:43:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhangjin Wu X-Patchwork-Id: 13398528 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2B3E8CE79A7 for ; Mon, 25 Sep 2023 22:43:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230038AbjIYWnw (ORCPT ); Mon, 25 Sep 2023 18:43:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60680 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229481AbjIYWnv (ORCPT ); Mon, 25 Sep 2023 18:43:51 -0400 Received: from bg4.exmail.qq.com (bg4.exmail.qq.com [43.154.54.12]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 28C05109; Mon, 25 Sep 2023 15:43:43 -0700 (PDT) X-QQ-mid: bizesmtp81t1695681815tls4ddg5 Received: from linux-lab-host.localdomain ( [116.30.124.152]) by bizesmtp.qq.com (ESMTP) with id ; Tue, 26 Sep 2023 06:43:33 +0800 (CST) X-QQ-SSF: 01200000002000E0Y000B00A0000000 X-QQ-FEAT: aBJFcW+uBGYffXzygR0k5C/WLWWZcLSCd2TbMPG0O7Tlzn1m+5D3uZe31rmrB aujFQULia5dBlILNDRUyEjx57EpMsxaL6Hz0UfpOimP01EPYwODfLNDt/08+rViZ0kDvJPS c/l6PK5eg6fwnuRPIEYFxcxK83ddGI9AWtGlJq/Ee72+sNa4MrAQ3EN8Qe34Np4jqLArABG JS2WsLg0nT+US7V5b/8yFqpM/D3X+G29I8CLiztdDhT1Y7JbtyMwz8ftGBL0fuh92PguYE4 IKeAjeoyg3J6mOYoYZE003kMKygyo6u/CV03ypKigE7GsLxTYVFe5MpxCrKElLULeYxae/d HtHN7uvHgeUIKpoUbjQ3Dfq7OGBezfWvX3+if5KLWzLVYk17ZVHC2GUJSVYzHQJ1NQ/1p5y X-QQ-GoodBg: 0 X-BIZMAIL-ID: 4775298546958751858 From: Zhangjin Wu To: linux-kernel@vger.kernel.org, linux-mips@vger.kernel.org, linux-riscv@lists.infradead.org, Arnd Bergmann Cc: falcon@tinylab.org, palmer@rivosinc.com, paul.walmsley@sifive.com, paulburton@kernel.org, paulmck@kernel.org, tsbogend@alpha.franken.de, w@1wt.eu, =?utf-8?q?Thomas_Wei=C3=9Fschuh?= , Tim Bird Subject: [PATCH v1 7/7] DCE/DSE: riscv: trim syscall tables Date: Tue, 26 Sep 2023 06:43:32 +0800 Message-Id: X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 X-QQ-SENDSIZE: 520 Feedback-ID: bizesmtp:tinylab.org:qybglogicsvrgz:qybglogicsvrgz5a-1 Precedence: bulk List-ID: X-Mailing-List: linux-mips@vger.kernel.org When the maximum nr of the used syscalls is smaller than __NR_syscalls (original syscalls total). It is able to update __NR_syscalls to (maximum nr + 1) and further trim the '>= (maximum nr + 1)' part of the syscall tables: For example: sys_call_table [143] = { [0 ... 143 - 1] = sys_ni_syscall, [64] = sys_write, [93] = sys_exit, [142] = sys_reboot, } The >= 143 part of the syscall tables can be trimmed. At the same time, the syscall >= 143 from user space must be ignored from do_trap_ecall_u() of traps.c. Signed-off-by: Zhangjin Wu --- arch/riscv/include/asm/unistd.h | 2 ++ arch/riscv/kernel/Makefile | 2 ++ arch/riscv/kernel/syscalls/Makefile | 22 +++++++++++++++++++ .../kernel/syscalls/compat_syscall_table.c | 4 ++-- arch/riscv/kernel/syscalls/syscall_table.c | 4 ++-- 5 files changed, 30 insertions(+), 4 deletions(-) diff --git a/arch/riscv/include/asm/unistd.h b/arch/riscv/include/asm/unistd.h index 221630bdbd07..4d8e41f446ff 100644 --- a/arch/riscv/include/asm/unistd.h +++ b/arch/riscv/include/asm/unistd.h @@ -23,4 +23,6 @@ #include +#ifndef NR_syscalls #define NR_syscalls (__NR_syscalls) +#endif diff --git a/arch/riscv/kernel/Makefile b/arch/riscv/kernel/Makefile index 40aebbf06880..e75424c10729 100644 --- a/arch/riscv/kernel/Makefile +++ b/arch/riscv/kernel/Makefile @@ -49,7 +49,9 @@ obj-y += signal.o obj-y += syscalls/ obj-y += sys_riscv.o obj-y += time.o +ifneq ($(CONFIG_TRIM_UNUSED_SYSCALLS),y) obj-y += traps.o +endif obj-y += riscv_ksyms.o obj-y += stacktrace.o obj-y += cacheinfo.o diff --git a/arch/riscv/kernel/syscalls/Makefile b/arch/riscv/kernel/syscalls/Makefile index 3b5969aaa9e8..f1a0597c8b24 100644 --- a/arch/riscv/kernel/syscalls/Makefile +++ b/arch/riscv/kernel/syscalls/Makefile @@ -14,9 +14,18 @@ else # CONFIG_TRIM_UNUSED_SYSCALLS include $(srctree)/scripts/Makefile.syscalls +# calculate syscalls total from $(obj)/syscall_table_used.i +ifneq ($(used_syscalls),) + NR_syscalls := $$(($$(sed -E -n -e '/^\[([0-9]+|\([0-9]+ \+ [0-9]+\))\] = /{s/^\[(.*)\].*/\1/gp}' $(obj)/syscall_table_used.i | bc | sort -g | tail -1 | grep '[0-9]' || echo -1) + 1)) +else + NR_syscalls := 0 +endif + +CFLAGS_traps_used.o += -DNR_syscalls=$(NR_syscalls) CFLAGS_syscall_table_used.o += $(call cc-option,-Wno-override-init,) CFLAGS_compat_syscall_table_used.o += $(call cc-option,-Wno-override-init,) +obj-y += traps_used.o obj-y += syscall_table_used.o obj-$(CONFIG_COMPAT) += compat_syscall_table_used.o @@ -24,15 +33,26 @@ obj-$(CONFIG_COMPAT) += compat_syscall_table_used.o quiet_cmd_used = USED $@ cmd_used = sed -E -e '/^\[([0-9]+|\([0-9]+ \+ [0-9]+\))\] = /{/= *__riscv_(__sys_|sys_|compat_)*($(used_syscalls)),/!{s%^%/* %g;s%$$% */%g}}' -i $@; +# update the syscalls total +quiet_cmd_snr = SNR $@ + cmd_snr = snr=$(NR_syscalls); if [ $$snr -ne 0 ]; then \ + sed -i -e "s/sys_call_table\[.*\] =/sys_call_table[($$snr)] =/g;s/\[0 ... (.*) - 1\] = __riscv_sys_ni_syscall/[0 ... ($$snr) - 1] = __riscv_sys_ni_syscall/g" $@; \ + fi; + +$(obj)/traps_used.c: $(src)/../traps.c $(obj)/syscall_table_used.i FORCE + $(Q)cp $< $@ + $(obj)/syscall_table_used.c: $(src)/syscall_table.c $(Q)cp $< $@ $(obj)/syscall_table_used.i: $(src)/syscall_table_used.c $(used_syscalls_deps) FORCE $(call if_changed_dep,cpp_i_c) $(call cmd,used) + $(call cmd,snr) $(obj)/syscall_table_used.o: $(obj)/syscall_table_used.i FORCE $(call if_changed,cc_o_c) + $(call cmd,force_checksrc) $(obj)/compat_syscall_table_used.c: $(src)/compat_syscall_table.c $(Q)cp $< $@ @@ -40,8 +60,10 @@ $(obj)/compat_syscall_table_used.c: $(src)/compat_syscall_table.c $(obj)/compat_syscall_table_used.i: $(src)/compat_syscall_table_used.c $(used_syscalls_deps) FORCE $(call if_changed_dep,cpp_i_c) $(call cmd,used) + $(call cmd,snr) $(obj)/compat_syscall_table_used.o: $(obj)/compat_syscall_table_used.i FORCE $(call if_changed,cc_o_c) + $(call cmd,force_checksrc) endif # CONFIG_TRIM_UNUSED_SYSCALLS diff --git a/arch/riscv/kernel/syscalls/compat_syscall_table.c b/arch/riscv/kernel/syscalls/compat_syscall_table.c index ad7f2d712f5f..4756b6858eac 100644 --- a/arch/riscv/kernel/syscalls/compat_syscall_table.c +++ b/arch/riscv/kernel/syscalls/compat_syscall_table.c @@ -17,7 +17,7 @@ asmlinkage long compat_sys_rt_sigreturn(void); -void * const compat_sys_call_table[__NR_syscalls] = { - [0 ... __NR_syscalls - 1] = __riscv_sys_ni_syscall, +void * const compat_sys_call_table[NR_syscalls] = { + [0 ... NR_syscalls - 1] = __riscv_sys_ni_syscall, #include }; diff --git a/arch/riscv/kernel/syscalls/syscall_table.c b/arch/riscv/kernel/syscalls/syscall_table.c index dda913764903..d2b3233ae5d4 100644 --- a/arch/riscv/kernel/syscalls/syscall_table.c +++ b/arch/riscv/kernel/syscalls/syscall_table.c @@ -16,7 +16,7 @@ #undef __SYSCALL #define __SYSCALL(nr, call) [nr] = __riscv_##call, -void * const sys_call_table[__NR_syscalls] = { - [0 ... __NR_syscalls - 1] = __riscv_sys_ni_syscall, +void * const sys_call_table[NR_syscalls] = { + [0 ... NR_syscalls - 1] = __riscv_sys_ni_syscall, #include };