Received: by 2002:a05:7412:2a8c:b0:e2:908c:2ebd with SMTP id u12csp1517129rdh; Mon, 25 Sep 2023 15:40:47 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGdojobu1qNthMJIG03h/ZWRRvKSJoomS7GfThSIlgzEJGg4va3AudVv2tkXvHu6bMIjW02 X-Received: by 2002:a05:6a21:19a:b0:14e:a1f0:a8ea with SMTP id le26-20020a056a21019a00b0014ea1f0a8eamr7672764pzb.3.1695681647344; Mon, 25 Sep 2023 15:40:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695681647; cv=none; d=google.com; s=arc-20160816; b=ni6Q4xerVu02/XHPBKEmxrSwAh3cbg4IP101tnU6QTMWvkObd3QXK0N9+eUsGk52wV Qc9Nl5LmSrDcw4AxxNNTD1xPbb9GED3m9FjuveA9GJlTBwCT5cf4v3ChTP5TJa5djMJb teD8pCI3HGzvSdPNeTZCHe5gd+8+hS5sOcDUDpphPyrZzh/Pgyr0Wo35Ebz1biHl0bcu CMdZy8RIRPWgz0p/9zx/yrVDfCsZfVuj1dFLJ8T206eXsClGvpShNrJskR39LCA7dcgA 3z2Vk8JQhO1JNllVj34dCZz4Ymqe0HJwbcy1cJp0guXNhjnIshG8AMoNQM/L64wAR1eF MS+g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:feedback-id:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from; bh=2rsNTARSRJebl9nIfZEQj9ej8HoLIRnRnXTOwqEJW84=; fh=Hu5Z85mCjwbIpQ6O7J4KtGQomc/bitxjLDlxDRGGJ5w=; b=NklaP9hPvfJGlVeu+ILn92cXErldvb7ipK+vw2DAzb5CDzFDqZXqExEAQLHXvmfN8e TWZWW8FKNlVVwYwpkKXEbVB0kv+P7z+a7RqqkwisuQlrY9ZuaKI+lUTwIusne2VVJ2AF +PuDDZSuGCVOCSe2N4X73cwG20Y7r54765jcjWgo/VzKOj90C06NWL/oI+TH1b5SY3Hi 71ZPuGZ+WFy1K7sVCF48epW8CRo9XDqivfhZqUy1qLBFb+AGD6FC3ypBEUHLqEnv5gBG n0HYBm/+uR8ZSmMDcOGQdYEa9zCEWWDJXjOWy1vjgdRXqH7oy5CJfcAHgChnkLyaI+ey DASQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from agentk.vger.email (agentk.vger.email. [23.128.96.32]) by mx.google.com with ESMTPS id e7-20020a17090301c700b001c62b8bb043si1001377plh.407.2023.09.25.15.40.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Sep 2023 15:40:47 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) client-ip=23.128.96.32; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id 2AE6E801D81E; Mon, 25 Sep 2023 15:40:34 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232401AbjIYWkf (ORCPT + 99 others); Mon, 25 Sep 2023 18:40:35 -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=20Wei=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 Content-Transfer-Encoding: 8bit X-QQ-SENDSIZE: 520 Feedback-ID: bizesmtp:tinylab.org:qybglogicsvrgz:qybglogicsvrgz5a-1 X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Mon, 25 Sep 2023 15:40:34 -0700 (PDT) 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 \ -- 2.25.1