From patchwork Fri Nov 3 15:58:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yuan Tan X-Patchwork-Id: 13444656 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 9D41FC4332F for ; Fri, 3 Nov 2023 15:59:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=PA9CPmEV6HgYwEKRceHYI2VvP27h+2e5tMLjCljlj7Q=; b=u88krqBhcbnOJj GPuqiX9qh7a99wmzXPYdiDd9r4t4TIzL8XUzrrAzlYfPdgTr3pX0Xu17GPx2cgE2O5QX0rkYVBt+6 x/zXEXClFTG38t2EsaI2ndTeQl+zOKqnoUeRZ78cSsRZekaMDdohrDfQciI86OfvEdk1dbFoykRzB RuRDtt29zeeT1KSzi8Ire+21MhUGouXmB3SBNvCdzh7g7zNS5ED9moyW4dgNZtVCEyjQU7pM5NAzo sryErEhxgKSkn03o+VCQLnn6zxeIqY7ztamIuxsR98u9KNogyFd2KuDvGLjJJYVkQmYAOb/Yvltij sdkT5M+Vj+4g8P3ocx9g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qywZZ-00BjNs-2F; Fri, 03 Nov 2023 15:59:01 +0000 Received: from bg4.exmail.qq.com ([43.154.221.58]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qywZW-00BjMn-2m for linux-riscv@lists.infradead.org; Fri, 03 Nov 2023 15:59:00 +0000 X-QQ-mid: bizesmtp83t1699027115tqmp7mar Received: from main2-ubuntu.tail147f4.ts.net ( [202.201.15.117]) by bizesmtp.qq.com (ESMTP) with id ; Fri, 03 Nov 2023 23:58:32 +0800 (CST) X-QQ-SSF: 01200000000000B06000000A0000000 X-QQ-FEAT: 3M0okmaRx3gtg4dkowId3SRZK6iJt7bmG/bknUDKf+3ULUZKiHp/tkQ2jHTjZ qCAJtCYV+PBISnAzK2lTT9gQ93lFd4WLGlpACg09bFke2VMU51xGkofztcVkF64kLeB/I40 gt7AiMXFEF2xrMMx0HrXUSXv2jHoH+pff3Xms4oos9d5sxvTKIeoM4HgumgCEXWN1DXMZGG mOnRKFHyB0tdauEDaWiRCJ4WkEsUYt3jBksdkZqXTIOM4Sg1erJZuCIGNrgNzHJvUOE0TQI qfM8VoqG8AKNC9mj7MLM6aOKtJ7PJZrzG9XhTTXhE/GAatyk3aTKEWjcCrmwWhXqp/YBb1k Fal2Ut2duOE5o37lshvTGlRfYJ/VnEvHOdQu3tDN7OWkjvzEFMMskq1oA1G7g== X-QQ-GoodBg: 0 X-BIZMAIL-ID: 4824966276626844455 From: Yuan Tan To: falcon@tinylab.org, arnd@arndb.de, linux-kernel@vger.kernel.org, linux-mips@vger.kernel.org, linux-riscv@lists.infradead.org, luc.vanoostenryck@gmail.com, linux-sparse@vger.kernel.org Cc: linux@weissschuh.net, palmer@rivosinc.com, paul.walmsley@sifive.com, paulburton@kernel.org, paulmck@kernel.org, tim.bird@sony.com, tsbogend@alpha.franken.de, w@1wt.eu, tanyuan@tinylab.org, i@maskray.me Subject: [PATCH v1 01/14] DCE/DSE: allow keep unique bounded sections Date: Fri, 3 Nov 2023 23:58:30 +0800 Message-Id: X-Mailer: git-send-email 2.34.1 In-Reply-To: References: MIME-Version: 1.0 X-QQ-SENDSIZE: 520 Feedback-ID: bizesmtp:tinylab.org:qybglogicsvrgz:qybglogicsvrgz5a-1 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231103_085859_210752_B001399B X-CRM114-Status: GOOD ( 11.22 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org From: Zhangjin Wu The bounded sections may break the elimination of some dead code. Some unused syscalls have been wrongly kept by `__ex_table`, we will unique `__ex_table` for every inserting and then remove the unused ones explicitly and eventually, the unused syscalls will be eliminated. In the future, we should find better methods to solve such issue: Some code may use '.pushsection/.popsection' to insert data to a bounded section, use `sys_sendfile` as an example: sys_sendfile: ".pushsection __ex_table,\"\"\n" ... ".long ((" insn ") - .)\n" ... ".popsection" `insn` is an address in `sys_sendfile`, even if no real user uses sys_sendfile, the keeping of __ex_table will become a 'user' and break the elimination of `sys_sendfile`. All of the bounded sections should be uniqued, and we should check if they are the last users of the code, if so, those sections should be removed and the code should be eliminated. Signed-off-by: Zhangjin Wu --- include/asm-generic/vmlinux.lds.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h index 9c59409104f6..ea8170e11ab1 100644 --- a/include/asm-generic/vmlinux.lds.h +++ b/include/asm-generic/vmlinux.lds.h @@ -103,6 +103,7 @@ #define RODATA_MAIN .rodata .rodata.[0-9a-zA-Z_]* .rodata..L* #define BSS_MAIN .bss .bss.[0-9a-zA-Z_]* .bss..compoundliteral* #define SBSS_MAIN .sbss .sbss.[0-9a-zA-Z_]* +#define BSEC_MAIN(sec) sec sec##.[0-9a-zA-Z_]* #else #define TEXT_MAIN .text #define DATA_MAIN .data @@ -110,6 +111,7 @@ #define RODATA_MAIN .rodata #define BSS_MAIN .bss #define SBSS_MAIN .sbss +#define BSEC_MAIN(sec) sec #endif /* @@ -201,12 +203,12 @@ #define BOUNDED_SECTION_PRE_LABEL(_sec_, _label_, _BEGIN_, _END_) \ _BEGIN_##_label_ = .; \ - KEEP(*(_sec_)) \ + KEEP(*(BSEC_MAIN(_sec_))) \ _END_##_label_ = .; #define BOUNDED_SECTION_POST_LABEL(_sec_, _label_, _BEGIN_, _END_) \ _label_##_BEGIN_ = .; \ - KEEP(*(_sec_)) \ + KEEP(*(BSEC_MAIN(_sec_))) \ _label_##_END_ = .; #define BOUNDED_SECTION_BY(_sec_, _label_) \ From patchwork Fri Nov 3 15:58:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yuan Tan X-Patchwork-Id: 13444657 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id BB69AC0018A for ; Fri, 3 Nov 2023 15:59:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=mQu8Ca6ZzzKEcAslom85TEOQT4F4ao4rYYLhnInUrlQ=; b=wxSczEHKvBrvjY OrGwbSWaLEOG9yytx379FafBP5zeSjd333nLLDSx2ZfuspuVbiJo5Phfn/2AyGYyqZ3nv0BzBqwpZ xKSzMaIwdt14v82W/2rqC1cI8vPHRIGe+EGKclIFAyoY2BCgsVfX7za5HZNrDzYr+Ye+HUvnpzvVG NuvwNvQkrWph5Sin6W0XKmQQSlDPznc91QOV9q1roE9JQq37YjtEj/WwAv8N2ltC2GJckPX+LMqLF w7eYegK+NZsZjV63uzJHEUIzMbCdCQTSy3cnXPlOB1lH1IEsYYhyC2uH6LXZcUfcKVUhKDXNIP9vk yZHFOlHtE5fRf9NuY6Cg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qywZp-00BjRj-07; Fri, 03 Nov 2023 15:59:17 +0000 Received: from bg4.exmail.qq.com ([43.154.221.58]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qywZl-00BjQZ-3B for linux-riscv@lists.infradead.org; Fri, 03 Nov 2023 15:59:15 +0000 X-QQ-mid: bizesmtp86t1699027134tyw2b1v4 Received: from main2-ubuntu.tail147f4.ts.net ( [202.201.15.117]) by bizesmtp.qq.com (ESMTP) with id ; Fri, 03 Nov 2023 23:58:50 +0800 (CST) X-QQ-SSF: 01200000000000B06000000A0000000 X-QQ-FEAT: eSZ1CZgv+JCVHfF1wGxh8nF1q0geFQVjdp7+4eC2s5jBRXYvF4MCh5LGR7B+E 8+fmWyYidCbzrgu0MyIjfriJ59BganbsFbgX/5YcVpNzFbubzZ6dLiMjHahc457QS0HWkpM Fs+rI0pdcMyYCTK4SUwz0pMd3PBl01wPTUvQesEcQq+EJG/XuR2vXuTHrlODVWPty+yV/29 2Vnc8zaKv9YE6DbotW/r8+csDUkR1pa5ZtDVaUUN5+YVN0eCeGjKznkQB0jsEaGSMDKdrln 4vKFNLZIoLjH5UocAwhtcmVuhVONXyw1aSP1/0oQeB7WlrjtTw1rgFghaFSj/mHgl+ZkWO2 yA9Fx5mYFZAXRB61jZpB7Sq3gDPes8pPxQZSZMLehfXO4a96th3jTtVgpf52ywStnBsM5Uq X-QQ-GoodBg: 0 X-BIZMAIL-ID: 9783515542256517097 From: Yuan Tan To: falcon@tinylab.org, arnd@arndb.de, linux-kernel@vger.kernel.org, linux-mips@vger.kernel.org, linux-riscv@lists.infradead.org, luc.vanoostenryck@gmail.com, linux-sparse@vger.kernel.org Cc: linux@weissschuh.net, palmer@rivosinc.com, paul.walmsley@sifive.com, paulburton@kernel.org, paulmck@kernel.org, tim.bird@sony.com, tsbogend@alpha.franken.de, w@1wt.eu, tanyuan@tinylab.org, i@maskray.me Subject: [PATCH v1 02/14] compiler: add a global __QUITE_UNIQUE_ID() Date: Fri, 3 Nov 2023 23:58:49 +0800 Message-Id: <152d812cb6fa2c6018794ea7f05f487631542d6e.1699025537.git.tanyuan@tinylab.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: MIME-Version: 1.0 X-QQ-SENDSIZE: 520 Feedback-ID: bizesmtp:tinylab.org:qybglogicsvrgz:qybglogicsvrgz5a-1 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231103_085914_338847_D72FD8C0 X-CRM114-Status: GOOD ( 10.88 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org From: Zhangjin Wu Differs from __UNIQUE_ID(), __QUITE_UNIQUE_ID() also appends the __COUNTER__ info to make it more unique. Besides, seems assembly code also require such a unique id, let's make it global, the same to the required __PASTE macro. Signed-off-by: Zhangjin Wu --- I am not sure whether it is proper to put the __QUITE_UNIQUE_ID and other stuff later in compiler.h. Welcome discussion as this is just a preliminary approach. include/linux/compiler.h | 5 +++++ include/linux/compiler_types.h | 8 ++++---- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/include/linux/compiler.h b/include/linux/compiler.h index d7779a18b24f..405b19cf6cf3 100644 --- a/include/linux/compiler.h +++ b/include/linux/compiler.h @@ -227,6 +227,11 @@ static inline void *offset_to_ptr(const int *off) #endif /* __ASSEMBLY__ */ +/* Quite-unique ID. */ +#ifndef __QUITE_UNIQUE_ID +# define __QUITE_UNIQUE_ID(prefix) __PASTE(__PASTE(prefix, __LINE__), __COUNTER__) +#endif + /* &a[0] degrades to a pointer: a different type from an array */ #define __must_be_array(a) BUILD_BUG_ON_ZERO(__same_type((a), &(a)[0])) diff --git a/include/linux/compiler_types.h b/include/linux/compiler_types.h index c523c6683789..0b79e19d1017 100644 --- a/include/linux/compiler_types.h +++ b/include/linux/compiler_types.h @@ -70,10 +70,6 @@ static inline void __chk_io_ptr(const volatile void __iomem *ptr) { } # define __builtin_warning(x, y...) (1) #endif /* __CHECKER__ */ -/* Indirect macros required for expanded argument pasting, eg. __LINE__. */ -#define ___PASTE(a,b) a##b -#define __PASTE(a,b) ___PASTE(a,b) - #ifdef __KERNEL__ /* Attributes */ @@ -308,6 +304,10 @@ struct ftrace_likely_data { #endif /* __ASSEMBLY__ */ +/* Indirect macros required for expanded argument pasting, eg. __LINE__. */ +#define ___PASTE(a, b) a##b +#define __PASTE(a, b) ___PASTE(a, b) + /* * The below symbols may be defined for one or more, but not ALL, of the above * compilers. We don't consider that to be an error, so set them to nothing. From patchwork Fri Nov 3 15:58:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yuan Tan X-Patchwork-Id: 13444658 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 19B53C4332F for ; Fri, 3 Nov 2023 15:59:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=WFq4gpyrqCAd9NblLMNfqmR3btNX45E5Q6ib1tlUN2g=; b=P0paLojKdEhumh zlePrcIgsIPEXMm7hnn1L6hSz+fNjUXoHFIW6Xc2qQwEtn2rGymgYvOz9+snP/44FsgYfCmTnPqc+ L7gFl/6IfIzqGeGxclwqa8okz/z8RfGFhsxTZ30XuMCHBLbID2bGrt99UD8ScK92lonD6aKiWgUqs F9x6itAwQkMWwHDM5vsJ9CXutid2SmO1w2bkb26ETESl89F7PvEY+kUcK/02yposjlIZe+vPbQTOZ oh4JhwOej81kWeXtm/y3OcRznD/nuE7P00Af5uIMs/Nle13FUsbnHYVLuS51M9/9+OxItqy2GWXHv LM8fdbkp7PLp24gSAsrg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qywZw-00BjTX-2X; Fri, 03 Nov 2023 15:59:24 +0000 Received: from bg4.exmail.qq.com ([43.155.67.158]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qywZt-00BjSD-0F for linux-riscv@lists.infradead.org; Fri, 03 Nov 2023 15:59:22 +0000 X-QQ-mid: bizesmtp87t1699027144tuxhh48b Received: from main2-ubuntu.tail147f4.ts.net ( [202.201.15.117]) by bizesmtp.qq.com (ESMTP) with id ; Fri, 03 Nov 2023 23:59:01 +0800 (CST) X-QQ-SSF: 01200000000000B06000000A0000000 X-QQ-FEAT: LE7C6P2vL8TDvuFtQgm7U5nmg5IefRLiYgMU7BisqY8a+MfFY5YFw57t6eU2N mHG9XUzklv0HbI1UYbnludIhogZCI7W/IazcZj+b/17hSpDlk9STyb/1qy8aOE2wUbOzCOZ EJn/pf7LRNuuDgsl1ei03i4F64rI0B4WYb761k/inK0WMo/2LPTxfduiL64kC54tN2qYj6t hSep7h9sssI09uh7yXGRmhB/6Z75f2XrvS/dhZRHxDT6hhxRWQRSbLi4gjCZaegiLml9nXo uSCfn4EBkxIyImAQMxNPNtmyG7cYWqYRM00FNDOSz631ECpoP+OjLEe1sXE5O7xcvql3Riv 8CaSaqWCZoYQNtMBmJ3hnYreg2Te9iyb3F76nRBVtDUVxQ8ajDjjBSD9mAMXg== X-QQ-GoodBg: 0 X-BIZMAIL-ID: 6960832744754887515 From: Yuan Tan To: falcon@tinylab.org, arnd@arndb.de, linux-kernel@vger.kernel.org, linux-mips@vger.kernel.org, linux-riscv@lists.infradead.org, luc.vanoostenryck@gmail.com, linux-sparse@vger.kernel.org Cc: linux@weissschuh.net, palmer@rivosinc.com, paul.walmsley@sifive.com, paulburton@kernel.org, paulmck@kernel.org, tim.bird@sony.com, tsbogend@alpha.franken.de, w@1wt.eu, tanyuan@tinylab.org, i@maskray.me Subject: [PATCH v1 03/14] compiler: add unique __SECTION_NAME() Date: Fri, 3 Nov 2023 23:58:59 +0800 Message-Id: <3c10b123c7ec27fbd942dd9a07d877743616c935.1699025537.git.tanyuan@tinylab.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: MIME-Version: 1.0 X-QQ-SENDSIZE: 520 Feedback-ID: bizesmtp:tinylab.org:qybglogicsvrgz:qybglogicsvrgz5a-1 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231103_085921_420744_A1B4FF49 X-CRM114-Status: UNSURE ( 5.72 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org From: Zhangjin Wu The new section helper is added for LD_DEAD_CODE_DATA_ELIMINATION to generate unique section name (strigified). Signed-off-by: Zhangjin Wu Signed-off-by: Yuan Tan --- include/linux/compiler.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/include/linux/compiler.h b/include/linux/compiler.h index 405b19cf6cf3..5a9cc3209b12 100644 --- a/include/linux/compiler.h +++ b/include/linux/compiler.h @@ -227,11 +227,25 @@ static inline void *offset_to_ptr(const int *off) #endif /* __ASSEMBLY__ */ +/* Import __stringify. */ +#ifndef __stringify +#include +#endif + /* Quite-unique ID. */ #ifndef __QUITE_UNIQUE_ID # define __QUITE_UNIQUE_ID(prefix) __PASTE(__PASTE(prefix, __LINE__), __COUNTER__) #endif +/* Quite-unique Section NAME. */ +#ifndef __SECTION_NAME +#ifdef CONFIG_LD_DEAD_CODE_DATA_ELIMINATION +# define __SECTION_NAME(prefix) __stringify(__QUITE_UNIQUE_ID(prefix.)) +#else +# define __SECTION_NAME(prefix) __stringify(prefix) +#endif +#endif + /* &a[0] degrades to a pointer: a different type from an array */ #define __must_be_array(a) BUILD_BUG_ON_ZERO(__same_type((a), &(a)[0])) From patchwork Fri Nov 3 15:59:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yuan Tan X-Patchwork-Id: 13444659 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id EF495C4332F for ; Fri, 3 Nov 2023 15:59:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=f77aUZPazatdUIzsXrMJgbeottLVPv2+pxnSIvz4BHk=; b=nfHRyHJckech7K 5T1ZvzFVIsTyxwzFW9PyCSGQJz4wsi5EDMv57jau/zBpBGkMqqsoHuKuhFX6p3Lke+XHoOlJdXR1o rRf3zCKgFrvEDYXnQ3URKrRrDQdHwxIO+zziUjs42awpA+qhWFVsdB3F7jC8/2qX8kWZtWeKYjmMs 5JsuMfpsUB0p+qMWNZIU+bbUPq3IrmdWEaeSNC7KU29g3+yI+ck8BktRiodeXKAHKK7yDBSsCz+CA 1AaJcevcnyvZS11oGuSRakeix7LHcUV30LIzljh18blfjFV6b7yTBMSnqBAN6xLanI/66s/StDdft UYvTG8YDmUKU2LcGTZPQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qywa9-00BjWw-2M; Fri, 03 Nov 2023 15:59:37 +0000 Received: from bg4.exmail.qq.com ([43.155.67.158]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qywa6-00BjVK-1y for linux-riscv@lists.infradead.org; Fri, 03 Nov 2023 15:59:36 +0000 X-QQ-mid: bizesmtp64t1699027156tvs9nek9 Received: from main2-ubuntu.tail147f4.ts.net ( [202.201.15.117]) by bizesmtp.qq.com (ESMTP) with id ; Fri, 03 Nov 2023 23:59:13 +0800 (CST) X-QQ-SSF: 01200000000000B06000000A0000000 X-QQ-FEAT: znfcQSa1hKbGuZsoOVNlc1WvbvEkFGnTx1nx7spI6Tuzd0sHLnkw7AiMgni3t ZggaII50uNhW4y9QfvuvOyeS4F6auFyNTJw8NQCg+vLjRI5V2SC6LCN9adAn0v67sJ3OSX/ ApylcxyFajCfrERC+YlFJVy8SGFJrBzCX2pVZ4xg8IbilwZDlWfF607cx65tZkc/N5v0pBo 5KJ44BzBG+chXyP6BguFE6wzB2WGXdJq47gbtwJbgnW6dVctfCnU818SNsx7tWsczxLqyqh u4yC+u7f5c5hMGNKdyDBqUc2ZmUsHeTUO2gp5wzAo1jI1qkf08kTw9ItQQe6yQ05zfvbyXV s7UC4ZqDN0fbnt0BzlvuczseCniFWDH+IfzMMqsezOL6Jc3njt6dIop1FXbag== X-QQ-GoodBg: 0 X-BIZMAIL-ID: 3788500215190827511 From: Yuan Tan To: falcon@tinylab.org, arnd@arndb.de, linux-kernel@vger.kernel.org, linux-mips@vger.kernel.org, linux-riscv@lists.infradead.org, luc.vanoostenryck@gmail.com, linux-sparse@vger.kernel.org Cc: linux@weissschuh.net, palmer@rivosinc.com, paul.walmsley@sifive.com, paulburton@kernel.org, paulmck@kernel.org, tim.bird@sony.com, tsbogend@alpha.franken.de, w@1wt.eu, tanyuan@tinylab.org, i@maskray.me Subject: [PATCH v1 04/14] compiler: add unique LABEL_NAME() Date: Fri, 3 Nov 2023 23:59:11 +0800 Message-Id: X-Mailer: git-send-email 2.34.1 In-Reply-To: References: MIME-Version: 1.0 X-QQ-SENDSIZE: 520 Feedback-ID: bizesmtp:tinylab.org:qybglogicsvrgz:qybglogicsvrgz5a-1 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231103_085934_961181_EF5CD423 X-CRM114-Status: UNSURE ( 5.64 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org From: Zhangjin Wu unique LABEL is required by SHF_LINK_ORDER support. Signed-off-by: Zhangjin Wu --- include/linux/compiler.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/include/linux/compiler.h b/include/linux/compiler.h index 5a9cc3209b12..b178f5d51ad6 100644 --- a/include/linux/compiler.h +++ b/include/linux/compiler.h @@ -246,6 +246,12 @@ static inline void *offset_to_ptr(const int *off) #endif #endif +/* Unique Label NAME. */ +/* Label is file scope, __LINE__ is enough, and not change in the same macro call */ +#ifndef __LABEL_NAME +# define __LABEL_NAME(prefix) __stringify(__PASTE(__PASTE(prefix, _), __LINE__)) +#endif + /* &a[0] degrades to a pointer: a different type from an array */ #define __must_be_array(a) BUILD_BUG_ON_ZERO(__same_type((a), &(a)[0])) From patchwork Fri Nov 3 15:59:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yuan Tan X-Patchwork-Id: 13444660 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 321AEC4167D for ; Fri, 3 Nov 2023 16:00:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=WDaXLJrVUrJHYx0+B8N/nUMo+d1YEnnvd5Q7flknT+I=; b=FcfypRtmNFWf27 MJH6rgZdA7D9KUmvisXWVWi8xdT4NxM9K7vDl7ig5Uf4V3sRW2Fn0+jzsb9xO1JCRg0LXjxHZ65c9 2cvyMKqVoOLFf3aDRsj/PdAg3iUNakxpv4c5trC/6nqeG+Xv9IiT55Ukcsw+Og9Lw4nCHomzQmios BPpZunobfO1avlKFa/nPMg5SOeQNDVa9hGOtEa1xXAyJZ1JGaKBOnzpF0M6W9lquBoyV1Yznjh5ko jpdYNZgiMbkcrHK9e6/FLq/fGM0HYrvaRWW+dNtCJ5uc0qmro2lJTd+QJorqtRQ/NARwp8Cd9orGz mtTwnsJdbqoAb2f94pfQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qywap-00Bjgy-1a; Fri, 03 Nov 2023 16:00:19 +0000 Received: from bg4.exmail.qq.com ([43.154.221.58]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qywam-00Bjfw-2J for linux-riscv@lists.infradead.org; Fri, 03 Nov 2023 16:00:18 +0000 X-QQ-mid: bizesmtp89t1699027199tr6cexfv Received: from main2-ubuntu.tail147f4.ts.net ( [202.201.15.117]) by bizesmtp.qq.com (ESMTP) with id ; Fri, 03 Nov 2023 23:59:56 +0800 (CST) X-QQ-SSF: 01200000000000B06000000A0000000 X-QQ-FEAT: J5JfekO1WsiW/sSK9b0/2SRgOwgztbvJaqippsUrhkBT0nfPERe3CiBmcwtjz QpzvzTaAyarFENK22g18sd4WrJtroYvGBndfc+80wj7YD8GXTPFE63PYdZfssoaggn37JF1 CeT4asgR6uqXE743WuMFyc0x2/w6p5rmPS5RdVkWpq1wdgAirUOvzdxBnfp/BH/yVAOG+VK nuqwGFmYsfi5b7WwIDnPQEhZN6hZb6/eGcz4PwK7TFD10lDLnMuVyHe9WS6+GDJ8RvQ2t0+ CRr+zifxj6GjZOuv7Gm2iGWovRvgRTB53/KK2DBFh1siV3bXj3z8JS2Obvsu+/t7oibKU9q 0uW9Al7Boxi073MJVkzuvWKDvgsnA== X-QQ-GoodBg: 0 X-BIZMAIL-ID: 6517666058283072593 From: Yuan Tan To: falcon@tinylab.org, arnd@arndb.de, linux-kernel@vger.kernel.org, linux-mips@vger.kernel.org, linux-riscv@lists.infradead.org, luc.vanoostenryck@gmail.com, linux-sparse@vger.kernel.org Cc: linux@weissschuh.net, palmer@rivosinc.com, paul.walmsley@sifive.com, paulburton@kernel.org, paulmck@kernel.org, tim.bird@sony.com, tsbogend@alpha.franken.de, w@1wt.eu, tanyuan@tinylab.org, i@maskray.me Subject: [PATCH v1 05/14] DCE/DSE: add HAVE_SECTION_SHF_LINK_ORDER_SUPPORT option Date: Fri, 3 Nov 2023 23:59:54 +0800 Message-Id: <141030de2b3d470251d1588b39cb041ec505d84f.1699025537.git.tanyuan@tinylab.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: MIME-Version: 1.0 X-QQ-SENDSIZE: 520 Feedback-ID: bizesmtp:tinylab.org:qybglogicsvrgz:qybglogicsvrgz5a-1 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231103_090017_070443_3AE74D1A X-CRM114-Status: UNSURE ( 6.99 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org SHF_LINK_ORDER requires ld >= 2.35. LLD supports SHF_LINK_ORDER to, but it does not support riscv HAVE_LD_DEAD_CODE_DATA_ELIMINATION. Therefore, I haven't tested the minimum compatible version yet. Signed-off-by: Yuan Tan Signed-off-by: Zhangjin Wu --- init/Kconfig | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/init/Kconfig b/init/Kconfig index aa648ce8bca1..1ef5b19918e5 100644 --- a/init/Kconfig +++ b/init/Kconfig @@ -1462,6 +1462,11 @@ config HAVE_TRIM_UNUSED_SYSCALLS depends on HAVE_LD_DEAD_CODE_DATA_ELIMINATION default n +config HAVE_SECTION_SHF_LINK_ORDER_SUPPORT + bool + depends on AS_IS_GNU && AS_VERSION >= 23500 + default y + menuconfig EXPERT bool "Configure standard kernel features (expert users)" # Unhide debug options, to make the on-by-default options visible From patchwork Fri Nov 3 16:00:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yuan Tan X-Patchwork-Id: 13444661 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 60452C4167D for ; Fri, 3 Nov 2023 16:00:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=BEYfm6wS2TWSUFQRLP/vQzaH4iz1ZcjCK8hm1V+jrtw=; b=3DPCnVgvfxyh6p aLRkhfl1iI9Lrju7f0P6QH+VHBSBiVfXgodmgLkOMHEL7QEEf4tqakS5GqV2w1skz6pveFuno5LfN 4IRL9U/M1hf9neJrvRmMUlTXIEUnwxa2LBaHmD+V4z6ISlHPWco0L4ORsQbKuP25gGLUI2iNoIcN/ sNd2Ug01oFu+N5XZ43c8ae13epQfeaIGUvXyjL+tKsWUkObm+egeLGFP2DwYPR49VVS6GsxSVuASi rhC9eQYL1x7mJ23c4PMztf0jt7+KW/WruAgnqXq14OS/5ybSwHXV/prGsc2i8vOLoHu5nwzU1gBUf JTAvwKnA5xgLlIjSqDgw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qywbA-00BjmB-2L; Fri, 03 Nov 2023 16:00:40 +0000 Received: from bg4.exmail.qq.com ([43.154.221.58]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qywb7-00BjlB-13 for linux-riscv@lists.infradead.org; Fri, 03 Nov 2023 16:00:38 +0000 X-QQ-mid: bizesmtp87t1699027218tobnpga2 Received: from main2-ubuntu.tail147f4.ts.net ( [202.201.15.117]) by bizesmtp.qq.com (ESMTP) with id ; Sat, 04 Nov 2023 00:00:15 +0800 (CST) X-QQ-SSF: 01200000000000B06000000A0000000 X-QQ-FEAT: +ynUkgUhZJkQaK3UoZkl8UFfBrmOfnK/yegytHp4rc1pb7b3un2ZnJljIAZmQ SyXnHa++l4m7fRjBIwpFo2yvoE/z+Ce3xG96JEz4TUS94+884spbt6QK0ijO0pys/0ZRtXT yTJ4KdwcAqHHm5OmVSBQkAf2mXr2BFgZ8g576cDxArslhY/NINryQd/xWCqsDWIMikhIK5H F80QRPBTraDKtfwcPifb2vihwGdJnwe9t6tWh5K+jA32jgVR2NAE3gNY43CdkZKiUzIK/a2 2z0Yjtc8JZajCom/XHmuU5CGRQIrP77qUPwshGoOPHCfrSCD//QjBQ3x/AqijADYI8wvpru bFuICpJ75TWkL/kTNaxMRL/UNMNcWL/Kyk4wkY2UyFKdKCjwzNjoUiJ1OI76g== X-QQ-GoodBg: 0 X-BIZMAIL-ID: 8486065313594138101 From: Yuan Tan To: falcon@tinylab.org, arnd@arndb.de, linux-kernel@vger.kernel.org, linux-mips@vger.kernel.org, linux-riscv@lists.infradead.org, luc.vanoostenryck@gmail.com, linux-sparse@vger.kernel.org Cc: linux@weissschuh.net, palmer@rivosinc.com, paul.walmsley@sifive.com, paulburton@kernel.org, paulmck@kernel.org, tim.bird@sony.com, tsbogend@alpha.franken.de, w@1wt.eu, tanyuan@tinylab.org, i@maskray.me Subject: [PATCH v1 06/14] DCE/DSE: add HAVE_SECTION_SHF_GROUP_SUPPORT option Date: Sat, 4 Nov 2023 00:00:14 +0800 Message-Id: <04271c1f3a4c3d369310146faefc0d05144276e9.1699025537.git.tanyuan@tinylab.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: MIME-Version: 1.0 X-QQ-SENDSIZE: 520 Feedback-ID: bizesmtp:tinylab.org:qybglogicsvrgz:qybglogicsvrgz5a-1 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231103_090037_674434_43835A6C X-CRM114-Status: UNSURE ( 6.57 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org SHF_GROUP requires ld >= 2.36. LLD supports SHF_GROUP too, but it does not support riscv HAVE_LD_DEAD_CODE_DATA_ELIMINATION. Therefore, I haven't tested the minimum compatible version yet. Signed-off-by: Yuan Tan Signed-off-by: Zhangjin Wu --- init/Kconfig | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/init/Kconfig b/init/Kconfig index 1ef5b19918e5..4296c97cfc84 100644 --- a/init/Kconfig +++ b/init/Kconfig @@ -1467,6 +1467,11 @@ config HAVE_SECTION_SHF_LINK_ORDER_SUPPORT depends on AS_IS_GNU && AS_VERSION >= 23500 default y +config HAVE_SECTION_SHF_GROUP_SUPPORT + bool + depends on AS_IS_GNU && AS_VERSION >= 23600 + default y + menuconfig EXPERT bool "Configure standard kernel features (expert users)" # Unhide debug options, to make the on-by-default options visible From patchwork Fri Nov 3 16:00:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yuan Tan X-Patchwork-Id: 13444662 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 23A20C4332F for ; Fri, 3 Nov 2023 16:01:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=jso41RErdgCJIRvOCuC+QcE/wVLSGEBrdn8EZKt4o4A=; b=qvzI6gJAzTzKQ6 6MEG6/Yd8KnWF84wh09EcVof6liuHAN/rKtPE6yv1aRsAYqnXp9rfVxJ4LdoOc66YC68eMJcpQEAr +xM/PW8vuwa9QOG7GHHp86kIq4XvEe8EVf5uqEm/Yk2Hb5XuYx1QlCBE7aDvsEIO+ab/rzyv3vWBH ywpcyg3/kWiLmwlCT4s8Kg2JUICKeK7rr6he+BoSRT8Tr/IcfHpVb+zDDuGhMNssW61ez3wts5Yta d5yGi9K7BDYNy9zjwzM+tMdNmlVVxWy//CpWVEhhr6f6+Y6Wx9eY3b/Q1bQi/B7GRXyTYGAY3k5Xq hHlEGTTP2xmh886cIHCw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qywbP-00Bjqm-2J; Fri, 03 Nov 2023 16:00:55 +0000 Received: from bg4.exmail.qq.com ([43.155.67.158]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qywbM-00BjpE-2n for linux-riscv@lists.infradead.org; Fri, 03 Nov 2023 16:00:54 +0000 X-QQ-mid: bizesmtp64t1699027236t5ijv5ky Received: from main2-ubuntu.tail147f4.ts.net ( [202.201.15.117]) by bizesmtp.qq.com (ESMTP) with id ; Sat, 04 Nov 2023 00:00:33 +0800 (CST) X-QQ-SSF: 01200000000000B06000000A0000000 X-QQ-FEAT: rZJGTgY0+YOXiDRtSv5jrBH+Ok8Gp19fhcj4KioUSMpuqQklo5ZZQc/JPJ8NP EtrPZ1izysnRKGJpccJps5x7PACRlaGOgqrbhQsoXPYIL0wptOzTr59TlmxVaci9hDwmWW3 p2AG5vAakwXzlGOvAVJVj+6geI4kiy35fnAl8Hxgjur7eOzsHK3fr/I5H8UeJZfgM66PbGn yeYjqTHLgymXpyzEuYFaXxOuqvZ/uCI5ZmMmOhTzMnqvs5W/vD7crDXrQQkhlJGtCD99gYw TlsX5JstKOh466iu7/6cBHsznx3S3ZdcSo34kwI/IMvXXT09A715opfHEEVuc05iI+uAU/L 64Ij+YmTR0MwCKVFG9rPTnOMLXFsQg6LeXI01q9jVrDUx/zPUETEnoZ/zd554YXkD/vc5qy X-QQ-GoodBg: 0 X-BIZMAIL-ID: 8259172485907225114 From: Yuan Tan To: falcon@tinylab.org, arnd@arndb.de, linux-kernel@vger.kernel.org, linux-mips@vger.kernel.org, linux-riscv@lists.infradead.org, luc.vanoostenryck@gmail.com, linux-sparse@vger.kernel.org Cc: linux@weissschuh.net, palmer@rivosinc.com, paul.walmsley@sifive.com, paulburton@kernel.org, paulmck@kernel.org, tim.bird@sony.com, tsbogend@alpha.franken.de, w@1wt.eu, tanyuan@tinylab.org, i@maskray.me Subject: [PATCH v1 07/14] DCE/DSE: add HAVE_SECTION_NO_KEEP_SUPPORT option Date: Sat, 4 Nov 2023 00:00:31 +0800 Message-Id: <494854689a6f6f91da151ae4bd9a7a6132092271.1699025537.git.tanyuan@tinylab.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: MIME-Version: 1.0 X-QQ-SENDSIZE: 520 Feedback-ID: bizesmtp:tinylab.org:qybglogicsvrgz:qybglogicsvrgz5a-1 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231103_090053_213959_DABBCE92 X-CRM114-Status: UNSURE ( 6.03 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org Once there's SECTION_SHF_LINK_ORDER_SUPPORT or SECTION_SHF_GROUP_SUPPORT, there won't be any orphan section and won't need KEEP() anymore. Signed-off-by: Yuan Tan Signed-off-by: Zhangjin Wu --- init/Kconfig | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/init/Kconfig b/init/Kconfig index 4296c97cfc84..9834dbb0ddae 100644 --- a/init/Kconfig +++ b/init/Kconfig @@ -1462,6 +1462,11 @@ config HAVE_TRIM_UNUSED_SYSCALLS depends on HAVE_LD_DEAD_CODE_DATA_ELIMINATION default n +config HAVE_SECTION_NO_KEEP_SUPPORT + bool + depends on HAVE_SECTION_SHF_LINK_ORDER_SUPPORT || HAVE_SECTION_SHF_GROUP_SUPPORT + default y + config HAVE_SECTION_SHF_LINK_ORDER_SUPPORT bool depends on AS_IS_GNU && AS_VERSION >= 23500 From patchwork Fri Nov 3 16:01:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yuan Tan X-Patchwork-Id: 13444663 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id DD6E3C4332F for ; Fri, 3 Nov 2023 16:01:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=bUpGpVQdetPDK1MFs3JyvQuX0LI3MqU7DHV3R2g0kBQ=; b=KAteJe9TV6Vlgl E6gM4M1fUVWXv3rmIBi1Beyhh96+rDeT4F9QXGvkHBinz4Q+BZ5gxv2Yf++/czNC7NAXmeXytdlq+ 0hYBw2z0KbS0nwe1GWc0QNrR62cDd8CxXTGpxkcISawhBPwqmYEVlcRu5F3iGiTC4SbJKbJMEdSeq SFN71BUirfqueTFQqhshYqTJVYLBxQm5XgfD1I8tD8qk0efLUBQ0FJzQr8fADIsqZoLaZEyLFJn6g DshVAZxldXWxHTnY6QIbQjAhXC5aEmmkkJ46hQ9Dxkg+msI2VA7aanlitgaWmnB09reLfuM00Q6BK xFDHt0xIzpplgI05Ds+A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qywby-00BjzR-2r; Fri, 03 Nov 2023 16:01:30 +0000 Received: from bg4.exmail.qq.com ([43.154.221.58]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qywbw-00Bjy4-04 for linux-riscv@lists.infradead.org; Fri, 03 Nov 2023 16:01:29 +0000 X-QQ-mid: bizesmtp78t1699027266ta08iml2 Received: from main2-ubuntu.tail147f4.ts.net ( [202.201.15.117]) by bizesmtp.qq.com (ESMTP) with id ; Sat, 04 Nov 2023 00:01:03 +0800 (CST) X-QQ-SSF: 01200000000000000000000A0000000 X-QQ-FEAT: QityeSR92A28ZPRtiE81G2IrXHWg2q27WIobMU1SAAzpzkyyfEB73YsFcjdDe bVIiFyAUAwy8zzKzjrseeMWj0rb6pexvSi+JMipbHYhQxpuclzEMg7X6cSFvfm0zUbuvUkH h53yUWwjypGaV/yCfz9llOfRSJAl345Te7BpmmwciccZriF1iTUIX3Acz0VVcqgLQLxij90 vmo9hUQ4XmPwLxfIwOPQoqiZRoQRMntdfHYmU86oxGlguDcOLX+hQcU1iiGjDNaJ56wmm5f d1CU19gnS85haVh9DhVlHm0SEjXqii66p+6zMkbYe99A6q5hm0RXrwcR0y5/I8ghUS3d/Qn 7FA36k1Kp5SCYysOg6IbHNlCGA9XQ9hupgoQtSoicunaxLd4PZDp6bU1S/y2A== X-QQ-GoodBg: 0 X-BIZMAIL-ID: 17055644200842692498 From: Yuan Tan To: falcon@tinylab.org, arnd@arndb.de, linux-kernel@vger.kernel.org, linux-mips@vger.kernel.org, linux-riscv@lists.infradead.org, luc.vanoostenryck@gmail.com, linux-sparse@vger.kernel.org Cc: linux@weissschuh.net, palmer@rivosinc.com, paul.walmsley@sifive.com, paulburton@kernel.org, paulmck@kernel.org, tim.bird@sony.com, tsbogend@alpha.franken.de, w@1wt.eu, tanyuan@tinylab.org, i@maskray.me Subject: [PATCH v1 08/14] DCE/DSE: add choice of methods to build reference for orphan sections Date: Sat, 4 Nov 2023 00:01:01 +0800 Message-Id: X-Mailer: git-send-email 2.34.1 In-Reply-To: References: MIME-Version: 1.0 X-QQ-SENDSIZE: 520 Feedback-ID: bizesmtp:tinylab.org:qybglogicsvrgz:qybglogicsvrgz5a-1 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231103_090128_369510_52D510FF X-CRM114-Status: UNSURE ( 9.31 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org Due to .pushsection producing orphan sections, the kernel currently uses `KEEP()` in the linker script to address this issue. Here we purpose two methods to build reference for pushed section, SHF_LINK_ORDER method and SECTION_SHF_GROUP method. The binary files compiled using both methods turn out to be identical, and it doesn't produce any side effects. Signed-off-by: Yuan Tan Signed-off-by: Zhangjin Wu --- init/Kconfig | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/init/Kconfig b/init/Kconfig index 9834dbb0ddae..9599d2de44e8 100644 --- a/init/Kconfig +++ b/init/Kconfig @@ -1740,6 +1740,56 @@ config USED_SYSCALLS If unsure, please disable TRIM_UNUSED_SYSCALLS. +choice + prompt "Trim methods" if EXPERT + default RESTRICTED_TRIM_UNUSED_SYSCALLS + depends on TRIM_UNUSED_SYSCALLS + help + This option selects the method to trim unused syscall wrongly kept. + + The binary files compiled using both methods are identical. + + If the trim methods is not specified, some syscalls are kept by + linker script and can not be trimmed. + +config RESTRICTED_TRIM_UNUSED_SYSCALLS + bool "Leave some kept syscalls (EXPERIMENTAL)" if EXPERT + help + Say Y here to trim 'unused' syscalls wrongly kept by __ex_table + like sections in kernel space. + + Some syscalls are kept by linker script and can not be trimmed. + + If unsure, choose this. + +config SECTION_SHF_LINK_ORDER_SUPPORT + bool "Using SHF_LINK_ORDER attribute (EXPERIMENTAL)" if EXPERT + depends on HAVE_SECTION_SHF_LINK_ORDER_SUPPORT + help + Say Y here to trim more 'unused' syscalls wrongly kept by __ex_table + like sections in kernel space. + + This option uses the SHF_LINK_ORDER attribute to build references for + orphan sections. Therefore, these sections are no longer kept in the + linker script. + + If unsure, not choose this. + +config SECTION_SHF_GROUP_SUPPORT + bool "Using SHF_GROUP attribute (EXPERIMENTAL)" if EXPERT + depends on HAVE_SECTION_SHF_GROUP_SUPPORT + help + Say Y here to trim more 'unused' syscalls wrongly kept by __ex_table + like sections in kernel space. + + This option uses the SHF_GROUP attribute to build references for + orphan sections. Therefore, these sections are no longer kept in the + linker script. + + If unsure, not choose this. + +endchoice + config KALLSYMS bool "Load all symbols for debugging/ksymoops" if EXPERT default y From patchwork Fri Nov 3 16:01:55 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yuan Tan X-Patchwork-Id: 13444664 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 0DBACC4332F for ; Fri, 3 Nov 2023 16:02:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=5XCBmylLTj5uU5QjE5DJA0QqTxGTV2b3otcR2YbBTfM=; b=RWvcMZQjPJ9or3 1xFJpoNpWOfj/ifYecC5IIGhsp1nfInhLFTTyJ9wHRqOdTnyWNAXKrgsTLIccLxwvg2iBbDImF4f7 rO1nRz1x73iSNW4ttOwloVsOKrL965Qxj8xIo0r34vFbeCSbpqS/kTZdBArE9qPBs1b/2Pk/Bh2+2 X9TEYCYBZvAMhw1n4PyXHMWvKIUYb7tun5osaWWzsaZVIfsv++CRzTC92VewfhfzfgNND9mCtFhyV dGyVjxvtrSXT/AOlZ34/mdw4Fr1EToikI/fhZH0+1NQR2zpuf0JUkS8sxS9epvgcZX3dWsyxIoGwy 3d67YcSt0+LmbHF3CWsw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qywcm-00BkLN-2R; Fri, 03 Nov 2023 16:02:20 +0000 Received: from bg4.exmail.qq.com ([43.154.221.58]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qywcj-00BkK1-2E for linux-riscv@lists.infradead.org; Fri, 03 Nov 2023 16:02:19 +0000 X-QQ-mid: bizesmtp66t1699027320t0x8xgof Received: from main2-ubuntu.tail147f4.ts.net ( [202.201.15.117]) by bizesmtp.qq.com (ESMTP) with id ; Sat, 04 Nov 2023 00:01:57 +0800 (CST) X-QQ-SSF: 01200000000000B06000000A0000000 X-QQ-FEAT: WQH7Uj+YMzXZTIeeYrzzH5itva0gXKImwAhNhNH+6I4DrfveqC5LRL/AcrFVZ 2/7bONsuYtIn2ySjQU5hL5gWFOT7EvhlXQ1iFCFG8OaKZP82pUKHeAwChH+M65VreM8t5le MEaIGsQTivG4RvqDkHbOYJyCINDKGWbhCKa0dUgjtXcRjNQmYo+pBt7KJc23OgX11rPo9HH eolIdA7eZrnIQZKidwNzLUodbR1P5fT1YDTe/GJ96w1sqVpiiORBTxHvJJR8fCReTgImbhn xk8Hctv3kJsMKpvxmjJqlVVP2vs4VDq6gBW71Z2pzucXzcbSYEcpsDNDwo0ITDvRO3EglyR gZFh+VYSI8gOs/YSPsMhwdqkvgrOUqcnzKKQlenAv7mO2o1OXg= X-QQ-GoodBg: 0 X-BIZMAIL-ID: 8381555887930633905 From: Yuan Tan To: falcon@tinylab.org, arnd@arndb.de, linux-kernel@vger.kernel.org, linux-mips@vger.kernel.org, linux-riscv@lists.infradead.org, luc.vanoostenryck@gmail.com, linux-sparse@vger.kernel.org Cc: linux@weissschuh.net, palmer@rivosinc.com, paul.walmsley@sifive.com, paulburton@kernel.org, paulmck@kernel.org, tim.bird@sony.com, tsbogend@alpha.franken.de, w@1wt.eu, tanyuan@tinylab.org, i@maskray.me Subject: [PATCH v1 09/14] DCE/DSE: inhibit .size directive for SHF_GROUP Date: Sat, 4 Nov 2023 00:01:55 +0800 Message-Id: <7807078d4612beaa3f450df9f3f3cf70b2bccb4a.1699025537.git.tanyuan@tinylab.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: MIME-Version: 1.0 X-QQ-SENDSIZE: 520 Feedback-ID: bizesmtp:tinylab.org:qybglogicsvrgz:qybglogicsvrgz5a-1 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231103_090218_039211_73918C8E X-CRM114-Status: UNSURE ( 6.00 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org .size directive fails in some functions with SHF_GROUP, this is not really required for normal building, inhibit it to silence the compiling failures with SHF_GROUP. Signed-off-by: Yuan Tan Signed-off-by: Zhangjin Wu --- Makefile | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Makefile b/Makefile index a4e522b747cb..f67b6e8d2c45 100644 --- a/Makefile +++ b/Makefile @@ -936,6 +936,9 @@ endif # `rustc`'s `-Zfunction-sections` applies to data too (as of 1.59.0). ifdef CONFIG_LD_DEAD_CODE_DATA_ELIMINATION KBUILD_CFLAGS_KERNEL += -ffunction-sections -fdata-sections +ifdef CONFIG_SECTION_SHF_GROUP_SUPPORT +KBUILD_CFLAGS_KERNEL += -finhibit-size-directive +endif KBUILD_RUSTFLAGS_KERNEL += -Zfunction-sections=y LDFLAGS_vmlinux += --gc-sections ifdef CONFIG_LD_DEAD_CODE_DATA_ELIMINATION_DEBUG From patchwork Fri Nov 3 16:02:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yuan Tan X-Patchwork-Id: 13444665 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 1503FC4332F for ; Fri, 3 Nov 2023 16:02:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=bCSjY9YkWb/Je9sP3MLhvtl0AX6y+4H94z8FmsR4U5o=; b=G5ts7zJC6nYNSY KU9V6Q2qIRPp2hP7drOKD0DxFOuVcAED7MBVdi2mMnf6Cza0kqHovD5I3TDMVMT5FJnFxkrb4D8S7 6IfYFUrYgEH1mKmTR5qAR53wdufO4L+q0FL+phq1Z7EFx6xBf5kKvJocN9isCQij0TSBdQOYMtEU5 cbA82J0AENPmUZbIW6g3M9M6855j2+05/B+ehAca4fNKZA1twkTvFrfmb8Hg+bDvD7c/nVOyFPfSN hoYmVOtRTRw76siV/fSD9KKt/GYuKZ78Wae1wrawvqXbeINqlovtGSo6BxW2mCiq1LMJUcZksCVhT EvmnNnaPA7l+JzOaqLfw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qywdC-00BkT3-00; Fri, 03 Nov 2023 16:02:46 +0000 Received: from bg4.exmail.qq.com ([43.154.221.58]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qywd8-00BkRB-24 for linux-riscv@lists.infradead.org; Fri, 03 Nov 2023 16:02:44 +0000 X-QQ-mid: bizesmtp91t1699027345tuzi88hk Received: from main2-ubuntu.tail147f4.ts.net ( [202.201.15.117]) by bizesmtp.qq.com (ESMTP) with id ; Sat, 04 Nov 2023 00:02:22 +0800 (CST) X-QQ-SSF: 01200000000000B06000000A0000000 X-QQ-FEAT: YlW+rreuxxXoxvlIlb1sqNHnSOT+l5Yn7jheMGM0MN7wg16F1FQezu3ESPCIn SG4dX7pl9FbKYtPlw5xFGKF9hdEiY4GXCO8Dcbx8/cg7Og+QCU3+CXMPCfzr3ILF+7b8OJC We3CArNs3/RzbQomd2+K7yNXkmGAdxxgFstmrUQolP47JcSLPCcnWVH+pzG+WBKc95SRuk6 GRNeVQS005EaooagskyJFuMF58jFp792MV4/nMVDor5tdI0R+v9ntYb8OLdlo+bjQBPaFjZ 3tXMXILkQNqiZOfSFuWlhMCs5t5EvoYMyXZptegM68V3A/gfjehT5qri7Me9UwyV2uMy7Yw qI4nF3fFj9RVpkTbEo40dXUlw5DXyqiA0exePUzOcNNH73+MM0= X-QQ-GoodBg: 0 X-BIZMAIL-ID: 1289692222090341736 From: Yuan Tan To: falcon@tinylab.org, arnd@arndb.de, linux-kernel@vger.kernel.org, linux-mips@vger.kernel.org, linux-riscv@lists.infradead.org, luc.vanoostenryck@gmail.com, linux-sparse@vger.kernel.org Cc: linux@weissschuh.net, palmer@rivosinc.com, paul.walmsley@sifive.com, paulburton@kernel.org, paulmck@kernel.org, tim.bird@sony.com, tsbogend@alpha.franken.de, w@1wt.eu, tanyuan@tinylab.org, i@maskray.me Subject: [PATCH v1 10/14] DCE/DSE: riscv: make every ex_table's name unique Date: Sat, 4 Nov 2023 00:02:18 +0800 Message-Id: X-Mailer: git-send-email 2.34.1 In-Reply-To: References: MIME-Version: 1.0 X-QQ-SENDSIZE: 520 Feedback-ID: bizesmtp:tinylab.org:qybglogicsvrgz:qybglogicsvrgz5a-1 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231103_090242_987811_847520E9 X-CRM114-Status: UNSURE ( 6.09 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org gc-sections require section names to be unique. Signed-off-by: Yuan Tan Signed-off-by: Zhangjin Wu --- arch/riscv/include/asm/asm-extable.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/arch/riscv/include/asm/asm-extable.h b/arch/riscv/include/asm/asm-extable.h index 00a96e7a9664..d0be5a838242 100644 --- a/arch/riscv/include/asm/asm-extable.h +++ b/arch/riscv/include/asm/asm-extable.h @@ -9,10 +9,12 @@ #ifdef CONFIG_MMU +#include + #ifdef __ASSEMBLY__ #define __ASM_EXTABLE_RAW(insn, fixup, type, data) \ - .pushsection __ex_table, "a"; \ + .pushsection __SECTION_NAME(__ex_table), "a"; \ .balign 4; \ .long ((insn) - .); \ .long ((fixup) - .); \ @@ -31,7 +33,7 @@ #include #define __ASM_EXTABLE_RAW(insn, fixup, type, data) \ - ".pushsection __ex_table, \"a\"\n" \ + ".pushsection " __SECTION_NAME(__ex_table) ", \"a\"\n" \ ".balign 4\n" \ ".long ((" insn ") - .)\n" \ ".long ((" fixup ") - .)\n" \ From patchwork Fri Nov 3 16:02:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yuan Tan X-Patchwork-Id: 13444682 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id EA025C4167B for ; Fri, 3 Nov 2023 16:03:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=WvgEBd+z3R1hZafUgpe4MhHrx/LQn4g9NGBJy72yZgM=; b=MKuoIfXGTdNZ8J R+wOzlcqrcIrBhpyI253vKYiaOj2GKMpCG290waFZiUS3xeKC708N+cLqDANN+R7oX15LlDD44Owl qpuRF8l3zIKobkSbWci5TUzC7PVJT4wiHePiG+T+h9MQabnghIB4se4SxeMmXBR2V2kro5VhcE3Mx nts99XHndHu8DSsl/ChNfcdvvg05AnOydF9QwoG6Th7kx5CL3MadIHCy4U8bNGFL+5V7ZuBiXCo64 XTek9k6RhZVy8grUmip5IMhH4Lin8t5pwcuN72IaMzUdBZrHUgiQVcGSNtWFSXsDIZoYEPyQl8Q+Q rpPE+hzJlaQFZ16XjmYQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qywdi-00BkdN-02; Fri, 03 Nov 2023 16:03:18 +0000 Received: from bg4.exmail.qq.com ([43.155.67.158]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qywde-00BkbT-1Q for linux-riscv@lists.infradead.org; Fri, 03 Nov 2023 16:03:16 +0000 X-QQ-mid: bizesmtp71t1699027375tdhm453g Received: from main2-ubuntu.tail147f4.ts.net ( [202.201.15.117]) by bizesmtp.qq.com (ESMTP) with id ; Sat, 04 Nov 2023 00:02:52 +0800 (CST) X-QQ-SSF: 01200000000000B06000000A0000000 X-QQ-FEAT: NcwpCxVQ7UNhf+mNoYKTlmUzCKrTx3/uLfRK9iw8b01sSRqpsgDYV8WUoq0+F bEVqW3uxHwMcq7cQk2v9IJTcEH5r/B/VLMPT6wOIogDyXcUP+URvzaHAuu/LDdBPo2y2PfX 7Mvj8Mqe2Ivk0sKa4LuqIN72w9m3gc5Lcqg/zqWO640FM0vG0kG9EircxCKhMl7uzB00yoH 1GP93ZVIalqTmrPj4vUjf6sev/hgXIrNQSDbJHjlwx52aJ9EmGcU4IM89eMwaKIUIKHp/FG vghOQ3hDkGX/eU+m4e94hHqprk/L/vOU8YSOvFJylFesXI+PLvYCD4xzTz8P1EhFUlvtRb/ xog9r+mNfQz65z8LEQVxAy/3lxXueH3B9eIMSnlsByWsQU4YjU= X-QQ-GoodBg: 0 X-BIZMAIL-ID: 14770929756585809619 From: Yuan Tan To: falcon@tinylab.org, arnd@arndb.de, linux-kernel@vger.kernel.org, linux-mips@vger.kernel.org, linux-riscv@lists.infradead.org, luc.vanoostenryck@gmail.com, linux-sparse@vger.kernel.org Cc: linux@weissschuh.net, palmer@rivosinc.com, paul.walmsley@sifive.com, paulburton@kernel.org, paulmck@kernel.org, tim.bird@sony.com, tsbogend@alpha.franken.de, w@1wt.eu, tanyuan@tinylab.org, i@maskray.me Subject: [PATCH v1 11/14] DCE/DSE: riscv: build reference for .pushsection in C functions Date: Sat, 4 Nov 2023 00:02:50 +0800 Message-Id: X-Mailer: git-send-email 2.34.1 In-Reply-To: References: MIME-Version: 1.0 X-QQ-SENDSIZE: 520 Feedback-ID: bizesmtp:tinylab.org:qybglogicsvrgz:qybglogicsvrgz5a-1 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231103_090314_785938_35800031 X-CRM114-Status: UNSURE ( 6.84 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org Add the SECTION_SHF_LINK_ORDER method and the SECTION_SHF_GROUP method to refactor __ASM_EXTABLE_RAW, so it won't produce orphan sections anymore. Signed-off-by: Yuan Tan Signed-off-by: Zhangjin Wu --- arch/riscv/include/asm/asm-extable.h | 34 ++++++++++++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) diff --git a/arch/riscv/include/asm/asm-extable.h b/arch/riscv/include/asm/asm-extable.h index d0be5a838242..7164d871e038 100644 --- a/arch/riscv/include/asm/asm-extable.h +++ b/arch/riscv/include/asm/asm-extable.h @@ -13,6 +13,21 @@ #ifdef __ASSEMBLY__ +#if defined(CONFIG_SECTION_SHF_LINK_ORDER_SUPPORT) +#define __ASM_EXTABLE_PUSH_SECTION \ + __LABEL_NAME(.L__ex_table) : \ + .pushsection __SECTION_NAME(__ex_table), "ao", __LABEL_NAME(.L__ex_table) + +#elif defined(CONFIG_SECTION_SHF_GROUP_SUPPORT) +#define __ASM_EXTABLE_PUSH_SECTION \ + .attach_to_group __SECTION_NAME(__ex_table); \ + .pushsection __SECTION_NAME(__ex_table), "a?" + +#else +#define __ASM_EXTABLE_PUSH_SECTION \ + .pushsection __SECTION_NAME(__ex_table), "a" +#endif + #define __ASM_EXTABLE_RAW(insn, fixup, type, data) \ .pushsection __SECTION_NAME(__ex_table), "a"; \ .balign 4; \ @@ -32,8 +47,23 @@ #include #include -#define __ASM_EXTABLE_RAW(insn, fixup, type, data) \ - ".pushsection " __SECTION_NAME(__ex_table) ", \"a\"\n" \ +#ifdef CONFIG_SECTION_SHF_LINK_ORDER_SUPPORT +#define __ASM_EXTABLE_PUSH_SECTION \ + __LABEL_NAME(.L__ex_table) ":" \ + ".pushsection " __SECTION_NAME(__ex_table) ", \"ao\"," __LABEL_NAME(.L__ex_table) "\n" + +#elif defined(CONFIG_SECTION_SHF_GROUP_SUPPORT) +#define __ASM_EXTABLE_PUSH_SECTION \ + ".attach_to_group " __SECTION_NAME(__ex_table) "\n" \ + ".pushsection " __SECTION_NAME(__ex_table) ", \"a?\"\n" + +#else +#define __ASM_EXTABLE_PUSH_SECTION \ + ".pushsection " __SECTION_NAME(__ex_table) ", \"a\"\n" +#endif + +#define __ASM_EXTABLE_RAW(insn, fixup, type, data) \ + __ASM_EXTABLE_PUSH_SECTION \ ".balign 4\n" \ ".long ((" insn ") - .)\n" \ ".long ((" fixup ") - .)\n" \ From patchwork Fri Nov 3 16:03:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yuan Tan X-Patchwork-Id: 13444683 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id DFEFEC4332F for ; Fri, 3 Nov 2023 16:03:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=XCwWPRF2U7MGoqks47uDRorCGwNIpUjeQHVNKQpJGm8=; b=PpBCZDLmoW4+Ah MK4EFg173/pr0Zl/j+Yh8l1S7DzKjcY9xwOCSSS7nWpUPBddJDhk4k1xj2sybyHJz9IAmSUFuAPqE nVQ69nettl5St4L0NY1k7Y56aGGMt5iBxykOS8XH3SCsFOdSV8G6oM7OojFsMRS99J4CpYhUCGM9G rdAOCpOaqR2jCDCrsPOjtd9x1MpxYEvcMMrKUTb7HY015PsLHN9GuBm++jXv/SpAuvi0T+asYlmqw zA/DH3bCoJVEKg7k+26GYZNmSEwc0qbHLYxHUsGORFdmktTip90srlL8t4kSDb044c/3wW/a2BVJJ kiNSz0f9kcsRgluFIFNA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qyweF-00Bks1-1A; Fri, 03 Nov 2023 16:03:51 +0000 Received: from bg4.exmail.qq.com ([43.154.221.58]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qyweA-00BkoW-0q for linux-riscv@lists.infradead.org; Fri, 03 Nov 2023 16:03:49 +0000 X-QQ-mid: bizesmtp82t1699027400trjco16j Received: from main2-ubuntu.tail147f4.ts.net ( [202.201.15.117]) by bizesmtp.qq.com (ESMTP) with id ; Sat, 04 Nov 2023 00:03:17 +0800 (CST) X-QQ-SSF: 01200000000000B06000000A0000000 X-QQ-FEAT: 7jw2iSiCazpcnkkT53zBV9E5I5T5DJqx1+TFUtxUfN3lRCahCSRmfodfnKjxV CZUVooP/s2ON1Xc7NqKw/750amPGn/HA/QmC3hjD503kq78AFBll7c+JW7zZRKRKgJ0dcBA fXrP4Q/oKyJmpMBY1aZwrgZA1L/EGsKMQUoOR5PupOxOnqtERz2toMY1qeVlWz/p7KZxsIk nY3oUd1ez40xtO3mx3yORZ0/HqylV4ibH6wp8aFM49EMpckQtLLAlVtwabPzzZ1qoI8noCY kYqhHDaoRthiGZg8naGoZeJJbGLrnRX5aIuzhSSszoQ36q6A0qlPDzDhUQFX3EVfpuXiQec mHMA3CCDPcDduASmtFWHo2AIgBomj0FnSbxAaz5DqO7Pmr8zO8= X-QQ-GoodBg: 0 X-BIZMAIL-ID: 5481933520797404592 From: Yuan Tan To: falcon@tinylab.org, arnd@arndb.de, linux-kernel@vger.kernel.org, linux-mips@vger.kernel.org, linux-riscv@lists.infradead.org, luc.vanoostenryck@gmail.com, linux-sparse@vger.kernel.org Cc: linux@weissschuh.net, palmer@rivosinc.com, paul.walmsley@sifive.com, paulburton@kernel.org, paulmck@kernel.org, tim.bird@sony.com, tsbogend@alpha.franken.de, w@1wt.eu, tanyuan@tinylab.org, i@maskray.me Subject: [PATCH v1 12/14] DCE/DSE: riscv: build reference for .pushsection in assembly Date: Sat, 4 Nov 2023 00:03:15 +0800 Message-Id: <26be8db18604f9a9e5eee9f03cc77ed034059d9a.1699025537.git.tanyuan@tinylab.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: MIME-Version: 1.0 X-QQ-SENDSIZE: 520 Feedback-ID: bizesmtp:tinylab.org:qybglogicsvrgz:qybglogicsvrgz5a-1 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231103_090346_639674_945E8809 X-CRM114-Status: UNSURE ( 9.15 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org Add the SECTION_SHF_LINK_ORDER method and the SECTION_SHF_GROUP method to refactor __ASM_EXTABLE_RAW, so it won't produce orphan sections anymore. Signed-off-by: Yuan Tan Signed-off-by: Zhangjin Wu --- arch/riscv/include/asm/asm-extable.h | 7 ++-- arch/riscv/lib/uaccess.S | 60 ++++++++++++++-------------- 2 files changed, 32 insertions(+), 35 deletions(-) diff --git a/arch/riscv/include/asm/asm-extable.h b/arch/riscv/include/asm/asm-extable.h index 7164d871e038..99e472b7a1be 100644 --- a/arch/riscv/include/asm/asm-extable.h +++ b/arch/riscv/include/asm/asm-extable.h @@ -29,7 +29,7 @@ #endif #define __ASM_EXTABLE_RAW(insn, fixup, type, data) \ - .pushsection __SECTION_NAME(__ex_table), "a"; \ + __ASM_EXTABLE_PUSH_SECTION; \ .balign 4; \ .long ((insn) - .); \ .long ((fixup) - .); \ @@ -37,9 +37,8 @@ .short (data); \ .popsection; - .macro _asm_extable, insn, fixup - __ASM_EXTABLE_RAW(\insn, \fixup, EX_TYPE_FIXUP, 0) - .endm +#define _asm_extable(insn, fixup) \ + __ASM_EXTABLE_RAW(insn, fixup, EX_TYPE_FIXUP, 0) #else /* __ASSEMBLY__ */ diff --git a/arch/riscv/lib/uaccess.S b/arch/riscv/lib/uaccess.S index 09b47ebacf2e..91c76d3fbe2f 100644 --- a/arch/riscv/lib/uaccess.S +++ b/arch/riscv/lib/uaccess.S @@ -4,11 +4,9 @@ #include #include - .macro fixup op reg addr lbl -100: - \op \reg, \addr - _asm_extable 100b, \lbl - .endm +#define fixup(op, reg, addr, lbl) \ + 100: op reg, addr; \ + _asm_extable(100b, lbl) ENTRY(__asm_copy_to_user) ENTRY(__asm_copy_from_user) @@ -50,9 +48,9 @@ ENTRY(__asm_copy_from_user) beq a0, t1, .Lskip_align_dst 1: /* a5 - one byte for copying data */ - fixup lb a5, 0(a1), 10f + fixup(lb, a5, 0(a1), 10f) addi a1, a1, 1 /* src */ - fixup sb a5, 0(a0), 10f + fixup(sb, a5, 0(a0), 10f) addi a0, a0, 1 /* dst */ bltu a0, t1, 1b /* t1 - start of aligned dst */ @@ -77,22 +75,22 @@ ENTRY(__asm_copy_from_user) */ addi t0, t0, -(8*SZREG) /* not to over run */ 2: - fixup REG_L a4, 0(a1), 10f - fixup REG_L a5, SZREG(a1), 10f - fixup REG_L a6, 2*SZREG(a1), 10f - fixup REG_L a7, 3*SZREG(a1), 10f - fixup REG_L t1, 4*SZREG(a1), 10f - fixup REG_L t2, 5*SZREG(a1), 10f - fixup REG_L t3, 6*SZREG(a1), 10f - fixup REG_L t4, 7*SZREG(a1), 10f - fixup REG_S a4, 0(a0), 10f - fixup REG_S a5, SZREG(a0), 10f - fixup REG_S a6, 2*SZREG(a0), 10f - fixup REG_S a7, 3*SZREG(a0), 10f - fixup REG_S t1, 4*SZREG(a0), 10f - fixup REG_S t2, 5*SZREG(a0), 10f - fixup REG_S t3, 6*SZREG(a0), 10f - fixup REG_S t4, 7*SZREG(a0), 10f + fixup(REG_L, a4, 0(a1), 10f) + fixup(REG_L, a5, SZREG(a1), 10f) + fixup(REG_L, a6, 2*SZREG(a1), 10f) + fixup(REG_L, a7, 3*SZREG(a1), 10f) + fixup(REG_L, t1, 4*SZREG(a1), 10f) + fixup(REG_L, t2, 5*SZREG(a1), 10f) + fixup(REG_L, t3, 6*SZREG(a1), 10f) + fixup(REG_L, t4, 7*SZREG(a1), 10f) + fixup(REG_S, a4, 0(a0), 10f) + fixup(REG_S, a5, SZREG(a0), 10f) + fixup(REG_S, a6, 2*SZREG(a0), 10f) + fixup(REG_S, a7, 3*SZREG(a0), 10f) + fixup(REG_S, t1, 4*SZREG(a0), 10f) + fixup(REG_S, t2, 5*SZREG(a0), 10f) + fixup(REG_S, t3, 6*SZREG(a0), 10f) + fixup(REG_S, t4, 7*SZREG(a0), 10f) addi a0, a0, 8*SZREG addi a1, a1, 8*SZREG bltu a0, t0, 2b @@ -130,7 +128,7 @@ ENTRY(__asm_copy_from_user) sub t4, a5, t3 /* Load the first word to combine with second word */ - fixup REG_L a5, 0(a1), 10f + fixup(REG_L, a5, 0(a1), 10f) 3: /* Main shifting copy @@ -142,11 +140,11 @@ ENTRY(__asm_copy_from_user) /* At least one iteration will be executed */ srl a4, a5, t3 - fixup REG_L a5, SZREG(a1), 10f + fixup(REG_L, a5, SZREG(a1), 10f) addi a1, a1, SZREG sll a2, a5, t4 or a2, a2, a4 - fixup REG_S a2, 0(a0), 10f + fixup(REG_S, a2, 0(a0), 10f) addi a0, a0, SZREG bltu a0, t1, 3b @@ -163,9 +161,9 @@ ENTRY(__asm_copy_from_user) */ bgeu a0, t0, .Lout_copy_user /* check if end of copy */ 4: - fixup lb a5, 0(a1), 10f + fixup(lb, a5, 0(a1), 10f) addi a1, a1, 1 /* src */ - fixup sb a5, 0(a0), 10f + fixup(sb, a5, 0(a0), 10f) addi a0, a0, 1 /* dst */ bltu a0, t0, 4b /* t0 - end of dst */ @@ -205,7 +203,7 @@ ENTRY(__clear_user) bgeu t0, t1, 2f bltu a0, t0, 4f 1: - fixup REG_S, zero, (a0), 11f + fixup(REG_S, zero, (a0), 11f) addi a0, a0, SZREG bltu a0, t1, 1b 2: @@ -217,12 +215,12 @@ ENTRY(__clear_user) li a0, 0 ret 4: /* Edge case: unalignment */ - fixup sb, zero, (a0), 11f + fixup(sb, zero, (a0), 11f) addi a0, a0, 1 bltu a0, t0, 4b j 1b 5: /* Edge case: remainder */ - fixup sb, zero, (a0), 11f + fixup(sb, zero, (a0), 11f) addi a0, a0, 1 bltu a0, a3, 5b j 3b From patchwork Fri Nov 3 16:04:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yuan Tan X-Patchwork-Id: 13444684 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id CA5F1C4332F for ; Fri, 3 Nov 2023 16:04:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=3O1iBlrnK1DLtDN9FVgiEtyFNbq5fertkfHPLrRbN4g=; b=EdPtfItTTyPzkC wMEJgjDWqD5F1K6AC4Zj6c6JfKYHgW2u7GYB4m+EpUx/jAF4VLe1uS0hTfU3kmSaqZo03EuzqVAhH Ybw824NMom9AfLXEYuVorZOq4Ke7uJ80D4rsnABdAkwsVPNaDt5wcR3pP729MJegI6zYZKA9PdHqU LjrsqGvRkMrGZBqNQy28k3Bq+m+0cKvFC+3mUh3pPTMj3Vd0LhwCOJ9gAdguCj1fmsTC6Zey2o0SV Gfn4IuiE0PlvJfQxgYwLv0K2pcPi1Gq+J5JAXWPhf5tyvhhkOJGErCf9ihhPEjMhNqFOUd9Dh8JlL ddD9Fi7xLYEhUJ90oY7g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qywf2-00BlGg-0J; Fri, 03 Nov 2023 16:04:40 +0000 Received: from bg4.exmail.qq.com ([43.154.221.58]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qywey-00BlEa-0Z for linux-riscv@lists.infradead.org; Fri, 03 Nov 2023 16:04:37 +0000 X-QQ-mid: bizesmtp78t1699027456tnrc347s Received: from main2-ubuntu.tail147f4.ts.net ( [202.201.15.117]) by bizesmtp.qq.com (ESMTP) with id ; Sat, 04 Nov 2023 00:04:13 +0800 (CST) X-QQ-SSF: 01200000000000B06000000A0000000 X-QQ-FEAT: mot7IUESEd/O3Ye3RvUm0u0JfDP8ilGw6DJ+bg2ku9yW02xqru4czyWnDR4JC EQdnw8q1TsviTHclgFaJRSxxEJSFDKoZfMUzfWIOoWQW5FI9+0rOhbgL2xFjAIQLOk/WiNb Ze0d8K6zH/AYLaKpQIAtAZG4jS7M72shuT9euUEJaCCA/CcImxoiQrXkdoAg+grDS7lI/xU DnpaZjUvJet9LH1I1tXUT2k+8t0nGwPGjmBS7XYMcEABQ3GlVXZx8/iDCsrMmgIy1Mf4YxT 25ig0IbUsLLwVXn/38HbQVCzou/49TJyeRhZOCpzf0rKiNfEg1KrsIRdd33Cz5XTnn7Ws/O zQ60yzEUchZNK3VB1+XcP3Ha7KKHjs9ib0py4O2 X-QQ-GoodBg: 0 X-BIZMAIL-ID: 6096022325544553150 From: Yuan Tan To: falcon@tinylab.org, arnd@arndb.de, linux-kernel@vger.kernel.org, linux-mips@vger.kernel.org, linux-riscv@lists.infradead.org, luc.vanoostenryck@gmail.com, linux-sparse@vger.kernel.org Cc: linux@weissschuh.net, palmer@rivosinc.com, paul.walmsley@sifive.com, paulburton@kernel.org, paulmck@kernel.org, tim.bird@sony.com, tsbogend@alpha.franken.de, w@1wt.eu, tanyuan@tinylab.org, i@maskray.me Subject: [PATCH v1 13/14] DCE/DSE: add SECTION_NO_KEEP_SUPPORT option Date: Sat, 4 Nov 2023 00:04:10 +0800 Message-Id: <4ad1b8cb7cd54c57e74e877235f64b5be5bbbe8f.1699025537.git.tanyuan@tinylab.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: MIME-Version: 1.0 X-QQ-SENDSIZE: 520 Feedback-ID: bizesmtp:tinylab.org:qybglogicsvrgz:qybglogicsvrgz5a-1 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231103_090436_525453_F944DBF1 X-CRM114-Status: UNSURE ( 8.41 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org It is able to drop the brute KEEP() keyword for some sections, when the sections are able to link or group together with one of the used sections. Some syscalls are actually orphan sections. SECTION_SHF_LINK_ORDER_SUPPORT or SECTION_SHF_GROUP_SUPPORT creates references for these sections, eliminating the need for the KEEP() directive. Signed-off-by: Yuan Tan Signed-off-by: Zhangjin Wu --- include/asm-generic/vmlinux.lds.h | 24 ++++++++++++++++++------ init/Kconfig | 9 +++++++++ 2 files changed, 27 insertions(+), 6 deletions(-) diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h index ea8170e11ab1..f10afc42a1ac 100644 --- a/include/asm-generic/vmlinux.lds.h +++ b/include/asm-generic/vmlinux.lds.h @@ -201,18 +201,30 @@ # endif #endif -#define BOUNDED_SECTION_PRE_LABEL(_sec_, _label_, _BEGIN_, _END_) \ +#ifdef CONFIG_SECTION_NO_KEEP_SUPPORT +#define NO_KEEP(sec) sec +#else +#define NO_KEEP(sec) KEEP(sec) +#endif + +#define _BOUNDED_SECTION_PRE_LABEL(_sec_, _label_, _BEGIN_, _END_, _KEEP_, ...) \ _BEGIN_##_label_ = .; \ - KEEP(*(BSEC_MAIN(_sec_))) \ + _KEEP_(*(BSEC_MAIN(_sec_))) \ _END_##_label_ = .; -#define BOUNDED_SECTION_POST_LABEL(_sec_, _label_, _BEGIN_, _END_) \ +#define BOUNDED_SECTION_PRE_LABEL(_sec_, _label_, _BEGIN_, _END_, ...) \ + _BOUNDED_SECTION_PRE_LABEL(_sec_, _label_, _BEGIN_, _END_, ##__VA_ARGS__, KEEP) + +#define _BOUNDED_SECTION_POST_LABEL(_sec_, _label_, _BEGIN_, _END_, _KEEP_, ...)\ _label_##_BEGIN_ = .; \ - KEEP(*(BSEC_MAIN(_sec_))) \ + _KEEP_(*(BSEC_MAIN(_sec_))) \ _label_##_END_ = .; -#define BOUNDED_SECTION_BY(_sec_, _label_) \ - BOUNDED_SECTION_PRE_LABEL(_sec_, _label_, __start, __stop) +#define BOUNDED_SECTION_POST_LABEL(_sec_, _label_, _BEGIN_, _END_, ...) \ + _BOUNDED_SECTION_POST_LABEL(_sec_, _label_, _BEGIN_, _END_, ##__VA_ARGS__, KEEP) + +#define BOUNDED_SECTION_BY(_sec_, _label_, ...) \ + _BOUNDED_SECTION_PRE_LABEL(_sec_, _label_, __start, __stop, ##__VA_ARGS__, KEEP) #define BOUNDED_SECTION(_sec) BOUNDED_SECTION_BY(_sec, _sec) diff --git a/init/Kconfig b/init/Kconfig index 9599d2de44e8..aeb859e410b2 100644 --- a/init/Kconfig +++ b/init/Kconfig @@ -1467,6 +1467,13 @@ config HAVE_SECTION_NO_KEEP_SUPPORT depends on HAVE_SECTION_SHF_LINK_ORDER_SUPPORT || HAVE_SECTION_SHF_GROUP_SUPPORT default y +config SECTION_NO_KEEP_SUPPORT + bool + depends on SECTION_SHF_LINK_ORDER_SUPPORT || SECTION_SHF_GROUP_SUPPORT + default y + help + This option allows some sections unkept so they can be GC + config HAVE_SECTION_SHF_LINK_ORDER_SUPPORT bool depends on AS_IS_GNU && AS_VERSION >= 23500 @@ -1765,6 +1772,7 @@ config RESTRICTED_TRIM_UNUSED_SYSCALLS config SECTION_SHF_LINK_ORDER_SUPPORT bool "Using SHF_LINK_ORDER attribute (EXPERIMENTAL)" if EXPERT depends on HAVE_SECTION_SHF_LINK_ORDER_SUPPORT + select SECTION_NO_KEEP_SUPPORT help Say Y here to trim more 'unused' syscalls wrongly kept by __ex_table like sections in kernel space. @@ -1778,6 +1786,7 @@ config SECTION_SHF_LINK_ORDER_SUPPORT config SECTION_SHF_GROUP_SUPPORT bool "Using SHF_GROUP attribute (EXPERIMENTAL)" if EXPERT depends on HAVE_SECTION_SHF_GROUP_SUPPORT + select SECTION_NO_KEEP_SUPPORT help Say Y here to trim more 'unused' syscalls wrongly kept by __ex_table like sections in kernel space. From patchwork Fri Nov 3 16:04:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yuan Tan X-Patchwork-Id: 13444685 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 303DAC4332F for ; Fri, 3 Nov 2023 16:05:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=sxOk4RR6wendiqygpO+URTiZ3r1Yb0qdnyMv84GILaE=; b=LhwtY7Si+JyUnl rAbcIaxtW5dWj0Y/R0kCNYfDeF1iXJeFY4Gjjetl45Tp2NmUn8RPa6H84PpInJlDbNs5IK4Z4vBss +D7hP7qyMnUiEfxGcanyRKmjk+neKmSvKVW3GUYiJ5JQkBmdyYiDZfxwnEmcznyL01HglXg/UrmoQ iJZXHiWc21VE5ls2pfdPs504tjCG1uWG29tVn0yHAjMUrUNmAi1Oj3nj7uWGN/PxmNtStgxfANz1T f2O+s/EyNo9FG/TbZYsIWhwQnVkwAvtvD9cbX8OIi1ulwpAnimB/yzDCymnWUXAOfrrBZYGz35ADs 04ge8uK34cJK1AYfy0AA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qywfs-00BlVm-16; Fri, 03 Nov 2023 16:05:32 +0000 Received: from bg4.exmail.qq.com ([43.154.221.58]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qywfp-00BlUd-0R for linux-riscv@lists.infradead.org; Fri, 03 Nov 2023 16:05:30 +0000 X-QQ-mid: bizesmtp88t1699027493t4lqanvg Received: from main2-ubuntu.tail147f4.ts.net ( [202.201.15.117]) by bizesmtp.qq.com (ESMTP) with id ; Sat, 04 Nov 2023 00:04:50 +0800 (CST) X-QQ-SSF: 01200000000000B06000000A0000000 X-QQ-FEAT: jXjag1m6xl5ppx2DzruJtGaZWnmD4kcr8XGhe8RzDeQnj/4txlNMA0RrzbdM3 NkLCpOnAtszVCaalBQWVPDXpaXS99zJq6AlrppFnw1HKvKL0xj0E5A9V7XJ4MlTzYMuw81z fr0TQpqQaEJWCRXcAtRVJi0F1ePqT0AT21/h93uarocjC8Z8j1tjIaNhhk3tVoz+rnGhrAd TRL0MreVOn2ipogbXqRHd+i6op09393O4FSiuY8ril1xpaW3/uszhT2UDapIXWOaUz+PptB f2CN/td6z1BqlmsTzYJ3ewPyBma8ADUsb5d7vDUH3TMXEtfm+e3ucDioNeOaMAYycbIr9aJ /sF2ho7MXuFQ17Wh2UAABl458F674OLb8zGA6HrpmOBwvwfV8QFEVjuC0lUdg== X-QQ-GoodBg: 0 X-BIZMAIL-ID: 11412250178732425861 From: Yuan Tan To: falcon@tinylab.org, arnd@arndb.de, linux-kernel@vger.kernel.org, linux-mips@vger.kernel.org, linux-riscv@lists.infradead.org, luc.vanoostenryck@gmail.com, linux-sparse@vger.kernel.org Cc: linux@weissschuh.net, palmer@rivosinc.com, paul.walmsley@sifive.com, paulburton@kernel.org, paulmck@kernel.org, tim.bird@sony.com, tsbogend@alpha.franken.de, w@1wt.eu, tanyuan@tinylab.org, i@maskray.me Subject: [PATCH v1 14/14] DCE/DSE: vmlinux.lds.h: allow NO_KEEP on __ex_table sections Date: Sat, 4 Nov 2023 00:04:48 +0800 Message-Id: <3acff566dc1818a36b32a34e25b0de58c5118ee6.1699025537.git.tanyuan@tinylab.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: MIME-Version: 1.0 X-QQ-SENDSIZE: 520 Feedback-ID: bizesmtp:tinylab.org:qybglogicsvrgz:qybglogicsvrgz5a-1 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231103_090529_491545_62AF9662 X-CRM114-Status: UNSURE ( 7.63 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org With SHF_LINK_ORDER or SHF_GROUP, all of the __extable sections are no longer orphan sections. In this case, KEEP() is no longer needed. Signed-off-by: Yuan Tan Signed-off-by: Zhangjin Wu --- include/asm-generic/vmlinux.lds.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h index f10afc42a1ac..e5e5850ea573 100644 --- a/include/asm-generic/vmlinux.lds.h +++ b/include/asm-generic/vmlinux.lds.h @@ -658,7 +658,7 @@ #define EXCEPTION_TABLE(align) \ . = ALIGN(align); \ __ex_table : AT(ADDR(__ex_table) - LOAD_OFFSET) { \ - BOUNDED_SECTION_BY(__ex_table, ___ex_table) \ + BOUNDED_SECTION_BY(__ex_table, ___ex_table, NO_KEEP) \ } /*