From nobody Sun Sep 14 16:17:48 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6AB36C00A5A for ; Thu, 19 Jan 2023 16:05:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230008AbjASQFO (ORCPT ); Thu, 19 Jan 2023 11:05:14 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58526 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229750AbjASQEp (ORCPT ); Thu, 19 Jan 2023 11:04:45 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9D2DC66ED6 for ; Thu, 19 Jan 2023 08:04:40 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 34B9C61CB2 for ; Thu, 19 Jan 2023 16:04:40 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9C585C433F0; Thu, 19 Jan 2023 16:04:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1674144279; bh=J6NfBaiAHaZuC3c1U8Q2mwYoiCAI9Bs41guM1DxDgPc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rGvlB0CvLLTbE3PEOLaWlAM8hyCbtspLIpmMAXkQE65qKeOs1S5YQ6tFOIDNNMTzm +mfaKlbigHE/gP4UIVpLKkUE8RGRAFTkwiUgY7UbGhAwFnghvwDYSxA3c8c+df+tEU +TXbI3TJkWdTzjtp+4PwcoQY1uuf+slEpGzFUMAiEhuex7y9DTZRa3elnetXCqZEcg J6QyYJbwP7Ni+xJqI5I5SWy/e+hvTRPVgwtDMy3tasF8/13mclwc4BQKJhm/3nNxXs bV1G5T1YvVXfIcg3yoatppjIV7UlRoU3+cbjKK09/GhIkXKDRLZhxjqvpxAcSI/CyH gPkwFYrYYBfMA== From: Jisheng Zhang To: Paul Walmsley , Palmer Dabbelt , Albert Ou , Masahiro Yamada , Kees Cook , Nathan Chancellor Cc: Conor Dooley , linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 1/5] riscv: lds: define RUNTIME_DISCARD_EXIT Date: Thu, 19 Jan 2023 23:54:13 +0800 Message-Id: <20230119155417.2600-2-jszhang@kernel.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20230119155417.2600-1-jszhang@kernel.org> References: <20230119155417.2600-1-jszhang@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" riscv discards .exit.* sections at run-time but doesn't define RUNTIME_DISCARD_EXIT. However, the .exit.* sections are still allocated and kept even if the generic DISCARDS would discard the sections due to missing RUNTIME_DISCARD_EXIT, because the DISCARD sits at the end of the linker script. Add the missing RUNTIME_DISCARD_EXIT define so that it still works if we move DISCARD up or even at the beginning of the linker script. Signed-off-by: Jisheng Zhang Suggested-by: Masahiro Yamada Reviewed-by: Conor Dooley --- arch/riscv/kernel/vmlinux.lds.S | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/riscv/kernel/vmlinux.lds.S b/arch/riscv/kernel/vmlinux.ld= s.S index 4e6c88aa4d87..07c19f2a288c 100644 --- a/arch/riscv/kernel/vmlinux.lds.S +++ b/arch/riscv/kernel/vmlinux.lds.S @@ -5,6 +5,7 @@ */ =20 #define RO_EXCEPTION_TABLE_ALIGN 4 +#define RUNTIME_DISCARD_EXIT =20 #ifdef CONFIG_XIP_KERNEL #include "vmlinux-xip.lds.S" --=20 2.38.1 From nobody Sun Sep 14 16:17:48 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 056B8C38159 for ; Fri, 20 Jan 2023 05:29:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231533AbjATF3b (ORCPT ); Fri, 20 Jan 2023 00:29:31 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33588 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229587AbjATF2r (ORCPT ); Fri, 20 Jan 2023 00:28:47 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0B930518C8 for ; Thu, 19 Jan 2023 21:23:46 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 1041AB825CE for ; Thu, 19 Jan 2023 16:04:43 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 08DD0C433D2; Thu, 19 Jan 2023 16:04:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1674144281; bh=JVI55/ivlZ2TxoJHk0X2NO1E9dymbfoLXWzO4tbPtjg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Sb/IuKp0gRLNHotZEmSEUC5VIcFKvFDct3mmUFbR/RgMiNz4w6hsFeLsqIRKBxs8C SVXmwwejCWXXx9vxIj0okNKj9s9nXgMDRqz8pM/8I/GxVGChP6BGEhZE/0NpaU0OZJ cWnOmQ6gTLwfeU7TLmG8uXy9apHLMCIN3feZd77krFdI3QM7+VTln48Qd4Ahs1o1eJ CQWzdokDLVZw/3ZLwLJAV+Z42Yn3++93GRXVXXzJbr+WmZ8w2fVTpHa1mk/RKUh2YH 8ct/q8JlLqoczfUQ4aTZhYBWCiKj761uH8aPsleUEILO0lJBavjg1fLAxvKgrFvDt8 /NrYA+SchZ3Lg== From: Jisheng Zhang To: Paul Walmsley , Palmer Dabbelt , Albert Ou , Masahiro Yamada , Kees Cook , Nathan Chancellor Cc: Conor Dooley , linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 2/5] riscv: vmlinux.lds.S: explicitly catch .rela.dyn symbols Date: Thu, 19 Jan 2023 23:54:14 +0800 Message-Id: <20230119155417.2600-3-jszhang@kernel.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20230119155417.2600-1-jszhang@kernel.org> References: <20230119155417.2600-1-jszhang@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" When enabling linker orphan section warning, I got warnings similar as below: riscv64-linux-gnu-ld: warning: orphan section `.rela.text' from `init/main.o' being placed in section `.rela.dyn' Use the approach similar as ARM64 does and declare it in vmlinux.lds.S Signed-off-by: Jisheng Zhang --- arch/riscv/kernel/vmlinux.lds.S | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/arch/riscv/kernel/vmlinux.lds.S b/arch/riscv/kernel/vmlinux.ld= s.S index 07c19f2a288c..6a250313b752 100644 --- a/arch/riscv/kernel/vmlinux.lds.S +++ b/arch/riscv/kernel/vmlinux.lds.S @@ -97,6 +97,10 @@ SECTIONS *(.rel.dyn*) } =20 + .rela.dyn : { + *(.rela*) + } + __init_data_end =3D .; =20 . =3D ALIGN(8); --=20 2.38.1 From nobody Sun Sep 14 16:17:48 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id ACD35C004D4 for ; Thu, 19 Jan 2023 16:05:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230233AbjASQFU (ORCPT ); Thu, 19 Jan 2023 11:05:20 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58602 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230051AbjASQEu (ORCPT ); Thu, 19 Jan 2023 11:04:50 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B33D386EE6 for ; Thu, 19 Jan 2023 08:04:44 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 4E99C61CB5 for ; Thu, 19 Jan 2023 16:04:44 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 192F1C433F0; Thu, 19 Jan 2023 16:04:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1674144283; bh=HZ2KeW9xZS9UJRxhjs2snT6EZu0lqTWV3MzCCMYghqA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZPQmJJUes4tQ1AHeqLpcuDsBW0QuzfZesiN8dtYdaZeUVxPt0hMlcL2HqoMfSORIU R0OGX1vIgqw3Szuz+yOhOdEK31eu6KYWEOSNPET/XJ0cnB+S8FklJuGJ9vsNuRKPvw RQyodrQj7IYIZcVX2nPnM/kdUcw6rvQ1sEp7TaCJ2c1LZFR35A01Va75F6cuiIKlgA 7IsczqPTd5NABgRSLCJBfB5wPxqtdNdKc0B/oSOiRf21wenFIlD+c4l+B2b7vqzHgn McDiYiDWtnsikeoHgFtGuixpH1sleZfxOm9OJ2VMgTBfNfi23ir6UeiBOBda2Fz/lc 3KP1k6cQgZ7Zw== From: Jisheng Zhang To: Paul Walmsley , Palmer Dabbelt , Albert Ou , Masahiro Yamada , Kees Cook , Nathan Chancellor Cc: Conor Dooley , linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 3/5] riscv: vmlinux.lds.S: explicitly catch .riscv.attributes sections Date: Thu, 19 Jan 2023 23:54:15 +0800 Message-Id: <20230119155417.2600-4-jszhang@kernel.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20230119155417.2600-1-jszhang@kernel.org> References: <20230119155417.2600-1-jszhang@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" When enabling linker orphan section warning, I got warnings similar as below: riscv64-linux-gnu-ld: warning: orphan section `.riscv.attributes' from `init/main.o' being placed in section `.riscv.attributes' While I don't see any usage of .riscv.attributes sections' in kernel now, just catch the sections so that we can enable linker orphan section warning. Signed-off-by: Jisheng Zhang --- arch/riscv/kernel/vmlinux.lds.S | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/riscv/kernel/vmlinux.lds.S b/arch/riscv/kernel/vmlinux.ld= s.S index 6a250313b752..7eb3d25d0dae 100644 --- a/arch/riscv/kernel/vmlinux.lds.S +++ b/arch/riscv/kernel/vmlinux.lds.S @@ -146,6 +146,7 @@ SECTIONS STABS_DEBUG DWARF_DEBUG ELF_DETAILS + .riscv.attributes 0 : { *(.riscv.attributes) } =20 DISCARDS } --=20 2.38.1 From nobody Sun Sep 14 16:17:48 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E4C3AC677F1 for ; Fri, 20 Jan 2023 05:30:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229661AbjATFaJ (ORCPT ); Fri, 20 Jan 2023 00:30:09 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35700 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230321AbjATF3O (ORCPT ); Fri, 20 Jan 2023 00:29:14 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 23D8672C12 for ; Thu, 19 Jan 2023 21:23:56 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 2ADBDB825D1 for ; Thu, 19 Jan 2023 16:04:47 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2773FC433EF; Thu, 19 Jan 2023 16:04:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1674144285; bh=pK9Wljug0Rn52ySou16paWAQsJuCdZT50slSKiioR6I=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=I2M7OjAvb5J/bLEAc1b32Jtbukywae8404syAwBYwhKyD3JPidlY3A/Es8gJ9BQAu Qp3p/b4rqgs8vNq/1frbEJyI3+RM1MtOo9DD/VCKW2lRBqscBhmIZpxiSHWL2aY4Pw RdH4jlK74S/mq0YVuTN1YkdGZzaCjh8SJmPJyJkqoidzKDfoxrLjAhOxPLwnmmwJ9V a3b/giUqbhV9myKXy0jPD8f6ZNFRvNZw9GTjnogGUilLxlvCG3/kvhLhBy79ECywzy XiMevmoyYtgRE3B/EnERlqPBLQH5PPSmaelHe/isPHMXpPMzdRh02oY/k0x3sc7Y4L Jqvc86erhRayw== From: Jisheng Zhang To: Paul Walmsley , Palmer Dabbelt , Albert Ou , Masahiro Yamada , Kees Cook , Nathan Chancellor Cc: Conor Dooley , linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 4/5] riscv: vmlinux.lds.S: explicitly catch .init.bss sections from EFI stub Date: Thu, 19 Jan 2023 23:54:16 +0800 Message-Id: <20230119155417.2600-5-jszhang@kernel.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20230119155417.2600-1-jszhang@kernel.org> References: <20230119155417.2600-1-jszhang@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" When enabling linker orphan section warning, I got warnings similar as below: ld.lld: warning: ./drivers/firmware/efi/libstub/lib.a(efi-stub-helper.stub.o):(.init.bss) is being placed in '.init.bss' Catch the sections so that we can enable linker orphan section warning. Signed-off-by: Jisheng Zhang --- arch/riscv/kernel/vmlinux.lds.S | 3 +++ 1 file changed, 3 insertions(+) diff --git a/arch/riscv/kernel/vmlinux.lds.S b/arch/riscv/kernel/vmlinux.ld= s.S index 7eb3d25d0dae..b2813b5e47a0 100644 --- a/arch/riscv/kernel/vmlinux.lds.S +++ b/arch/riscv/kernel/vmlinux.lds.S @@ -87,6 +87,9 @@ SECTIONS /* Start of init data section */ __init_data_begin =3D .; INIT_DATA_SECTION(16) + .init.bss : { + *(.init.bss) /* from the EFI stub */ + } .exit.data : { EXIT_DATA --=20 2.38.1 From nobody Sun Sep 14 16:17:48 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9C5B6C004D4 for ; Thu, 19 Jan 2023 16:05:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230316AbjASQF3 (ORCPT ); Thu, 19 Jan 2023 11:05:29 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58622 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230161AbjASQEv (ORCPT ); Thu, 19 Jan 2023 11:04:51 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3F1BD69222 for ; Thu, 19 Jan 2023 08:04:49 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id C13E461CB7 for ; Thu, 19 Jan 2023 16:04:48 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 31355C43398; Thu, 19 Jan 2023 16:04:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1674144288; bh=Q3aUPyCmgVUYIBmI6uVtAlDrofg5WEVa3xPWnM7xs/M=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KOOU8bw3d6SuGu0wcCX7KDP4dmpC5+XBCZ2OljXy1baMW85lsj4+IqWljAFyoSWBl ppX4QqkJxaSDD0HfCrhXdJhHdHNiJa2wGfyyV1QOju+OJf2+ZkEsMUd6PnsHRUvRif pbfBKnuYGROfs91MqXhZAJeoqCFjbscAlGdNGsS0v9mUv9NxUg+tV1MdzdHfEpWLHT zTv8VTs/c1/0c1jQl4JNc2fmMLxE/IWL1jJJRNdZbxYZ7AAcS9PCCA/DnSjQecu6E4 Sv8jnLCBxM8fMikux4xClrENpdNhnm0ZuSDTp0EqingpaCJSR2sQr7mOwAgsIQ3reB IaPMMTaUwCudg== From: Jisheng Zhang To: Paul Walmsley , Palmer Dabbelt , Albert Ou , Masahiro Yamada , Kees Cook , Nathan Chancellor Cc: Conor Dooley , linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 5/5] riscv: select ARCH_WANT_LD_ORPHAN_WARN for !XIP_KERNEL Date: Thu, 19 Jan 2023 23:54:17 +0800 Message-Id: <20230119155417.2600-6-jszhang@kernel.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20230119155417.2600-1-jszhang@kernel.org> References: <20230119155417.2600-1-jszhang@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Now, after that all the sections are explicitly described and declared in vmlinux.lds.S, we can enable ld orphan warnings for !XIP_KERNEL to prevent from missing any new sections in future. Signed-off-by: Jisheng Zhang Reviewed-by: Conor Dooley --- arch/riscv/Kconfig | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig index e2b656043abf..335e0c45cced 100644 --- a/arch/riscv/Kconfig +++ b/arch/riscv/Kconfig @@ -46,6 +46,7 @@ config RISCV select ARCH_WANT_FRAME_POINTERS select ARCH_WANT_GENERAL_HUGETLB select ARCH_WANT_HUGE_PMD_SHARE if 64BIT + select ARCH_WANT_LD_ORPHAN_WARN if !XIP_KERNEL select ARCH_WANTS_THP_SWAP if HAVE_ARCH_TRANSPARENT_HUGEPAGE select BINFMT_FLAT_NO_DATA_START_OFFSET if !MMU select BUILDTIME_TABLE_SORT if MMU --=20 2.38.1