From patchwork Fri Feb 17 00:49: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: 58303 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp616620wrn; Thu, 16 Feb 2023 16:53:23 -0800 (PST) X-Google-Smtp-Source: AK7set/+dy8g3SGZ4aleImZzDKV4cUEwaXTiDFQYFIs/NXblMWaL7tLy/4hI21OGGgYv36hD0AJQ X-Received: by 2002:a17:906:40c9:b0:8b1:75a0:57fa with SMTP id a9-20020a17090640c900b008b175a057famr2672908ejk.43.1676595203739; Thu, 16 Feb 2023 16:53:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1676595203; cv=none; d=google.com; s=arc-20160816; b=hCani1EOMkYvJLXIXIVAfCwXZSth0/iUO2nqnibEzZvZ3alZqsk308wEkgW1tfIPNO flsCYo1gq9OcllYdA77mhRHx4McXUqwTDhMNFEQ/PaCxzMV4+OjZYBun9JqeF8p79j4b 75z3AM0SWqlslR+JjVchYiTFfA1l7WS4wjeYgJCw6THhE+R1n/12IXQ027hSNOdUALkh 9OrjpU53Gj4msLtZGV5/iOwMQAkzYv8A95Ds7DkYjFKcwfMar1pGAZkjuork+i8It9Gr g1ZAdFVoeOnaDjIqnDU5V9/ZuaRtrO/LGAh/tvXiyLzdVNkJLQ5zJluqUhgg6mszrl3H +/+A== 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=m1p7dnhEsRIVsnzK0e7I8OsbQqK8jj8CjHMvB1ks+Xo=; b=CLcWo5hNIs3T2mfc1lHlTLws+N7uwXebX8Sx/Yb9x8aecxVgQKT8zBgBvo8vIB3n+c hDW2oDqJzCTTbWGw7MYCTuQbPC5hWbmuCAnQSPGsV57qxQ9RgdTAmGUGPD4pNqh2ECGN SHJN3Oxc/C9G2EOjoYdXumItx1QQ4QTzA5ko+Vh1fbL0Bb6HfPLkXbabMbo0ZtBIeXoo avPQb3Z0z/fElhGdoEnAHWmUHzaBUfIdHungpkQwdBNgu50cI4QN1jV6ismnJ+UkVvnb 0X22HHaNl6od4I/AqjZN/bpmw80R//zBNZucJ5uppsV4kuNTRGVZb6zxtaUZT0cZiZyp 7J0A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id fc5-20020a1709073a4500b008b14709d699si3199680ejc.412.2023.02.16.16.52.59; Thu, 16 Feb 2023 16:53:23 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229886AbjBQAuB (ORCPT + 99 others); Thu, 16 Feb 2023 19:50:01 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56388 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229534AbjBQAuA (ORCPT ); Thu, 16 Feb 2023 19:50:00 -0500 Received: from smtpbguseast3.qq.com (smtpbguseast3.qq.com [54.243.244.52]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F034F3C7B7; Thu, 16 Feb 2023 16:49:56 -0800 (PST) X-QQ-mid: bizesmtp76t1676594974t44ilj1c Received: from localhost.localdomain ( [116.30.131.224]) by bizesmtp.qq.com (ESMTP) with id ; Fri, 17 Feb 2023 08:49:31 +0800 (CST) X-QQ-SSF: 01200000000000C0T000000A0000000 X-QQ-FEAT: znfcQSa1hKbHsodWWJ7dLyJeU0dQLSJ2PPtzz1iLzMNgSELCkUn2ujNlhycbg vLg03SNvb9EFMysNu9WjgjH2yYBaAi1fGVqPKaFhctNfTwt+bbxYpXQIVh9rDo/8cNrLyPt ToX08gVh/Po6w/uiFpE5NpG8RVgjCEHPEAjNBEvKB228hcFV2zJd7lPvufzHTfmfzprQ+fT BT5FvJHdZIQ0ZHz+hIneTfMRDTSLb6HDEunI+ke40/IGoYkdjw1kyDvwLpdYHmyCpkkWnqA O1Hes08eR/3n/SlY9lwkeFrEDn7M4DXKn75YILTWaoiJycDGTzD8fi1d+13MWbJyxm4+S3n g5P3PHo4ATnp0TD9593FPSzON//EjXHb6RjyzNWaKJfKxUqmS92Hopcemr0iQ8IBGReu7VW X-QQ-GoodBg: 0 From: Zhangjin Wu To: linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, linux-mips@vger.kernel.org Cc: Thomas Bogendoerfer , Palmer Dabbelt , Willy Tarreau , Paul Burton , "Paul E . McKenney" , Paul Walmsley , Nicholas Mc Guire , Zhangjin Wu Subject: [RFC PATCH 1/5] syscall: Allow configure used system calls Date: Fri, 17 Feb 2023 08:49:21 +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:qybglogicsvr:qybglogicsvr7 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1758037492434081883?= X-GMAIL-MSGID: =?utf-8?q?1758037492434081883?= A new CONFIG_SYSCALLS_USED is added to configure the system calls used in a target system (especially for the ultra small embedded systems), the other system calls will be disabled. If further enabling CONFIG_HAVE_LD_DEAD_CODE_DATA_ELIMINATION, the other ones (if also not used by kernel itself) will be removed automatically. The used system calls should be listed one by one like this: write exit reboot The architecture should implement it and then select the HAVE_SYSCALLS_USED option. Signed-off-by: Zhangjin Wu --- init/Kconfig | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/init/Kconfig b/init/Kconfig index 44e90b28a30f..2c4b8b234168 100644 --- a/init/Kconfig +++ b/init/Kconfig @@ -1502,6 +1502,10 @@ config BPF bool select CRYPTO_LIB_SHA1 +config HAVE_SYSCALLS_USED + bool + default n + menuconfig EXPERT bool "Configure standard kernel features (expert users)" # Unhide debug options, to make the on-by-default options visible @@ -1728,6 +1732,24 @@ config MEMBARRIER If unsure, say Y. +config SYSCALLS_USED + string "Configure used syscalls (EXPERIMENTAL)" if EXPERT + depends on HAVE_SYSCALLS_USED + default "" + help + This option allows to configure the system calls used in a target + system, the other system calls will be disabled. + + If further enabling CONFIG_HAVE_LD_DEAD_CODE_DATA_ELIMINATION, the + other ones (if also not used by kernel itself) will be removed + automatically. + + The used system calls should be listed one by one like this: + + write exit reboot + + If unsure, keep this empty. + config KALLSYMS bool "Load all symbols for debugging/ksymoops" if EXPERT default y From patchwork Fri Feb 17 00:49:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhangjin Wu X-Patchwork-Id: 58311 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp618376wrn; Thu, 16 Feb 2023 16:59:07 -0800 (PST) X-Google-Smtp-Source: AK7set9Y0GJzNxEmtsK94I6bShbT9g2Xq+r7IX63Jpc4UQx8E+KxgWczFTTN98wR8GuoCYRQlrQ1 X-Received: by 2002:a05:6a20:4c12:b0:c7:684a:e4ae with SMTP id fm18-20020a056a204c1200b000c7684ae4aemr1167633pzb.15.1676595547425; Thu, 16 Feb 2023 16:59:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1676595547; cv=none; d=google.com; s=arc-20160816; b=HpBnfv/D1McOGr80QuBzw/6nYMFtA1s44pIe7xTLXdFKJr2WqHiXfIqmUhFOLxv6cr gz7vTOdJV7d/mL1zjLUj0V0rsCMhrO+1tHtDWILVeeYkhWLS6/W1ZhwwWv4eu3ppPI/3 sOFttBvdNerrFn+TYxyXTmyTseEFaNyLh1eQX0Z0/woCVuSkNnTfZ9nhMyVbbD45j63b B+JJscvFh3FeQyFOWZIASwqDmBeN36Ht7aK6bcrCbgEVW6kTPktPcQ1dXHj0Szs/bmZk NmnBDACjnY3Vc+q/ze+hKuwY5yXCQ0oxKSxgt0wgML3QZRnH2VLgybbjN5wTeoIhypM4 EBag== 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=yLb16cvavpJmJcg3+UwmMJOFkV8ahMSMr+EDxcMpkho=; b=sQpmdWleiKBkXdjtEutXtPD44xYgyn66irf9bxqzOGcs2V3OyWe1c8Y7RO2gj33MP2 gdq0fIq9VVAnH+xJ42mLC39LiM7hFPkGiZpyD98AmpWVDOtfP1plwEbJTkt2OYHwuzbS ZlFGFV4wPPJNtIcQLI+r2Cf8IpweD0t4N6KXjnwqhCidOvXWY80fG0mDi7Bcrymx6J9z GaZUep9nAS/U0trq3S1CfdpTYcgDbPRxL5v49/wTOSXoopISH4N4i5wYdbs3OJxYbNsf CPX4OKSq4JDyKkDbs8JHEtwgBqD95bRjlaN9O8NvNYP+P9ATbG8xMNlYBL2/c5G3mfQ9 GrYA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i191-20020a6387c8000000b004fb7d5d316esi3375787pge.404.2023.02.16.16.58.54; Thu, 16 Feb 2023 16:59:07 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229620AbjBQAxD (ORCPT + 99 others); Thu, 16 Feb 2023 19:53:03 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33090 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229482AbjBQAxB (ORCPT ); Thu, 16 Feb 2023 19:53:01 -0500 Received: from smtpbg153.qq.com (smtpbg153.qq.com [13.245.218.24]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6FAA27DAB; Thu, 16 Feb 2023 16:52:49 -0800 (PST) X-QQ-mid: bizesmtp76t1676594981tzj20bxn Received: from localhost.localdomain ( [116.30.131.224]) by bizesmtp.qq.com (ESMTP) with id ; Fri, 17 Feb 2023 08:49:37 +0800 (CST) X-QQ-SSF: 01200000000000C0T000000A0000000 X-QQ-FEAT: HH6/KuQOBEYape0K7eNPpGClNte1p9KwHz5G63svXw4+DTBNwFMoPpE5XUhx6 05cCvEABd10oan5cv3LUnUMcUAHqyNqZq4+jTSCoUmilAXTQ9duURc8/ruw7SY6oor0tBev RoFEB3fWfD1W8TD67x5MtiQ+DjwwcYO78oT04ndKAyzBOChBjxfUcAYeQ4FX5k0S5OoK8Ox gFEhgXjlsxlrY99cZIG/3rP3A79PqE/96cPTSu6w0R+hXn7r4u9vMv+S2yzV/ofwTvSCq12 zwDKb63xgVmxw+JXjn9VgOf31CWsu7Tgnd7untYTG8+Nkyy+99r1iatC9zrXPQh7OdEa1UY DB2saWPTsE8kVbMerbuqMOpDMVViphDIwHBwBVQOPZPg8P/98pX6ELE5xO/vKjwq+wBju5K sOzMCFPNoHQ= X-QQ-GoodBg: 0 From: Zhangjin Wu To: linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, linux-mips@vger.kernel.org Cc: Thomas Bogendoerfer , Palmer Dabbelt , Willy Tarreau , Paul Burton , "Paul E . McKenney" , Paul Walmsley , Nicholas Mc Guire , Zhangjin Wu Subject: [RFC PATCH 2/5] MIPS: Add dead syscalls elimination support Date: Fri, 17 Feb 2023 08:49:22 +0800 Message-Id: <29e5a037ac439c40970b40692286feb6f010f8f3.1676594211.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:qybglogicsvr:qybglogicsvr7 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1758037852793947100?= X-GMAIL-MSGID: =?utf-8?q?1758037852793947100?= By enabling CONFIG_HAVE_LD_DEAD_CODE_DATA_ELIMINATION and setting CONFIG_SYSCALLS_USED, It is able to remove the left 'dead' syscalls. For example, if setting CONFIG_SYSCALLS_USED="write exit reboot", a 'used' variant of the *.tbl will be generated, accordingly, the kernel api unistd_nr_*.h and syscall_table_*.h will be generated from the 'used' *tbl variant. the user api version of unistd_*.h is reserved as-is. Here is a test result on qemu with a minimal malta config. | mipsel malta | config ----------------|-----------------|------------------- vmlinux | 5041628 | https://pastebin.com/0bE2ibLD + gc-sections | 4474060 (-11.2%)| CONFIG_HAVE_LD_DEAD_CODE_DATA_ELIMINATION=y + syscalls_used | 4265280 (-4.67%)| CONFIG_SYSCALLS_USED="_newselect" + syscalls_used | 4274364 (-4.46%)| CONFIG_SYSCALLS_USED="write exit reboot" notes: - The shrink ratios of the syscalls_used lines are based on the gc-sections line. - "write exit reboot" are used by a hello.c to simply print "Hello, World!", exit and shutdown qemu. - "_newselect" is used by rcutorture to do a long-time sleep. Signed-off-by: Zhangjin Wu --- arch/mips/Kconfig | 1 + arch/mips/kernel/syscalls/Makefile | 24 ++++++++++++++++++++++-- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig index 15cb692b0a09..868d9a871b3e 100644 --- a/arch/mips/Kconfig +++ b/arch/mips/Kconfig @@ -102,6 +102,7 @@ config MIPS select TRACE_IRQFLAGS_SUPPORT select ARCH_HAS_ELFCORE_COMPAT select HAVE_ARCH_KCSAN if 64BIT + select HAVE_SYSCALLS_USED config MIPS_FIXUP_BIGPHYS_ADDR bool diff --git a/arch/mips/kernel/syscalls/Makefile b/arch/mips/kernel/syscalls/Makefile index e6b21de65cca..8ffba5301cf0 100644 --- a/arch/mips/kernel/syscalls/Makefile +++ b/arch/mips/kernel/syscalls/Makefile @@ -26,10 +26,30 @@ 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 +ifdef CONFIG_SYSCALLS_USED +syscalls_used := $(shell echo $(CONFIG_SYSCALLS_USED) | tr -s ' ' | tr ' ' '|') +endif + +ifneq ($(syscalls_used),) +utbl := arch/$(SRCARCH)/include/generated/tbl +_tbl := $(src)/syscall_%.tbl + tbl := $(utbl)/syscall_used_%.tbl + +$(shell mkdir -p $(utbl)) + +quiet_cmd_used = USED $@ + cmd_used = sed -E -e "/^[0-9]*[[:space:]]/{/(^($(syscalls_used))[[:space:]]|[[:space:]]($(syscalls_used))[[:space:]]|[[:space:]]($(syscalls_used))$$)/!{s/^/\#/g}}" $< > $@; + +$(tbl): $(_tbl) $(objtree)/.config + $(call cmd,used) +else +tbl := $(src)/syscall_%.tbl +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 Fri Feb 17 00:49: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: 58304 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp616653wrn; Thu, 16 Feb 2023 16:53:31 -0800 (PST) X-Google-Smtp-Source: AK7set/yQ3dp8e3KSBnYxgDGsiQPvoeL/ThI5gE0TxrwXlEdeJjFGquwGxDoIIsKC+UJ2MwK6diw X-Received: by 2002:a17:906:4888:b0:8af:5752:26e4 with SMTP id v8-20020a170906488800b008af575226e4mr8234120ejq.68.1676595210826; Thu, 16 Feb 2023 16:53:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1676595210; cv=none; d=google.com; s=arc-20160816; b=f9O12r6KEYuJAkdWRZ82wBpx5gRGyAQ+7yMkQdQsXLNbFF3QscqR9IdZcboqkJuGM2 uXpHeMW3SPIdIxJyZBHKcKWUxiOrrk68wAhqya/aZYU1EJPou8Eho0ohAE9H6zwF3VId WvBSehFdefgn6MKZGy2A5PYZ7LBnOHQjbdpGsQrIykl3DbmU46SV4JEkCVW4mexALzES EVXGorsn7DuUMiupM5tpZofTCKIKjdiK/UPoA4CRymnyP52j1vctMZbvO27hJa8feJtA /EDK30yf65z5nscn7nN8tjoZZ3zKWIcDo3DdZ9isRrr+U5+xzPWjky1vMhj77U/QQVzC aOpg== 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=l8Ed8kGhFirFcdRFPJHWG0cwiqJs87B0NEiD/UOd9vs=; b=U9DqdNQRaCqIQgHfqELnHIzeklO26JH2vOKv1E9WvpE++McpBL6VYTS5PsaLoZuRtc z65lJBps3uJWi1i1MZiFyZ3dewhP4KQCNx1AOwjJcHVX+1D/aIxu0vUE0mulCCKlGHaa yaT0cA2VlWzGfpoAu9r1x6yORcZplkRvTuFxEAvBn8JVYJAxsLMVpDlArim6q7pB65h/ ZQR7Nth3CZADo4/A+r8pulxZtwQ/JddRfNvJ4LkqClct/LhqbUh0MOUxw/FGffgqWe38 PLD4sATr+wJ+dp1RnLnb3QQpj1aJGhEuN6DuqPtQ4yEUy16Xx8nIhZZgQsJ1eK+RXFQF a8Kw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id gh32-20020a1709073c2000b008b19eb42527si723124ejc.267.2023.02.16.16.53.06; Thu, 16 Feb 2023 16:53:30 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229505AbjBQAu1 (ORCPT + 99 others); Thu, 16 Feb 2023 19:50:27 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57034 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230004AbjBQAuY (ORCPT ); Thu, 16 Feb 2023 19:50:24 -0500 Received: from smtpbgeu2.qq.com (smtpbgeu2.qq.com [18.194.254.142]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9116D54D6A; Thu, 16 Feb 2023 16:50:10 -0800 (PST) X-QQ-mid: bizesmtp76t1676594986t2mmsk6j Received: from localhost.localdomain ( [116.30.131.224]) by bizesmtp.qq.com (ESMTP) with id ; Fri, 17 Feb 2023 08:49:43 +0800 (CST) X-QQ-SSF: 01200000000000C0T000000A0000000 X-QQ-FEAT: 5CNn+SP0K2vhxP3ij/QWqUpDn2ZGtGF/HTyDPtXoKH89iqmX5zLubkqspz2kF NtTnLYIU+0SgEHfMgM5sR432r0TwmkrBhe3kSySu0yLsgT/Mzi+EbeZyoycxW8ekbNOfRH1 EXwhkOKRPC/LUAyhLqRb0s1KBws0EFd+HfFVJy6b2pICKxi0PJuR8HR9PRmB9M2cvkHWsfc 8XLlUBY56KbU6ixoaSQW5xoQnB2/2OYtiW0RP0OwXyXI4+lqxgiNSKr/RMA0F5hV4Ns5IqG cUjDHnF+OJ33xh5c0CET//3UA93C/o1KyTGve+1c/7fiRLD7ejxwfy/voNuaapE0xHPZcwr pwOpy7EwBDywpDN/XTzr4UT0Y0uFav3R5GDMcnFLi7Baqd7sxf2ep2dZisXQosML7Wc74Ad DQ1lmWv68Z4= X-QQ-GoodBg: 0 From: Zhangjin Wu To: linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, linux-mips@vger.kernel.org Cc: Thomas Bogendoerfer , Palmer Dabbelt , Willy Tarreau , Paul Burton , "Paul E . McKenney" , Paul Walmsley , Nicholas Mc Guire , Zhangjin Wu Subject: [RFC PATCH 3/5] RISC-V: Enable dead code elimination Date: Fri, 17 Feb 2023 08:49:23 +0800 Message-Id: <234017be6d06ef84844583230542e31068fa3685.1676594211.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:qybglogicsvr:qybglogicsvr7 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_PASS,T_SPF_HELO_TEMPERROR autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1758037500071359034?= X-GMAIL-MSGID: =?utf-8?q?1758037500071359034?= Select CONFIG_HAVE_LD_DEAD_CODE_DATA_ELIMINATION for RISC-V, allowing the user to enable dead code elimination. In order for this to work, ensure that we keep the alternative table by annotating them with KEEP. This boots well on qemu with both rv32_defconfig & rv64 defconfig, but it only shrinks their builds by ~1%, a smaller config is thereforce customized to test this feature: | rv32 | rv64 --------|------------------------|--------------------- No DCE | 4460684 | 4893488 DCE | 3986716 | 4376400 Shrink | 473968 (~10.6%) | 517088 (~10.5%) The config used above only reserves necessary options to boot on qemu with serial console, more like the size-critical embedded scenes: - rv64 config: https://pastebin.com/crz82T0s - rv32 config: rv64 config + 32-bit.config Signed-off-by: Zhangjin Wu --- arch/riscv/Kconfig | 1 + arch/riscv/kernel/vmlinux.lds.S | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig index e2b656043abf..8a73d7180cb8 100644 --- a/arch/riscv/Kconfig +++ b/arch/riscv/Kconfig @@ -103,6 +103,7 @@ config RISCV select HAVE_KPROBES_ON_FTRACE if !XIP_KERNEL select HAVE_KRETPROBES if !XIP_KERNEL select HAVE_RETHOOK if !XIP_KERNEL + select HAVE_LD_DEAD_CODE_DATA_ELIMINATION select HAVE_MOVE_PMD select HAVE_MOVE_PUD select HAVE_PCI diff --git a/arch/riscv/kernel/vmlinux.lds.S b/arch/riscv/kernel/vmlinux.lds.S index 4e6c88aa4d87..51218cfe1ee4 100644 --- a/arch/riscv/kernel/vmlinux.lds.S +++ b/arch/riscv/kernel/vmlinux.lds.S @@ -101,7 +101,7 @@ SECTIONS . = ALIGN(8); .alternative : { __alt_start = .; - *(.alternative) + KEEP(*(.alternative)) __alt_end = .; } __init_end = .; From patchwork Fri Feb 17 00:49:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhangjin Wu X-Patchwork-Id: 58305 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp616799wrn; Thu, 16 Feb 2023 16:53:57 -0800 (PST) X-Google-Smtp-Source: AK7set+yDZ7vBSTnGeXPkSB7VLmYaaj3pVDQRzxROGyzSaIhNnkV4e6bYYne94ZXwMTphUjmiifb X-Received: by 2002:aa7:df02:0:b0:4ab:2504:c7ff with SMTP id c2-20020aa7df02000000b004ab2504c7ffmr7311219edy.23.1676595237013; Thu, 16 Feb 2023 16:53:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1676595236; cv=none; d=google.com; s=arc-20160816; b=njOJXP/X4dTfItY8fgnEsNucqGQiR32oYg4eKzkxtY1ydDwcJGTM9NymmJdP/qMZGb zrYgGheUs1KCl0yvc8zX7XqRSgaDB1VWwiGnnyxXoWVguorU2LguUdWnb2hSQZ/6PV0N 7MWkbqx53M8dyRBGIT+78RJ5kbinPk6ctIvhPayWAd2rcNA6anpUoRx9K1fmNLng3P0z bdQ90ZU/UvpqvlJSxKncxTeRQVDtfP0O/oMu+blQpOnJ8PLD98QVNpHhbr9gncT5xYpy xCpC8oAVBqlKy1p3ho9uK7TBVuC8D74jDumbbv3//AKDxhyBEQaJEGP7zky2dt6qXbOX feMg== 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=UgyYgPRZcDw0wenr8MEngmDMztjQ+xnlrC+qPoQiwmg=; b=jssmW+XDucoNVzxzq79fAY0bwkKrVR+kgT9+6qytw/aIfhoqXZUkfAJ3BTR3mouAal kfuaOjovODWjY5ZFZsfJhT5YuchIdWfKKXOn2xsoiKnLX0KsTIJEqHhEFjExOiXAKtga 5mIhzYZAlNk6xtxv6Z+VCYSAFGtWhspKaEAznbYfSt+T6RVNFORbZLm2lTN/vRwZoqDZ 5Z6g14NgFHU8MOEha301mGcSasKHHWKTWGZbftfQ/UpD468b+8MYhBX7RwO3dZTsQ7dq oM9z3Op3VMu2L+jilu2kmY4ngT5gl28gkjISyfwcGFpvBJn9Hhlqnhbzw9tabIZDF215 0fcw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j3-20020a50ed03000000b004ab4569274esi3562048eds.88.2023.02.16.16.53.33; Thu, 16 Feb 2023 16:53:56 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230059AbjBQAue (ORCPT + 99 others); Thu, 16 Feb 2023 19:50:34 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57216 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229843AbjBQAud (ORCPT ); Thu, 16 Feb 2023 19:50:33 -0500 Received: from smtpbg151.qq.com (smtpbg151.qq.com [18.169.211.239]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F08E45828A; Thu, 16 Feb 2023 16:50:14 -0800 (PST) X-QQ-mid: bizesmtp76t1676594991t44bsp5y Received: from localhost.localdomain ( [116.30.131.224]) by bizesmtp.qq.com (ESMTP) with id ; Fri, 17 Feb 2023 08:49:49 +0800 (CST) X-QQ-SSF: 01200000000000C0T000000A0000000 X-QQ-FEAT: jGGC4gWX7WEdtHNjbW2La5D1yIRo1r+Zw/KaMj6Bl464xthLk0kAH0yAvRVPu pQdpYfLzsKgWo0JcHqKeObB4CrGIvHKePNNUzCW3kJCwsR3UUngiOXTUDO2pSg5aXI5963T w7WclL2OLpN1imcjF5siVtz2b6B6g4sRmXFVZMTQzEHe7zv76gtN3EFNDOZTxrEl1Mqp4eQ oHep0yeehO8eA+Cwwd+Iw4beO1XFcCt+dJ5cV+YpBSQoTHm/Ngf11fhZYRFGSsljUYsGb6L 9yBH/B5Mt7pWcK5iwojBnpW3zqBCnthsxNlqGdlXPAEuemx7vbHMCzkkB0/xKKlhEsFouD+ mLEpshtFxpdm8ttAwcJUSciB3GCHrBdeebHRFIkUgqAeR/VpZsr9k3ws58PpM1AN9d+HCtD X-QQ-GoodBg: 0 From: Zhangjin Wu To: linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, linux-mips@vger.kernel.org Cc: Thomas Bogendoerfer , Palmer Dabbelt , Willy Tarreau , Paul Burton , "Paul E . McKenney" , Paul Walmsley , Nicholas Mc Guire , Zhangjin Wu Subject: [RFC PATCH 4/5] RISC-V: Add dead syscalls elimination support Date: Fri, 17 Feb 2023 08:49:24 +0800 Message-Id: <9a4d0339dd8175cdb3801dc66d68167cac47ddbf.1676594211.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:qybglogicsvr:qybglogicsvr7 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1758037527213539512?= X-GMAIL-MSGID: =?utf-8?q?1758037527213539512?= By enabling CONFIG_HAVE_LD_DEAD_CODE_DATA_ELIMINATION and setting CONFIG_SYSCALLS_USED, It is able to remove the left 'dead' syscalls. For example, if setting CONFIG_SYSCALLS_USED="write exit reboot", a 'used' variant of the *syscall_table.c will be generated. Here is a test result on qemu with a minimal rv64 config. | rv64 | config ----------------|-----------------|------------------- vmlinux | 4893488 | https://pastebin.com/crz82T0s + gc-sections | 4376400 (-10.5%)| CONFIG_HAVE_LD_DEAD_CODE_DATA_ELIMINATION=y + syscalls_used | 4172112 (-4.67%)| CONFIG_SYSCALLS_USED="pselect6" + syscalls_used | 4172848 (-4.65%)| CONFIG_SYSCALLS_USED="write exit reboot" notes: - The shrink ratios of the syscalls_used lines are based on the gc-sections line. - "write exit reboot" are used by a hello.c to simply print "Hello, World!", exit and shutdown qemu. - "pselect6" is used by rcutorture to do a long-time sleep. Signed-off-by: Zhangjin Wu --- arch/riscv/Kconfig | 1 + arch/riscv/kernel/Makefile | 5 ++-- arch/riscv/kernel/syscalls/Makefile | 46 +++++++++++++++++++++++++++++ 3 files changed, 49 insertions(+), 3 deletions(-) create mode 100644 arch/riscv/kernel/syscalls/Makefile diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig index 8a73d7180cb8..f78cc6b2413f 100644 --- a/arch/riscv/Kconfig +++ b/arch/riscv/Kconfig @@ -140,6 +140,7 @@ config RISCV select HAVE_FTRACE_MCOUNT_RECORD if !XIP_KERNEL select HAVE_FUNCTION_GRAPH_TRACER select HAVE_FUNCTION_TRACER if !XIP_KERNEL + select HAVE_SYSCALLS_USED config ARCH_MMAP_RND_BITS_MIN default 18 if 64BIT diff --git a/arch/riscv/kernel/Makefile b/arch/riscv/kernel/Makefile index 4cf303a779ab..fd716d5ffda5 100644 --- a/arch/riscv/kernel/Makefile +++ b/arch/riscv/kernel/Makefile @@ -8,7 +8,8 @@ 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,) + +obj-y += syscalls/ ifdef CONFIG_KEXEC AFLAGS_kexec_relocate.o := -mcmodel=medany $(call cc-option,-mno-relax) @@ -42,7 +43,6 @@ obj-y += ptrace.o obj-y += reset.o obj-y += setup.o obj-y += signal.o -obj-y += syscall_table.o obj-y += sys_riscv.o obj-y += time.o obj-y += traps.o @@ -86,6 +86,5 @@ obj-$(CONFIG_CRASH_CORE) += crash_core.o obj-$(CONFIG_JUMP_LABEL) += jump_label.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..7bd327331a98 --- /dev/null +++ b/arch/riscv/kernel/syscalls/Makefile @@ -0,0 +1,46 @@ +# SPDX-License-Identifier: GPL-2.0-or-later +# +# Copyright (C) 2023 Zhangjin Wu +# + +CFLAGS_syscall_table_used.o += $(call cc-option,-Wno-override-init,) +obj-y += syscall_table_used.o +obj-$(CONFIG_COMPAT) += compat_syscall_table_used.o + +ifdef CONFIG_SYSCALLS_USED +syscalls_used := $(shell echo $(CONFIG_SYSCALLS_USED) | tr -s ' ' | tr ' ' '|') +endif + +ifneq ($(syscalls_used),) + +quiet_cmd_calc = CALC $@ + cmd_calc = sed -n -e '/^\[([0-9 +]*)\] = /{s/.*\[\(.*\)\] = .*/sed \\"s%^\\\\[\1\\\\] = %[$$((\1))] = %g\\" -i /gp}' $@ | xargs -I{} echo {} $@ | sh; + +quiet_cmd_used = USED $@ + cmd_used = sed -E -e '/^\[[0-9]*\] = /{/(^\[($(syscalls_used))\] *=|= *\((sys_)*($(syscalls_used))\),)/!{s%^%// %g}}' -i $@; + +$(obj)/syscall_table.i: $(src)/../syscall_table.c $(objtree)/.config FORCE + $(call if_changed_dep,cpp_i_c) + $(call cmd,calc) + $(call cmd,used) + +$(obj)/syscall_table_used.o: $(obj)/syscall_table.i FORCE + $(call if_changed,cc_o_c) + +$(obj)/compat_syscall_table.i: $(src)/../compat_syscall_table.c $(objtree)/.config FORCE + $(call if_changed_dep,cpp_i_c) + $(call cmd,calc) + $(call cmd,used) + +$(obj)/compat_syscall_table_used.o: $(obj)/compat_syscall_table.i FORCE + $(call if_changed,cc_o_c) + +else + +$(obj)/syscall_table_used.o: $(src)/../syscall_table.c FORCE + $(call if_changed_rule,cc_o_c) + +$(obj)/compat_syscall_table_used.o: $(src)/../compat_syscall_table.c FORCE + $(call if_changed_rule,cc_o_c) + +endif From patchwork Fri Feb 17 00:49:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhangjin Wu X-Patchwork-Id: 58313 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp630508wrn; Thu, 16 Feb 2023 17:30:56 -0800 (PST) X-Google-Smtp-Source: AK7set/dAS+d3+qqkFEbqNgUBgRPuF0F1IxAriaxadSywK5JlrKC+toE+dXHqd6NeQi72VU749OR X-Received: by 2002:a17:906:ef8c:b0:8b1:806b:7dbb with SMTP id ze12-20020a170906ef8c00b008b1806b7dbbmr1166659ejb.51.1676597456331; Thu, 16 Feb 2023 17:30:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1676597456; cv=none; d=google.com; s=arc-20160816; b=bPM/bYwRDNbHxZio0uaT6pULfwJp+QX/jlXZvdqp6wGIzmUVt/w5oW0bU6Rn1YWRn1 1ddp+CMvJ+r4/YbceVynHTIpSYpLc7mV4Sq7zXyfCdWl73uKh5a/95cDEJy/JMcf2g74 nEv/NHVxmqQPLlLpTdcS9Yhia6HAI0cXC+BOUuiCbirh5HaXE5tbrh71lkE1zkV7TyxF kRaqIL5Ol8fbyAID8EGgTu671eIlL440RittmknR6945lacUkyA4RNsMRZuINY4Vf7gB fv/T3OPE/zJr/E+ZorSYaW5Aao3jC9IN+KBtxxKBNRtKeoDwb/p8pBgyvfsZGbVbeoMT jIgw== 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=n43pO7srMv4TNzkNfoMKdh1Egz6EgFigaYZlQB2tMZo=; b=W1cMUHMPqkCowSb5zOr3lejGCa89wQdFiOLx2rYnCCBDN4hAb5Q40rTv9ryk4QTFQg NVBZTnchaDsHuMbmFBq8/K6jaYV7OamKH3gbTpIo1RkUr3XHLiR32d9YZynJGlIfa7WX vTgQBVzpxZ5BxWeEm2b61zrVb+Va+qGzEoE0HWcYdmE10+U9RCmGtuk8je3jdBfoHSIn 2kbip6bXQIevURapltFgzGhcterFpGOn0RHAenofyUNHYdCkqy8WcXTea8cGhVIP+muQ vDZWPqXz4mVQrIuKn8elVRuwVR6usJfQmZN0Fxls5PRMJ1XLfZAVRbAA/bxQTv/Y/16k +eAQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id v22-20020a17090651d600b008b14b6437easi3961523ejk.771.2023.02.16.17.30.29; Thu, 16 Feb 2023 17:30:56 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229721AbjBQAxe (ORCPT + 99 others); Thu, 16 Feb 2023 19:53:34 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33868 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229508AbjBQAxc (ORCPT ); Thu, 16 Feb 2023 19:53:32 -0500 Received: from smtpbgbr2.qq.com (smtpbgbr2.qq.com [54.207.22.56]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 06E944AFC8; Thu, 16 Feb 2023 16:53:16 -0800 (PST) X-QQ-mid: bizesmtp76t1676594995t3oi78ew Received: from localhost.localdomain ( [116.30.131.224]) by bizesmtp.qq.com (ESMTP) with id ; Fri, 17 Feb 2023 08:49:53 +0800 (CST) X-QQ-SSF: 01200000000000C0T000000A0000000 X-QQ-FEAT: bhet8yMU7vlmY6nuENHCzNJu1BZZpDnRn9I+XyAaob1f8dWHf98iPQrpDZqXH saXuQiK7JfX4+FJfqSo0pANHueQ39kPgOQmPV+7/hAn2V/SOXd7Q5k4WCXpOCYTTMUm/1Tg kFRyl/FNxEq1JFEt0XGcoPA/dx12sbPDOU9L2dS93/hIsAInN2myDtZjNiOLQxoXbPurBvp fIU5W4KQ1Ux/5rSWVx5ivQGb6Xb1+I5COlKhiyo5nGqae/XaJv5Hv7zAmeoKKDbn13r+A/Y R1iSuadlTtKkEdykgqJe4rcmsOQRBqc29PLqjbmqeWUtBKk5nraoKf3iwl1j/is1RxmW9Ll ytcfjDeeI0Al4XlYDCWQIkKi0n0/0kS0ShmbDFb8mQzm9mZlDOKnLA40hi4cq8AYCb++qHU X-QQ-GoodBg: 0 From: Zhangjin Wu To: linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, linux-mips@vger.kernel.org Cc: Thomas Bogendoerfer , Palmer Dabbelt , Willy Tarreau , Paul Burton , "Paul E . McKenney" , Paul Walmsley , Nicholas Mc Guire , Zhangjin Wu Subject: [RFC PATCH 5/5] nolibc: Record used syscalls in their own sections Date: Fri, 17 Feb 2023 08:49:25 +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:qybglogicsvr:qybglogicsvr7 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1758039854138893174?= X-GMAIL-MSGID: =?utf-8?q?1758039854138893174?= A new section is added for every system call, the section is encoded with the syscall name and syscall number. for example: .rodata.syscall.__NR_exit.4001 .rodata.syscall.__NR_getpid.(4000+20) .rodata.syscall.__NR_kill.(4000+37) .rodata.syscall.__NR_write.(4000+4) .rodata.syscall.__NR_reboot.(4000+88) Both such sections and the unused syscalls can be printed by the -Wl,--print-gc-sections option of ld (with -ffunction-sections -fdata-sections and -Wl,--gc-sections together): removing unused section '.text.sys_getpid' in file '/tmp/ccbRltF4.o' removing unused section '.text.sys_kill' in file '/tmp/ccbRltF4.o' removing unused section '.rodata.syscall.__NR_exit.4001' in file '/tmp/cc0vNiof.o' removing unused section '.rodata.syscall.__NR_getpid.(4000+20)' in file '/tmp/ccbRltF4.o' removing unused section '.rodata.syscall.__NR_kill.(4000+37)' in file '/tmp/ccbRltF4.o' removing unused section '.rodata.syscall.__NR_write.(4000+4)' in file '/tmp/ccbRltF4.o' removing unused section '.rodata.syscall.__NR_reboot.(4000+88)' in file '/tmp/ccbRltF4.o' To get the used syscalls, we can use: the group of '.rodata.syscall.*' - the group of '.text.sys_*' At last, we get: __NR_exit.4001 __NR_write.(4000+4) __NR_reboot.(4000+88) Signed-off-by: Zhangjin Wu --- tools/include/nolibc/Makefile | 2 +- tools/include/nolibc/arch-aarch64.h | 17 ++++--- tools/include/nolibc/arch-arm.h | 15 +++--- tools/include/nolibc/arch-i386.h | 17 ++++--- tools/include/nolibc/arch-mips.h | 15 +++--- tools/include/nolibc/arch-riscv.h | 17 ++++--- tools/include/nolibc/arch-x86_64.h | 17 ++++--- tools/include/nolibc/arch.h | 2 + tools/include/nolibc/record.h | 77 +++++++++++++++++++++++++++++ 9 files changed, 138 insertions(+), 41 deletions(-) create mode 100644 tools/include/nolibc/record.h diff --git a/tools/include/nolibc/Makefile b/tools/include/nolibc/Makefile index cfd06764b5ae..f06cbb24124e 100644 --- a/tools/include/nolibc/Makefile +++ b/tools/include/nolibc/Makefile @@ -26,7 +26,7 @@ endif nolibc_arch := $(patsubst arm64,aarch64,$(ARCH)) arch_file := arch-$(nolibc_arch).h all_files := ctype.h errno.h nolibc.h signal.h std.h stdio.h stdlib.h string.h \ - sys.h time.h types.h unistd.h + sys.h time.h types.h unistd.h record.h # install all headers needed to support a bare-metal compiler all: headers diff --git a/tools/include/nolibc/arch-aarch64.h b/tools/include/nolibc/arch-aarch64.h index f68baf8f395f..9f7f5f662cd3 100644 --- a/tools/include/nolibc/arch-aarch64.h +++ b/tools/include/nolibc/arch-aarch64.h @@ -62,7 +62,7 @@ struct sys_stat_struct { */ #define __ARCH_WANT_SYS_PSELECT6 -#define my_syscall0(num) \ +#define _my_syscall0(num) \ ({ \ register long _num __asm__ ("x8") = (num); \ register long _arg1 __asm__ ("x0"); \ @@ -76,7 +76,7 @@ struct sys_stat_struct { _arg1; \ }) -#define my_syscall1(num, arg1) \ +#define _my_syscall1(num, arg1) \ ({ \ register long _num __asm__ ("x8") = (num); \ register long _arg1 __asm__ ("x0") = (long)(arg1); \ @@ -91,7 +91,7 @@ struct sys_stat_struct { _arg1; \ }) -#define my_syscall2(num, arg1, arg2) \ +#define _my_syscall2(num, arg1, arg2) \ ({ \ register long _num __asm__ ("x8") = (num); \ register long _arg1 __asm__ ("x0") = (long)(arg1); \ @@ -107,7 +107,7 @@ struct sys_stat_struct { _arg1; \ }) -#define my_syscall3(num, arg1, arg2, arg3) \ +#define _my_syscall3(num, arg1, arg2, arg3) \ ({ \ register long _num __asm__ ("x8") = (num); \ register long _arg1 __asm__ ("x0") = (long)(arg1); \ @@ -124,7 +124,7 @@ struct sys_stat_struct { _arg1; \ }) -#define my_syscall4(num, arg1, arg2, arg3, arg4) \ +#define _my_syscall4(num, arg1, arg2, arg3, arg4) \ ({ \ register long _num __asm__ ("x8") = (num); \ register long _arg1 __asm__ ("x0") = (long)(arg1); \ @@ -142,7 +142,7 @@ struct sys_stat_struct { _arg1; \ }) -#define my_syscall5(num, arg1, arg2, arg3, arg4, arg5) \ +#define _my_syscall5(num, arg1, arg2, arg3, arg4, arg5) \ ({ \ register long _num __asm__ ("x8") = (num); \ register long _arg1 __asm__ ("x0") = (long)(arg1); \ @@ -161,7 +161,7 @@ struct sys_stat_struct { _arg1; \ }) -#define my_syscall6(num, arg1, arg2, arg3, arg4, arg5, arg6) \ +#define _my_syscall6(num, arg1, arg2, arg3, arg4, arg5, arg6) \ ({ \ register long _num __asm__ ("x8") = (num); \ register long _arg1 __asm__ ("x0") = (long)(arg1); \ @@ -181,6 +181,8 @@ struct sys_stat_struct { _arg1; \ }) +#include "record.h" + /* startup code */ __asm__ (".section .text\n" ".weak _start\n" @@ -194,6 +196,7 @@ __asm__ (".section .text\n" "bl main\n" // main() returns the status code, we'll exit with it. "mov x8, 93\n" // NR_exit == 93 "svc #0\n" + asm_record_exit(93) ""); #endif // _NOLIBC_ARCH_AARCH64_H diff --git a/tools/include/nolibc/arch-arm.h b/tools/include/nolibc/arch-arm.h index f31be8e967d6..7e9f190b8d48 100644 --- a/tools/include/nolibc/arch-arm.h +++ b/tools/include/nolibc/arch-arm.h @@ -75,7 +75,7 @@ struct sys_stat_struct { */ #define __ARCH_WANT_SYS_OLD_SELECT -#define my_syscall0(num) \ +#define _my_syscall0(num) \ ({ \ register long _num __asm__ ("r7") = (num); \ register long _arg1 __asm__ ("r0"); \ @@ -89,7 +89,7 @@ struct sys_stat_struct { _arg1; \ }) -#define my_syscall1(num, arg1) \ +#define _my_syscall1(num, arg1) \ ({ \ register long _num __asm__ ("r7") = (num); \ register long _arg1 __asm__ ("r0") = (long)(arg1); \ @@ -104,7 +104,7 @@ struct sys_stat_struct { _arg1; \ }) -#define my_syscall2(num, arg1, arg2) \ +#define _my_syscall2(num, arg1, arg2) \ ({ \ register long _num __asm__ ("r7") = (num); \ register long _arg1 __asm__ ("r0") = (long)(arg1); \ @@ -120,7 +120,7 @@ struct sys_stat_struct { _arg1; \ }) -#define my_syscall3(num, arg1, arg2, arg3) \ +#define _my_syscall3(num, arg1, arg2, arg3) \ ({ \ register long _num __asm__ ("r7") = (num); \ register long _arg1 __asm__ ("r0") = (long)(arg1); \ @@ -137,7 +137,7 @@ struct sys_stat_struct { _arg1; \ }) -#define my_syscall4(num, arg1, arg2, arg3, arg4) \ +#define _my_syscall4(num, arg1, arg2, arg3, arg4) \ ({ \ register long _num __asm__ ("r7") = (num); \ register long _arg1 __asm__ ("r0") = (long)(arg1); \ @@ -155,7 +155,7 @@ struct sys_stat_struct { _arg1; \ }) -#define my_syscall5(num, arg1, arg2, arg3, arg4, arg5) \ +#define _my_syscall5(num, arg1, arg2, arg3, arg4, arg5) \ ({ \ register long _num __asm__ ("r7") = (num); \ register long _arg1 __asm__ ("r0") = (long)(arg1); \ @@ -174,6 +174,8 @@ struct sys_stat_struct { _arg1; \ }) +#include "record.h" + /* startup code */ __asm__ (".section .text\n" ".weak _start\n" @@ -199,6 +201,7 @@ __asm__ (".section .text\n" "bl main\n" // main() returns the status code, we'll exit with it. "movs r7, $1\n" // NR_exit == 1 "svc $0x00\n" + asm_record_exit(1) ""); #endif // _NOLIBC_ARCH_ARM_H diff --git a/tools/include/nolibc/arch-i386.h b/tools/include/nolibc/arch-i386.h index d7e7212346e2..de8ea6b32cc4 100644 --- a/tools/include/nolibc/arch-i386.h +++ b/tools/include/nolibc/arch-i386.h @@ -63,7 +63,7 @@ struct sys_stat_struct { */ #define __ARCH_WANT_SYS_OLD_SELECT -#define my_syscall0(num) \ +#define _my_syscall0(num) \ ({ \ long _ret; \ register long _num __asm__ ("eax") = (num); \ @@ -77,7 +77,7 @@ struct sys_stat_struct { _ret; \ }) -#define my_syscall1(num, arg1) \ +#define _my_syscall1(num, arg1) \ ({ \ long _ret; \ register long _num __asm__ ("eax") = (num); \ @@ -93,7 +93,7 @@ struct sys_stat_struct { _ret; \ }) -#define my_syscall2(num, arg1, arg2) \ +#define _my_syscall2(num, arg1, arg2) \ ({ \ long _ret; \ register long _num __asm__ ("eax") = (num); \ @@ -110,7 +110,7 @@ struct sys_stat_struct { _ret; \ }) -#define my_syscall3(num, arg1, arg2, arg3) \ +#define _my_syscall3(num, arg1, arg2, arg3) \ ({ \ long _ret; \ register long _num __asm__ ("eax") = (num); \ @@ -128,7 +128,7 @@ struct sys_stat_struct { _ret; \ }) -#define my_syscall4(num, arg1, arg2, arg3, arg4) \ +#define _my_syscall4(num, arg1, arg2, arg3, arg4) \ ({ \ long _ret; \ register long _num __asm__ ("eax") = (num); \ @@ -147,7 +147,7 @@ struct sys_stat_struct { _ret; \ }) -#define my_syscall5(num, arg1, arg2, arg3, arg4, arg5) \ +#define _my_syscall5(num, arg1, arg2, arg3, arg4, arg5) \ ({ \ long _ret; \ register long _num __asm__ ("eax") = (num); \ @@ -167,7 +167,7 @@ struct sys_stat_struct { _ret; \ }) -#define my_syscall6(num, arg1, arg2, arg3, arg4, arg5, arg6) \ +#define _my_syscall6(num, arg1, arg2, arg3, arg4, arg5, arg6) \ ({ \ long _eax = (long)(num); \ long _arg6 = (long)(arg6); /* Always in memory */ \ @@ -190,6 +190,8 @@ struct sys_stat_struct { _eax; \ }) +#include "record.h" + /* startup code */ /* * i386 System V ABI mandates: @@ -214,6 +216,7 @@ __asm__ (".section .text\n" "movl $1, %eax\n" // NR_exit == 1 "int $0x80\n" // exit now "hlt\n" // ensure it does not + asm_record_exit(1) ""); #endif // _NOLIBC_ARCH_I386_H diff --git a/tools/include/nolibc/arch-mips.h b/tools/include/nolibc/arch-mips.h index 7380093ba9e7..719eef58b187 100644 --- a/tools/include/nolibc/arch-mips.h +++ b/tools/include/nolibc/arch-mips.h @@ -67,7 +67,7 @@ struct sys_stat_struct { * don't have to experience issues with register constraints. */ -#define my_syscall0(num) \ +#define _my_syscall0(num) \ ({ \ register long _num __asm__ ("v0") = (num); \ register long _arg4 __asm__ ("a3"); \ @@ -84,7 +84,7 @@ struct sys_stat_struct { _arg4 ? -_num : _num; \ }) -#define my_syscall1(num, arg1) \ +#define _my_syscall1(num, arg1) \ ({ \ register long _num __asm__ ("v0") = (num); \ register long _arg1 __asm__ ("a0") = (long)(arg1); \ @@ -103,7 +103,7 @@ struct sys_stat_struct { _arg4 ? -_num : _num; \ }) -#define my_syscall2(num, arg1, arg2) \ +#define _my_syscall2(num, arg1, arg2) \ ({ \ register long _num __asm__ ("v0") = (num); \ register long _arg1 __asm__ ("a0") = (long)(arg1); \ @@ -123,7 +123,7 @@ struct sys_stat_struct { _arg4 ? -_num : _num; \ }) -#define my_syscall3(num, arg1, arg2, arg3) \ +#define _my_syscall3(num, arg1, arg2, arg3) \ ({ \ register long _num __asm__ ("v0") = (num); \ register long _arg1 __asm__ ("a0") = (long)(arg1); \ @@ -144,7 +144,7 @@ struct sys_stat_struct { _arg4 ? -_num : _num; \ }) -#define my_syscall4(num, arg1, arg2, arg3, arg4) \ +#define _my_syscall4(num, arg1, arg2, arg3, arg4) \ ({ \ register long _num __asm__ ("v0") = (num); \ register long _arg1 __asm__ ("a0") = (long)(arg1); \ @@ -165,7 +165,7 @@ struct sys_stat_struct { _arg4 ? -_num : _num; \ }) -#define my_syscall5(num, arg1, arg2, arg3, arg4, arg5) \ +#define _my_syscall5(num, arg1, arg2, arg3, arg4, arg5) \ ({ \ register long _num __asm__ ("v0") = (num); \ register long _arg1 __asm__ ("a0") = (long)(arg1); \ @@ -188,6 +188,8 @@ struct sys_stat_struct { _arg4 ? -_num : _num; \ }) +#include "record.h" + /* startup code, note that it's called __start on MIPS */ __asm__ (".section .text\n" ".weak __start\n" @@ -212,6 +214,7 @@ __asm__ (".section .text\n" "syscall\n" ".end __start\n" ".set pop\n" + asm_record_exit(4001) ""); #endif // _NOLIBC_ARCH_MIPS_H diff --git a/tools/include/nolibc/arch-riscv.h b/tools/include/nolibc/arch-riscv.h index a3bdd9803f8c..700d02860ecd 100644 --- a/tools/include/nolibc/arch-riscv.h +++ b/tools/include/nolibc/arch-riscv.h @@ -64,7 +64,7 @@ struct sys_stat_struct { */ #define __ARCH_WANT_SYS_PSELECT6 -#define my_syscall0(num) \ +#define _my_syscall0(num) \ ({ \ register long _num __asm__ ("a7") = (num); \ register long _arg1 __asm__ ("a0"); \ @@ -78,7 +78,7 @@ struct sys_stat_struct { _arg1; \ }) -#define my_syscall1(num, arg1) \ +#define _my_syscall1(num, arg1) \ ({ \ register long _num __asm__ ("a7") = (num); \ register long _arg1 __asm__ ("a0") = (long)(arg1); \ @@ -92,7 +92,7 @@ struct sys_stat_struct { _arg1; \ }) -#define my_syscall2(num, arg1, arg2) \ +#define _my_syscall2(num, arg1, arg2) \ ({ \ register long _num __asm__ ("a7") = (num); \ register long _arg1 __asm__ ("a0") = (long)(arg1); \ @@ -108,7 +108,7 @@ struct sys_stat_struct { _arg1; \ }) -#define my_syscall3(num, arg1, arg2, arg3) \ +#define _my_syscall3(num, arg1, arg2, arg3) \ ({ \ register long _num __asm__ ("a7") = (num); \ register long _arg1 __asm__ ("a0") = (long)(arg1); \ @@ -125,7 +125,7 @@ struct sys_stat_struct { _arg1; \ }) -#define my_syscall4(num, arg1, arg2, arg3, arg4) \ +#define _my_syscall4(num, arg1, arg2, arg3, arg4) \ ({ \ register long _num __asm__ ("a7") = (num); \ register long _arg1 __asm__ ("a0") = (long)(arg1); \ @@ -143,7 +143,7 @@ struct sys_stat_struct { _arg1; \ }) -#define my_syscall5(num, arg1, arg2, arg3, arg4, arg5) \ +#define _my_syscall5(num, arg1, arg2, arg3, arg4, arg5) \ ({ \ register long _num __asm__ ("a7") = (num); \ register long _arg1 __asm__ ("a0") = (long)(arg1); \ @@ -162,7 +162,7 @@ struct sys_stat_struct { _arg1; \ }) -#define my_syscall6(num, arg1, arg2, arg3, arg4, arg5, arg6) \ +#define _my_syscall6(num, arg1, arg2, arg3, arg4, arg5, arg6) \ ({ \ register long _num __asm__ ("a7") = (num); \ register long _arg1 __asm__ ("a0") = (long)(arg1); \ @@ -182,6 +182,8 @@ struct sys_stat_struct { _arg1; \ }) +#include "record.h" + /* startup code */ __asm__ (".section .text\n" ".weak _start\n" @@ -199,6 +201,7 @@ __asm__ (".section .text\n" "call main\n" // main() returns the status code, we'll exit with it. "li a7, 93\n" // NR_exit == 93 "ecall\n" + asm_record_exit(93) ""); #endif // _NOLIBC_ARCH_RISCV_H diff --git a/tools/include/nolibc/arch-x86_64.h b/tools/include/nolibc/arch-x86_64.h index 0e1e9eb8545d..5628b27a6f25 100644 --- a/tools/include/nolibc/arch-x86_64.h +++ b/tools/include/nolibc/arch-x86_64.h @@ -65,7 +65,7 @@ struct sys_stat_struct { * */ -#define my_syscall0(num) \ +#define _my_syscall0(num) \ ({ \ long _ret; \ register long _num __asm__ ("rax") = (num); \ @@ -79,7 +79,7 @@ struct sys_stat_struct { _ret; \ }) -#define my_syscall1(num, arg1) \ +#define _my_syscall1(num, arg1) \ ({ \ long _ret; \ register long _num __asm__ ("rax") = (num); \ @@ -95,7 +95,7 @@ struct sys_stat_struct { _ret; \ }) -#define my_syscall2(num, arg1, arg2) \ +#define _my_syscall2(num, arg1, arg2) \ ({ \ long _ret; \ register long _num __asm__ ("rax") = (num); \ @@ -112,7 +112,7 @@ struct sys_stat_struct { _ret; \ }) -#define my_syscall3(num, arg1, arg2, arg3) \ +#define _my_syscall3(num, arg1, arg2, arg3) \ ({ \ long _ret; \ register long _num __asm__ ("rax") = (num); \ @@ -130,7 +130,7 @@ struct sys_stat_struct { _ret; \ }) -#define my_syscall4(num, arg1, arg2, arg3, arg4) \ +#define _my_syscall4(num, arg1, arg2, arg3, arg4) \ ({ \ long _ret; \ register long _num __asm__ ("rax") = (num); \ @@ -149,7 +149,7 @@ struct sys_stat_struct { _ret; \ }) -#define my_syscall5(num, arg1, arg2, arg3, arg4, arg5) \ +#define _my_syscall5(num, arg1, arg2, arg3, arg4, arg5) \ ({ \ long _ret; \ register long _num __asm__ ("rax") = (num); \ @@ -169,7 +169,7 @@ struct sys_stat_struct { _ret; \ }) -#define my_syscall6(num, arg1, arg2, arg3, arg4, arg5, arg6) \ +#define _my_syscall6(num, arg1, arg2, arg3, arg4, arg5, arg6) \ ({ \ long _ret; \ register long _num __asm__ ("rax") = (num); \ @@ -190,6 +190,8 @@ struct sys_stat_struct { _ret; \ }) +#include "record.h" + /* startup code */ /* * x86-64 System V ABI mandates: @@ -210,6 +212,7 @@ __asm__ (".section .text\n" "mov $60, %eax\n" // NR_exit == 60 "syscall\n" // really exit "hlt\n" // ensure it does not return + asm_record_exit(60) ""); #endif // _NOLIBC_ARCH_X86_64_H diff --git a/tools/include/nolibc/arch.h b/tools/include/nolibc/arch.h index 4c6992321b0d..e0552934eb77 100644 --- a/tools/include/nolibc/arch.h +++ b/tools/include/nolibc/arch.h @@ -29,4 +29,6 @@ #include "arch-riscv.h" #endif +#include "record.h" + #endif /* _NOLIBC_ARCH_H */ diff --git a/tools/include/nolibc/record.h b/tools/include/nolibc/record.h new file mode 100644 index 000000000000..95e02092cecf --- /dev/null +++ b/tools/include/nolibc/record.h @@ -0,0 +1,77 @@ +/* SPDX-License-Identifier: LGPL-2.1 OR MIT */ +/* + * Copyright (C) 2023 Zhangjin Wu + */ + +#ifndef _NOLIBC_RECORD_H +#define _NOLIBC_RECORD_H + +/* To record syscalls used, please pass -DRECORD_SYSCALL to gcc */ +#ifdef RECORD_SYSCALL +#define __asm_record_syscall(name, val) \ + ".pushsection .rodata.syscall." name "." #val ",\"a\"\n" \ + ".word (" #val ")\n" \ + ".popsection\n" + +#define asm_record_syscall(num) __asm_record_syscall(#num, num) +#define asm_record_exit(num) __asm_record_syscall("__NR_exit", num) + +#define record_syscall(name, val) \ +({ \ + __asm__ volatile ( \ + __asm_record_syscall(name, val) \ + ); \ +}) + +#else /* RECORD_SYSCALL */ +#define asm_record_exit(num) "" +#define record_syscall(name, val) do { } while (0) +#endif /* !RECORD_SYSCALL */ + +#define my_syscall0(num) \ +({ \ + record_syscall(#num, num); \ + _my_syscall0(num); \ +}) + +#define my_syscall1(num, arg1) \ +({ \ + record_syscall(#num, num); \ + _my_syscall1(num, arg1); \ +}) + +#define my_syscall2(num, arg1, arg2) \ +({ \ + record_syscall(#num, num); \ + _my_syscall2(num, arg1, arg2); \ +}) + +#define my_syscall3(num, arg1, arg2, arg3) \ +({ \ + record_syscall(#num, num); \ + _my_syscall3(num, arg1, arg2, arg3); \ +}) + +#define my_syscall4(num, arg1, arg2, arg3, arg4) \ +({ \ + record_syscall(#num, num); \ + _my_syscall4(num, arg1, arg2, arg3, arg4); \ +}) + +#ifdef _my_syscall5 +#define my_syscall5(num, arg1, arg2, arg3, arg4, arg5) \ +({ \ + record_syscall(#num, num); \ + _my_syscall5(num, arg1, arg2, arg3, arg4, arg5); \ +}) +#endif + +#ifdef _my_syscall6 +#define my_syscall6(num, arg1, arg2, arg3, arg4, arg5, arg6) \ +({ \ + record_syscall(#num, num); \ + _my_syscall6(num, arg1, arg2, arg3, arg4, arg5, arg6); \ +}) +#endif + +#endif /* _NOLIBC_RECORD_H */