diff mbox series

[4/4] arm64: drop binutils version checks

Message ID 20250407094116.1339199-5-arnd@kernel.org (mailing list archive)
State New
Headers show
Series Make gcc-8.1 and binutils-2.30 the minimum version | expand

Commit Message

Arnd Bergmann April 7, 2025, 9:41 a.m. UTC
From: Arnd Bergmann <arnd@arndb.de>

Now that gcc-8 and binutils-2.30 are the minimum versions, a lot of
the individual feature checks can go away for simplification.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 arch/arm64/Kconfig              | 37 ++-------------------------------
 arch/arm64/Makefile             | 21 ++-----------------
 arch/arm64/include/asm/rwonce.h |  4 ----
 arch/arm64/kvm/Kconfig          |  1 -
 arch/arm64/lib/xor-neon.c       |  2 +-
 5 files changed, 5 insertions(+), 60 deletions(-)

Comments

Will Deacon April 8, 2025, 8:46 a.m. UTC | #1
Hi Arnd,

On Mon, Apr 07, 2025 at 11:41:16AM +0200, Arnd Bergmann wrote:
> From: Arnd Bergmann <arnd@arndb.de>
> 
> Now that gcc-8 and binutils-2.30 are the minimum versions, a lot of
> the individual feature checks can go away for simplification.
> 
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> ---
>  arch/arm64/Kconfig              | 37 ++-------------------------------
>  arch/arm64/Makefile             | 21 ++-----------------
>  arch/arm64/include/asm/rwonce.h |  4 ----
>  arch/arm64/kvm/Kconfig          |  1 -
>  arch/arm64/lib/xor-neon.c       |  2 +-
>  5 files changed, 5 insertions(+), 60 deletions(-)

Since some of these checks are dynamic (i.e. they try passing various
options to the tools to see if they barf), have you checked that the
minimum supported version of clang implements them all?

Will
Arnd Bergmann April 8, 2025, 1:10 p.m. UTC | #2
On Tue, Apr 8, 2025, at 10:46, Will Deacon wrote:
> Hi Arnd,
>
> On Mon, Apr 07, 2025 at 11:41:16AM +0200, Arnd Bergmann wrote:
>> From: Arnd Bergmann <arnd@arndb.de>
>> 
>> Now that gcc-8 and binutils-2.30 are the minimum versions, a lot of
>> the individual feature checks can go away for simplification.
>> 
>> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
>> ---
>>  arch/arm64/Kconfig              | 37 ++-------------------------------
>>  arch/arm64/Makefile             | 21 ++-----------------
>>  arch/arm64/include/asm/rwonce.h |  4 ----
>>  arch/arm64/kvm/Kconfig          |  1 -
>>  arch/arm64/lib/xor-neon.c       |  2 +-
>>  5 files changed, 5 insertions(+), 60 deletions(-)
>
> Since some of these checks are dynamic (i.e. they try passing various
> options to the tools to see if they barf), have you checked that the
> minimum supported version of clang implements them all?

I did some randconfig build testing with clang-13/lld-13, since that
is the oldest supported version, and checked that the options are
all supported. I'm pretty sure it's been there for a long time before
that already.

      Arnd
Mark Rutland April 8, 2025, 2:05 p.m. UTC | #3
Hi Arnd,

On Mon, Apr 07, 2025 at 11:41:16AM +0200, Arnd Bergmann wrote:
> From: Arnd Bergmann <arnd@arndb.de>
> 
> Now that gcc-8 and binutils-2.30 are the minimum versions, a lot of
> the individual feature checks can go away for simplification.
> 
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>

To address Will's concern, I grabbed the LLVM 13.0.1 (since that's the
minimum supported version) from https://www.kernel.org/pub//tools/llvm/,
and using v6.15-rc1 I checked the Kconfig resulting from:

  # magic script that puts the toolchain in my $PATH
  usekorg-llvm 13.0.1 make ARCH=arm64 LLVM=1 defconfig
  usekorg-llvm 13.0.1 make ARCH=arm64 LLVM=1 menuconfig

I then applied this series, and built a defconfig kernel with the same
toolchain, which built cleanly and boots fine.

The gist is that everything looks good, so:

Acked-by: Mark Rutland <mark.rutland@arm.com>

More specifically, with that I see:

	CC_IS_CLANG [=y]
	AS_IS_LLVM [=y]
	LD_IS_LLD [=y]

... and I've noted each of the Kconfig options below.

[...]

> -config ARM64_LD_HAS_FIX_ERRATUM_843419
> -	def_bool $(ld-option,--fix-cortex-a53-843419)

	ARM64_LD_HAS_FIX_ERRATUM_843419 [=y] 

