From nobody Thu Sep 11 20:55:05 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 EDD1EC636CC for ; Wed, 15 Feb 2023 18:47:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229759AbjBOSrC (ORCPT ); Wed, 15 Feb 2023 13:47:02 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36450 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229576AbjBOSrA (ORCPT ); Wed, 15 Feb 2023 13:47:00 -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 3D7FA3D916 for ; Wed, 15 Feb 2023 10:46:45 -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 3A47FB82357 for ; Wed, 15 Feb 2023 18:41:28 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3B679C4339B; Wed, 15 Feb 2023 18:41:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1676486486; bh=Bn4PnsdfMk3VpRZTuBATRwN4ucU9A9gaRgDX010A7pA=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=K8DssxvWbdq3XXo1YlSzB5+4GoV8/dvTaDPuEvZyLvicAEOonCuS2M5DEFoCbrvhg 9mX1bx0KyAhhg/9xZjzUlCLfgkI4AtVp12CiaitfkmBdGayB6shkHIcfQYfCaILPFl ZWwZx/cZ24fUFYqQNUm4vn0vD7tBojGDzilj0Ph30bbwU7lwBvDE/KMd10N660T9wb y0CoDUJoN5/UGiiVBnXt3o0rPnzt9mJ5v0OQ/zG481K9slBRUjyMcnYQ/P8+4OaEUm GhAGo6913DGwcPIbWcvHbaSpd/5Sd8TnWJ3pfordVGsGBdVCNuG6XT5/pW3IxuytL3 5jbCLGsXGIUPA== From: Nathan Chancellor Date: Wed, 15 Feb 2023 11:41:15 -0700 Subject: [PATCH 1/3] powerpc/boot: Only use '-mabi=elfv2' with CONFIG_PPC64_BOOT_WRAPPER MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20230118-ppc64-elfv2-llvm-v1-1-b9e2ec9da11d@kernel.org> References: <20230118-ppc64-elfv2-llvm-v1-0-b9e2ec9da11d@kernel.org> In-Reply-To: <20230118-ppc64-elfv2-llvm-v1-0-b9e2ec9da11d@kernel.org> To: mpe@ellerman.id.au Cc: npiggin@gmail.com, christophe.leroy@csgroup.eu, erhard_f@mailbox.org, nathan@kernel.org, ndesaulniers@google.com, trix@redhat.com, linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org, llvm@lists.linux.dev, patches@lists.linux.dev X-Mailer: b4 0.12.1 X-Developer-Signature: v=1; a=openpgp-sha256; l=1330; i=nathan@kernel.org; h=from:subject:message-id; bh=Bn4PnsdfMk3VpRZTuBATRwN4ucU9A9gaRgDX010A7pA=; b=owGbwMvMwCEmm602sfCA1DTG02pJDMlv1UNDVS+uVxZctb7mrC67yZbDwu3i3yIzTRpudAjIi LeJeV/tKGVhEONgkBVTZKl+rHrc0HDOWcYbpybBzGFlAhnCwMUpABP5spLhf+Bf/oNmFpFBUb6v WfMc5rDmiO8KlFiyN/ebnkn7A8F7Gxl+s/3U+PCZu/WaT3mP2GK3kIayadsSHt+fKtjALvwuec1 TdgA= X-Developer-Key: i=nathan@kernel.org; a=openpgp; fpr=2437CB76E544CB6AB3D9DFD399739260CB6CB716 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When CONFIG_PPC64_ELF_ABI_V2 is enabled with clang through CONFIG_PPC64_BIG_ENDIAN_ELF_ABI_V2, building the powerpc boot wrapper in 32-bit mode (i.e. with CONFIG_PPC64_BOOT_WRAPPER=3Dn) fails with: error: unknown target ABI 'elfv2' The ABI cannot be changed with '-m32'; GCC silently accepts it but clang errors out. Only provide '-mabi=3Delfv2' when CONFIG_PPC64_BOOT_WRAPPER is enabled, which is the only way '-mabi=3Delfv2' will be useful. Tested-by: "Erhard F." Signed-off-by: Nathan Chancellor --- arch/powerpc/boot/Makefile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/arch/powerpc/boot/Makefile b/arch/powerpc/boot/Makefile index d32d95aea5d6..0d4a8e8bdcab 100644 --- a/arch/powerpc/boot/Makefile +++ b/arch/powerpc/boot/Makefile @@ -44,6 +44,9 @@ BOOTCFLAGS +=3D -m64 -mcpu=3Dpowerpc64le else BOOTCFLAGS +=3D -m64 -mcpu=3Dpowerpc64 endif +ifdef CONFIG_PPC64_ELF_ABI_V2 +BOOTCFLAGS +=3D $(call cc-option,-mabi=3Delfv2) +endif else BOOTCFLAGS +=3D -m32 -mcpu=3Dpowerpc endif @@ -55,9 +58,6 @@ BOOTCFLAGS +=3D -mbig-endian else BOOTCFLAGS +=3D -mlittle-endian endif -ifdef CONFIG_PPC64_ELF_ABI_V2 -BOOTCFLAGS +=3D $(call cc-option,-mabi=3Delfv2) -endif =20 BOOTAFLAGS :=3D -D__ASSEMBLY__ $(BOOTCFLAGS) -nostdinc =20 --=20 2.39.2 From nobody Thu Sep 11 20:55:05 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 6DD71C636D4 for ; Wed, 15 Feb 2023 18:43:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229487AbjBOSm7 (ORCPT ); Wed, 15 Feb 2023 13:42:59 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59792 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229609AbjBOSm4 (ORCPT ); Wed, 15 Feb 2023 13:42:56 -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 8F1953CE34 for ; Wed, 15 Feb 2023 10:42:31 -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 2D45061D25 for ; Wed, 15 Feb 2023 18:41:28 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0242FC4339C; Wed, 15 Feb 2023 18:41:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1676486487; bh=S6yVv++b65cKUFiT1cYYAPG0IYVYL9tj+zjmVfJD+Zk=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=rB+kfF+dhz5w+QmVPHcrcLgFtFDbFuOvzN5aFHsok+4YXPR81oIL98QzjGhCaDx+z jsMJd454lmfvgl2tVn2unZm4mIe0ZKy2HYLarBHPynIQ2D5jQ3evdZLKjHTA+HcSkF XszqP60J6FJLAA+qsnrXWjk2Nsgs4bcDlnv1Q7+3YsXhYq+C/FqQGAAM9bVz7qzHj9 +PCU4KMRpS4omZtleXio5oJuF6sCjrm7N+qZzPJjP0DEUnoeBiaVVj1hp21O6g9TRs SzGT/2ocPlPSkKk5QGERq+bp4yOPGfs1Ezj3BqY9yqApWfU1ejjuK9lxRAQKh9Hlko 3Up+9Ry2UadyA== From: Nathan Chancellor Date: Wed, 15 Feb 2023 11:41:16 -0700 Subject: [PATCH 2/3] powerpc: Fix use of '-mabi=elfv2' with clang MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20230118-ppc64-elfv2-llvm-v1-2-b9e2ec9da11d@kernel.org> References: <20230118-ppc64-elfv2-llvm-v1-0-b9e2ec9da11d@kernel.org> In-Reply-To: <20230118-ppc64-elfv2-llvm-v1-0-b9e2ec9da11d@kernel.org> To: mpe@ellerman.id.au Cc: npiggin@gmail.com, christophe.leroy@csgroup.eu, erhard_f@mailbox.org, nathan@kernel.org, ndesaulniers@google.com, trix@redhat.com, linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org, llvm@lists.linux.dev, patches@lists.linux.dev X-Mailer: b4 0.12.1 X-Developer-Signature: v=1; a=openpgp-sha256; l=1880; i=nathan@kernel.org; h=from:subject:message-id; bh=S6yVv++b65cKUFiT1cYYAPG0IYVYL9tj+zjmVfJD+Zk=; b=owGbwMvMwCEmm602sfCA1DTG02pJDMlv1UO17k02Z26YoWbpfXPSBdset27J7m8R3792T95zS EF07em8jlIWBjEOBlkxRZbqx6rHDQ3nnGW8cWoSzBxWJpAhDFycAjCRgDmMDNNCvnlsi9+lmndg rvuu3TtCdhnJKjQePpzldulZ1cV63VCGfxovmz0WvVB+zXBiVhXPesEydy/bG14tDZMOzcq2bVv 7nBEA X-Developer-Key: i=nathan@kernel.org; a=openpgp; fpr=2437CB76E544CB6AB3D9DFD399739260CB6CB716 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org '-mabi=3Delfv2' is not added to clang's invocations when CONFIG_PPC64_ELF_ABI_V2 is enabled, resulting in the generation of elfv1 code, as evidenced by the orphan section warnings/errors: ld.lld: error: vmlinux.a(arch/powerpc/kernel/prom_init.o):(.opd) is being= placed in '.opd' ld.lld: error: vmlinux.a(init/main.o):(.opd) is being placed in '.opd' ld.lld: error: vmlinux.a(init/version.o):(.opd) is being placed in '.opd' To resolve this, add '-mabi=3Delfv2' to CFLAGS with clang. This uncovers an issue in the 32-bit vDSO: error: unknown target ABI 'elfv2' The ELFv2 ABI cannot be used when building code for a 32-bit target. To resolve this, just remove the '-mabi' flags from the assembler flags, as it was only needed for preprocessing (the _CALL_ELF macro) but this was cleaned up in commit 5b89492c03e5 ("powerpc: Finalise cleanup around ABI use"). Tested-by: "Erhard F." --- arch/powerpc/Makefile | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/arch/powerpc/Makefile b/arch/powerpc/Makefile index dc4cbf0a5ca9..3f2dd930e3cd 100644 --- a/arch/powerpc/Makefile +++ b/arch/powerpc/Makefile @@ -123,14 +123,12 @@ endif endif =20 CFLAGS-$(CONFIG_PPC64) :=3D $(call cc-option,-mtraceback=3Dno) -ifndef CONFIG_CC_IS_CLANG ifdef CONFIG_PPC64_ELF_ABI_V2 CFLAGS-$(CONFIG_PPC64) +=3D $(call cc-option,-mabi=3Delfv2,$(call cc-optio= n,-mcall-aixdesc)) -AFLAGS-$(CONFIG_PPC64) +=3D $(call cc-option,-mabi=3Delfv2) else +ifndef CONFIG_CC_IS_CLANG CFLAGS-$(CONFIG_PPC64) +=3D $(call cc-option,-mabi=3Delfv1) CFLAGS-$(CONFIG_PPC64) +=3D $(call cc-option,-mcall-aixdesc) -AFLAGS-$(CONFIG_PPC64) +=3D $(call cc-option,-mabi=3Delfv1) endif endif CFLAGS-$(CONFIG_PPC64) +=3D $(call cc-option,-mcmodel=3Dmedium,$(call cc-o= ption,-mminimal-toc)) --=20 2.39.2 From nobody Thu Sep 11 20:55:05 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 9ADF9C636CC for ; Wed, 15 Feb 2023 18:43:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229598AbjBOSnG (ORCPT ); Wed, 15 Feb 2023 13:43:06 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59790 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229609AbjBOSnA (ORCPT ); Wed, 15 Feb 2023 13:43:00 -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 B3C423E091 for ; Wed, 15 Feb 2023 10:42:34 -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 85A76B82371 for ; Wed, 15 Feb 2023 18:41:29 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B9E63C4339E; Wed, 15 Feb 2023 18:41:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1676486488; bh=fc+5seqhTO5BvvY3isnCsCZbytpHZYKbkp6X0pw+tz0=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=KwKxexKOjWpIM62ogFQODLQ1bQsNzLet37om+7MP+97xaJyIyy2vgnIwKvqGHgSum AK1HlTcMi+AvC332r/QIwE+/49lsjRtJJSV4BIXQMrnonWfh+22HtMsqqs7j8kwYyW w1EKs81R8h99F0BIHuSoZfDAmS6VE5JSMLdZ+IFrjA4FhQ/WlqFpzGOvDUzu4ZTqOq FYLfMowZLmq29qGViyPSz7myGFzjL33q7gGLhZfuv3GDwHSYvo80FQH+P2N8ItH8t1 EkSsDc48uZakeV8iEsThXGc2ro9ZjG3icqKXOi2XHl4Nf9kwmXsGAq9DohtR+CUXdi ndi0MW4G87mvA== From: Nathan Chancellor Date: Wed, 15 Feb 2023 11:41:17 -0700 Subject: [PATCH 3/3] powerpc: Allow CONFIG_PPC64_BIG_ENDIAN_ELF_ABI_V2 with ld.lld 15+ MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20230118-ppc64-elfv2-llvm-v1-3-b9e2ec9da11d@kernel.org> References: <20230118-ppc64-elfv2-llvm-v1-0-b9e2ec9da11d@kernel.org> In-Reply-To: <20230118-ppc64-elfv2-llvm-v1-0-b9e2ec9da11d@kernel.org> To: mpe@ellerman.id.au Cc: npiggin@gmail.com, christophe.leroy@csgroup.eu, erhard_f@mailbox.org, nathan@kernel.org, ndesaulniers@google.com, trix@redhat.com, linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org, llvm@lists.linux.dev, patches@lists.linux.dev X-Mailer: b4 0.12.1 X-Developer-Signature: v=1; a=openpgp-sha256; l=1504; i=nathan@kernel.org; h=from:subject:message-id; bh=fc+5seqhTO5BvvY3isnCsCZbytpHZYKbkp6X0pw+tz0=; b=owGbwMvMwCEmm602sfCA1DTG02pJDMlv1UPn3nmjdiU36FOT54YGk9jbwdOfzrpwQ4Lldo2jh aTmydrijlIWBjEOBlkxRZbqx6rHDQ3nnGW8cWoSzBxWJpAhDFycAjAR3mCG/xFvgraEdZq6CVXX CPptLaiNF2zQ335f/duS/6bbGRO9lRgZHkb0V30yMWtbK9nNreCq1Vi8e/3F+z8LMgqXK/R7Bzh zAwA= X-Developer-Key: i=nathan@kernel.org; a=openpgp; fpr=2437CB76E544CB6AB3D9DFD399739260CB6CB716 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit 5017b4594672 ("powerpc/64: Option to build big-endian with ELFv2 ABI") restricted the ELFv2 ABI configuration such that it can only be selected when linking with ld.bfd, due to lack of testing with LLVM. ld.lld can link ELFv2 kernels without any issues; in fact, it is the only ABI that ld.lld supports, as ELFv1 is not supported in ld.lld. As this has not seen a ton of real world testing yet, be conservative and only allow this option to be selected with the latest stable release of LLVM (15.x) and newer. While in the area, remove 'default n', as it is unnecessary to specify it explicitly since all boolean/tristate configuration symbols default to n. Tested-by: "Erhard F." --- arch/powerpc/Kconfig | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig index b8c4ac56bddc..f9f13029c98a 100644 --- a/arch/powerpc/Kconfig +++ b/arch/powerpc/Kconfig @@ -603,8 +603,7 @@ config PPC64_BIG_ENDIAN_ELF_ABI_V2 bool "Build big-endian kernel using ELF ABI V2 (EXPERIMENTAL)" depends on PPC64 && CPU_BIG_ENDIAN depends on CC_HAS_ELFV2 - depends on LD_IS_BFD && LD_VERSION >=3D 22400 - default n + depends on LD_VERSION >=3D 22400 || LLD_VERSION >=3D 150000 help This builds the kernel image using the "Power Architecture 64-Bit ELF V2 ABI Specification", which has a reduced stack overhead and faster --=20 2.39.2