> -config AS_HAS_LSE_ATOMICS
> -	def_bool $(as-instr,.arch_extension lse)

	AS_HAS_LSE_ATOMICS [=y]

> -config AS_HAS_ARMV8_2
> -	def_bool $(cc-option,-Wa$(comma)-march=armv8.2-a)

	AS_HAS_ARMV8_2 [=y]

> -config AS_HAS_SHA3
> -	def_bool $(as-instr,.arch armv8.2-a+sha3)

	AS_HAS_SHA3 [=y]

> -config CC_HAS_SIGN_RETURN_ADDRESS
> -	# GCC 7, 8
> -	def_bool $(cc-option,-msign-return-address=all)

	 CC_HAS_SIGN_RETURN_ADDRESS [=y]

> -config AS_HAS_ARMV8_3
> -	def_bool $(cc-option,-Wa$(comma)-march=armv8.3-a)

	AS_HAS_ARMV8_3 [=y]

>  config AS_HAS_CFI_NEGATE_RA_STATE
> +	# binutils 2.34+
>  	def_bool $(as-instr,.cfi_startproc\n.cfi_negate_ra_state\n.cfi_endproc\n)

	AS_HAS_CFI_NEGATE_RA_STATE [=y]

> -config AS_HAS_LDAPR
> -	def_bool $(as-instr,.arch_extension rcpc)

	AS_HAS_LDAPR [=y]

> -config AS_HAS_ARMV8_4
> -	def_bool $(cc-option,-Wa$(comma)-march=armv8.4-a)

	AS_HAS_ARMV8_4 [=y]

> diff --git a/arch/arm64/Makefile b/arch/arm64/Makefile
> index 1d5dfcd1c13e..73a10f65ce8b 100644
> --- a/arch/arm64/Makefile
> +++ b/arch/arm64/Makefile
> @@ -16,14 +16,11 @@ ifeq ($(CONFIG_RELOCATABLE), y)
>  # Pass --no-apply-dynamic-relocs to restore pre-binutils-2.27 behaviour
>  # for relative relocs, since this leads to better Image compression
>  # with the relocation offsets always being zero.
> -LDFLAGS_vmlinux		+= -shared -Bsymbolic -z notext \
> -			$(call ld-option, --no-apply-dynamic-relocs)
> +LDFLAGS_vmlinux	+= -shared -Bsymbolic -z notext --no-apply-dynamic-relocs
>  endif

Looks good:

  [mark@lakrids:~/src/linux]% usekorg-llvm 13.0.1 ld.lld -shared -Bsymbolic -z notext --made-up-argument       
  ld.lld: error: unknown argument '--made-up-argument'
  [mark@lakrids:~/src/linux]% usekorg-llvm 13.0.1 ld.lld -shared -Bsymbolic -z notext --no-apply-dynamic-relocs
  ld.lld: error: no input files

>  ifeq ($(CONFIG_ARM64_ERRATUM_843419),y)
> -  ifeq ($(CONFIG_ARM64_LD_HAS_FIX_ERRATUM_843419),y)
>  LDFLAGS_vmlinux	+= --fix-cortex-a53-843419
> -  endif
>  endif

Looks good:

  [mark@lakrids:~/src/linux]% usekorg-llvm 13.0.1 ld.lld --made-up-argument
  ld.lld: error: unknown argument '--made-up-argument'
  [mark@lakrids:~/src/linux]% usekorg-llvm 13.0.1 ld.lld --fix-cortex-a53-843419
  ld.lld: error: no input files

[...]

>  ifeq ($(CONFIG_AS_HAS_ARMV8_5), y)
>    asm-arch := armv8.5-a
> -else ifeq ($(CONFIG_AS_HAS_ARMV8_4), y)
> +else
>    asm-arch := armv8.4-a
> -else ifeq ($(CONFIG_AS_HAS_ARMV8_3), y)
> -  asm-arch := armv8.3-a
> -else ifeq ($(CONFIG_AS_HAS_ARMV8_2), y)
> -  asm-arch := armv8.2-a
>  endif

Looks good; this was checked in Kconfig.

[...]

>  archprepare:
>  	$(Q)$(MAKE) $(build)=arch/arm64/tools kapi
> -ifeq ($(CONFIG_ARM64_ERRATUM_843419),y)
> -  ifneq ($(CONFIG_ARM64_LD_HAS_FIX_ERRATUM_843419),y)
> -	@echo "warning: ld does not support --fix-cortex-a53-843419; kernel may be susceptible to erratum" >&2
> -  endif
> -endif
> -ifeq ($(CONFIG_ARM64_USE_LSE_ATOMICS),y)
> -  ifneq ($(CONFIG_ARM64_LSE_ATOMICS),y)
> -	@echo "warning: LSE atomics not supported by binutils" >&2
> -  endif
> -endif

Looks good; both were checked in Kconfig.

[...]

> -#ifdef CONFIG_AS_HAS_LDAPR
>  #define __LOAD_RCPC(sfx, regs...)					\
>  	ALTERNATIVE(							\
>  		"ldar"	#sfx "\t" #regs,				\
>  		".arch_extension rcpc\n"				\
>  		"ldapr"	#sfx "\t" #regs,				\
>  	ARM64_HAS_LDAPR)
> -#else
> -#define __LOAD_RCPC(sfx, regs...)	"ldar" #sfx "\t" #regs
> -#endif /* CONFIG_AS_HAS_LDAPR */

Looks good.

>  
>  /*
>   * When building with LTO, there is an increased risk of the compiler
> diff --git a/arch/arm64/kvm/Kconfig b/arch/arm64/kvm/Kconfig
> index 096e45acadb2..713248f240e0 100644
> --- a/arch/arm64/kvm/Kconfig
> +++ b/arch/arm64/kvm/Kconfig
> @@ -19,7 +19,6 @@ if VIRTUALIZATION
>  
>  menuconfig KVM
>  	bool "Kernel-based Virtual Machine (KVM) support"
> -	depends on AS_HAS_ARMV8_4
>  	select KVM_COMMON
>  	select KVM_GENERIC_HARDWARE_ENABLING
>  	select KVM_GENERIC_MMU_NOTIFIER

Looks good.

> diff --git a/arch/arm64/lib/xor-neon.c b/arch/arm64/lib/xor-neon.c
> index f9a53b7f9842..8fffebfa17b2 100644
> --- a/arch/arm64/lib/xor-neon.c
> +++ b/arch/arm64/lib/xor-neon.c
> @@ -319,7 +319,7 @@ static void xor_arm64_eor3_5(unsigned long bytes,
>  
>  static int __init xor_neon_init(void)
>  {
> -	if (IS_ENABLED(CONFIG_AS_HAS_SHA3) && cpu_have_named_feature(SHA3)) {
> +	if (cpu_have_named_feature(SHA3)) {

Looks good.

Mark.
Will Deacon April 11, 2025, 4:02 p.m. UTC | #4
On Tue, Apr 08, 2025 at 03:10:57PM +0200, Arnd Bergmann wrote:
> On Tue, Apr 8, 2025, at 10:46, Will Deacon wrote:
> > Hi Arnd,
> >
> > On Mon, Apr 07, 2025 at 11:41:16AM +0200, Arnd Bergmann wrote:
> >> From: Arnd Bergmann <arnd@arndb.de>
> >> 
> >> Now that gcc-8 and binutils-2.30 are the minimum versions, a lot of
> >> the individual feature checks can go away for simplification.
> >> 
> >> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> >> ---
> >>  arch/arm64/Kconfig              | 37 ++-------------------------------
> >>  arch/arm64/Makefile             | 21 ++-----------------
> >>  arch/arm64/include/asm/rwonce.h |  4 ----
> >>  arch/arm64/kvm/Kconfig          |  1 -
> >>  arch/arm64/lib/xor-neon.c       |  2 +-
> >>  5 files changed, 5 insertions(+), 60 deletions(-)
> >
> > Since some of these checks are dynamic (i.e. they try passing various
> > options to the tools to see if they barf), have you checked that the
> > minimum supported version of clang implements them all?
> 
> I did some randconfig build testing with clang-13/lld-13, since that
> is the oldest supported version, and checked that the options are
> all supported. I'm pretty sure it's been there for a long time before
> that already.

Thanks (especially to Mark!) for checking.

Will
diff mbox series

Patch

diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig
index a182295e6f08..d33e3955566d 100644
--- a/arch/arm64/Kconfig
+++ b/arch/arm64/Kconfig
@@ -642,9 +642,6 @@  config ARM64_ERRATUM_843419
 
 	  If unsure, say Y.
 
-config ARM64_LD_HAS_FIX_ERRATUM_843419
-	def_bool $(ld-option,--fix-cortex-a53-843419)
-
 config ARM64_ERRATUM_1024718
 	bool "Cortex-A55: 1024718: Update of DBM/AP bits without break before make might result in incorrect update"
 	default y
@@ -1890,13 +1887,9 @@  config ARM64_PAN
 	  The feature is detected at runtime, and will remain as a 'nop'
 	  instruction if the cpu does not implement the feature.
 
-config AS_HAS_LSE_ATOMICS
-	def_bool $(as-instr,.arch_extension lse)
-
 config ARM64_LSE_ATOMICS
 	bool
 	default ARM64_USE_LSE_ATOMICS
-	depends on AS_HAS_LSE_ATOMICS
 
 config ARM64_USE_LSE_ATOMICS
 	bool "Atomic instructions"
@@ -1908,20 +1901,12 @@  config ARM64_USE_LSE_ATOMICS
 
 	  Say Y here to make use of these instructions for the in-kernel
 	  atomic routines. This incurs a small overhead on CPUs that do
-	  not support these instructions and requires the kernel to be
-	  built with binutils >= 2.25 in order for the new instructions
-	  to be used.
+	  not support these instructions.
 
 endmenu # "ARMv8.1 architectural features"
 
 menu "ARMv8.2 architectural features"
 
-config AS_HAS_ARMV8_2
-	def_bool $(cc-option,-Wa$(comma)-march=armv8.2-a)
-
-config AS_HAS_SHA3
-	def_bool $(as-instr,.arch armv8.2-a+sha3)
-
 config ARM64_PMEM
 	bool "Enable support for persistent memory"
 	select ARCH_HAS_PMEM_API
@@ -1995,7 +1980,6 @@  config ARM64_PTR_AUTH_KERNEL
 	bool "Use pointer authentication for kernel"
 	default y
 	depends on ARM64_PTR_AUTH
-	depends on (CC_HAS_SIGN_RETURN_ADDRESS || CC_HAS_BRANCH_PROT_PAC_RET) && AS_HAS_ARMV8_3
 	# Modern compilers insert a .note.gnu.property section note for PAC
 	# which is only understood by binutils starting with version 2.33.1.
 	depends on LD_IS_LLD || LD_VERSION >= 23301 || (CC_IS_GCC && GCC_VERSION < 90100)
@@ -2016,19 +2000,10 @@  config CC_HAS_BRANCH_PROT_PAC_RET
 	# GCC 9 or later, clang 8 or later
 	def_bool $(cc-option,-mbranch-protection=pac-ret+leaf)
 
-config CC_HAS_SIGN_RETURN_ADDRESS
-	# GCC 7, 8
-	def_bool $(cc-option,-msign-return-address=all)
-
-config AS_HAS_ARMV8_3
-	def_bool $(cc-option,-Wa$(comma)-march=armv8.3-a)
-
 config AS_HAS_CFI_NEGATE_RA_STATE
+	# binutils 2.34+
 	def_bool $(as-instr,.cfi_startproc\n.cfi_negate_ra_state\n.cfi_endproc\n)
 
-config AS_HAS_LDAPR
-	def_bool $(as-instr,.arch_extension rcpc)
-
 endmenu # "ARMv8.3 architectural features"
 
 menu "ARMv8.4 architectural features"
@@ -2056,20 +2031,13 @@  config ARM64_AMU_EXTN
 	  correctly reflect reality. Most commonly, the value read will be 0,
 	  indicating that the counter is not enabled.
 
-config AS_HAS_ARMV8_4
-	def_bool $(cc-option,-Wa$(comma)-march=armv8.4-a)
-
 config ARM64_TLB_RANGE
 	bool "Enable support for tlbi range feature"
 	default y
-	depends on AS_HAS_ARMV8_4
 	help
 	  ARMv8.4-TLBI provides TLBI invalidation instruction that apply to a
 	  range of input addresses.
 
-	  The feature introduces new assembly instructions, and they were
-	  support when binutils >= 2.30.
-
 endmenu # "ARMv8.4 architectural features"
 
 menu "ARMv8.5 architectural features"
@@ -2145,7 +2113,6 @@  config ARM64_MTE
 	default y
 	depends on ARM64_AS_HAS_MTE && ARM64_TAGGED_ADDR_ABI
 	depends on AS_HAS_ARMV8_5
-	depends on AS_HAS_LSE_ATOMICS
 	# Required for tag checking in the uaccess routines
 	select ARM64_PAN
 	select ARCH_HAS_SUBPAGE_FAULTS
diff --git a/arch/arm64/Makefile b/arch/arm64/Makefile
index 1d5dfcd1c13e..73a10f65ce8b 100644
--- a/arch/arm64/Makefile
+++ b/arch/arm64/Makefile
@@ -16,14 +16,11 @@  ifeq ($(CONFIG_RELOCATABLE), y)
 # Pass --no-apply-dynamic-relocs to restore pre-binutils-2.27 behaviour
 # for relative relocs, since this leads to better Image compression
 # with the relocation offsets always being zero.
-LDFLAGS_vmlinux		+= -shared -Bsymbolic -z notext \
-			$(call ld-option, --no-apply-dynamic-relocs)
+LDFLAGS_vmlinux	+= -shared -Bsymbolic -z notext --no-apply-dynamic-relocs
 endif
 
 ifeq ($(CONFIG_ARM64_ERRATUM_843419),y)
-  ifeq ($(CONFIG_ARM64_LD_HAS_FIX_ERRATUM_843419),y)
 LDFLAGS_vmlinux	+= --fix-cortex-a53-843419
-  endif
 endif
 
 cc_has_k_constraint := $(call try-run,echo				\
@@ -105,12 +102,8 @@  endif
 # hardware.
 ifeq ($(CONFIG_AS_HAS_ARMV8_5), y)
   asm-arch := armv8.5-a
-else ifeq ($(CONFIG_AS_HAS_ARMV8_4), y)
+else
   asm-arch := armv8.4-a
-else ifeq ($(CONFIG_AS_HAS_ARMV8_3), y)
-  asm-arch := armv8.3-a
-else ifeq ($(CONFIG_AS_HAS_ARMV8_2), y)
-  asm-arch := armv8.2-a
 endif
 
 ifdef asm-arch
@@ -201,16 +194,6 @@  install zinstall:
 
 archprepare:
 	$(Q)$(MAKE) $(build)=arch/arm64/tools kapi
-ifeq ($(CONFIG_ARM64_ERRATUM_843419),y)
-  ifneq ($(CONFIG_ARM64_LD_HAS_FIX_ERRATUM_843419),y)
-	@echo "warning: ld does not support --fix-cortex-a53-843419; kernel may be susceptible to erratum" >&2
-  endif
-endif
-ifeq ($(CONFIG_ARM64_USE_LSE_ATOMICS),y)
-  ifneq ($(CONFIG_ARM64_LSE_ATOMICS),y)
-	@echo "warning: LSE atomics not supported by binutils" >&2
-  endif
-endif
 
 ifeq ($(KBUILD_EXTMOD),)
 # We need to generate vdso-offsets.h before compiling certain files in kernel/.
diff --git a/arch/arm64/include/asm/rwonce.h b/arch/arm64/include/asm/rwonce.h
index 56f7b1d4d54b..97d9256d33c9 100644
--- a/arch/arm64/include/asm/rwonce.h
+++ b/arch/arm64/include/asm/rwonce.h
@@ -12,16 +12,12 @@ 
 
 #ifndef BUILD_VDSO
 
-#ifdef CONFIG_AS_HAS_LDAPR
 #define __LOAD_RCPC(sfx, regs...)					\
 	ALTERNATIVE(							\
 		"ldar"	#sfx "\t" #regs,				\
 		".arch_extension rcpc\n"				\
 		"ldapr"	#sfx "\t" #regs,				\
 	ARM64_HAS_LDAPR)
-#else
-#define __LOAD_RCPC(sfx, regs...)	"ldar" #sfx "\t" #regs
-#endif /* CONFIG_AS_HAS_LDAPR */
 
 /*
  * When building with LTO, there is an increased risk of the compiler
diff --git a/arch/arm64/kvm/Kconfig b/arch/arm64/kvm/Kconfig
index 096e45acadb2..713248f240e0 100644
--- a/arch/arm64/kvm/Kconfig
+++ b/arch/arm64/kvm/Kconfig
@@ -19,7 +19,6 @@  if VIRTUALIZATION
 
 menuconfig KVM
 	bool "Kernel-based Virtual Machine (KVM) support"
-	depends on AS_HAS_ARMV8_4
 	select KVM_COMMON
 	select KVM_GENERIC_HARDWARE_ENABLING
 	select KVM_GENERIC_MMU_NOTIFIER
diff --git a/arch/arm64/lib/xor-neon.c b/arch/arm64/lib/xor-neon.c
index f9a53b7f9842..8fffebfa17b2 100644
--- a/arch/arm64/lib/xor-neon.c
+++ b/arch/arm64/lib/xor-neon.c
@@ -319,7 +319,7 @@  static void xor_arm64_eor3_5(unsigned long bytes,
 
 static int __init xor_neon_init(void)
 {
-	if (IS_ENABLED(CONFIG_AS_HAS_SHA3) && cpu_have_named_feature(SHA3)) {
+	if (cpu_have_named_feature(SHA3)) {
 		xor_block_inner_neon.do_3 = xor_arm64_eor3_3;
 		xor_block_inner_neon.do_4 = xor_arm64_eor3_4;
 		xor_block_inner_neon.do_5 = xor_arm64_eor3_5;