Skip to contentSkip to conversation

arm64: Simplify gas LSE support detection

PATCH In review Catalin Marinas 3 participants 7 messages Jan 15, 2020

Subsystems (3)
lore
Share & tools
lore

Catalin Marinas

author maintainer
#0 lore raw

v2 cover arm64: Simplify gas LSE support detection

Version two of the patch series moving the LSE assembler support detection from Makefile to Kconfig.

Changes since v1 [1]:

- Re-introduce the Makefile warning if the .config contains CONFIG_ARM64_USE_LSE_ATOMICS but the assembler does not support the feature, disabling CONFIG_ARM64_LSE_ATOMICS.

[1] http://lkml.kernel.org/r/[email protected]

Catalin Marinas (2):
kbuild: Add support for 'as-instr' to be used in Kconfig files
arm64: Move the LSE gas support detection to Kconfig

 arch/arm64/Kconfig                    |  5 +++++
 arch/arm64/Makefile                   | 11 ++++-------
 arch/arm64/include/asm/atomic_ll_sc.h |  2 +-
 arch/arm64/include/asm/lse.h          |  6 +++---
 arch/arm64/kernel/cpufeature.c        |  4 ++--
 scripts/Kconfig.include               |  4 ++++
 6 files changed, 19 insertions(+), 13 deletions(-)

_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

author maintainer
#1 lore raw

PATCH v2 1/2 kbuild: Add support for 'as-instr' to be used in Kconfig files

Similar to 'cc-option' or 'ld-option', it is occasionally necessary to check whether the assembler supports certain ISA extensions. In the arm64 code we currently do this in Makefile with an additional define:

lseinstr := $(call as-instr,.arch_extension lse,-DCONFIG_AS_LSE=1)

Add the 'as-instr' option so that it can be used in Kconfig directly:

	def_bool $(as-instr,.arch_extension lse)
---
 scripts/Kconfig.include | 4 ++++
 1 file changed, 4 insertions(+)
scripts/Kconfig.include +4 -0
index d4adfbe42690..9d07e59cbdf7 100644
@@ -31,6 +31,10 @@ cc-option = $(success,$(CC) -Werror $(CLANG_FLAGS) $(1) -E -x c /dev/null -o /de
 # Return y if the linker supports <flag>, n otherwise
 ld-option = $(success,$(LD) -v $(1))
 
+# $(as-instr,<instr>)
+# Return y if the assembler supports <instr>, n otherwise
+as-instr = $(success,printf "%b\n" "$(1)" | $(CC) $(CLANG_FLAGS) -c -x assembler -o /dev/null -)
+
 # check if $(CC) and $(LD) exist
 $(error-if,$(failure,command -v $(CC)),compiler '$(CC)' not found)
 $(error-if,$(failure,command -v $(LD)),linker '$(LD)' not found)

_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

author maintainer
#2 lore raw

PATCH v2 2/2 arm64: Move the LSE gas support detection to Kconfig

In reply to Catalin Marinas

As the Kconfig syntax gained support for $(as-instr) tests, move the LSE gas support detection from Makefile to the main arm64 Kconfig and remove the additional CONFIG_AS_LSE definition and check.

---

Notes:
v2:
- Re-introduce build-time warning if .config wants LSE atomics but gas does not support it
- Given that the patch was modified, I have not added Vladimir's reviewed-by tag on v1

 arch/arm64/Kconfig                    |  5 +++++
 arch/arm64/Makefile                   | 11 ++++-------
 arch/arm64/include/asm/atomic_ll_sc.h |  2 +-
 arch/arm64/include/asm/lse.h          |  6 +++---
 arch/arm64/kernel/cpufeature.c        |  4 ++--
 5 files changed, 15 insertions(+), 13 deletions(-)
arch/arm64/Kconfig +5 -0
index b1b4476ddb83..cf3b6d2a67cf 100644
@@ -1363,6 +1363,11 @@ config ARM64_PAN
 	 instruction if the cpu does not implement the feature.
 
 config ARM64_LSE_ATOMICS
+	bool
+	default ARM64_USE_LSE_ATOMICS
+	depends on $(as-instr,.arch_extension lse)
+
+config ARM64_USE_LSE_ATOMICS
 	bool "Atomic instructions"
 	depends on JUMP_LABEL
 	default y
arch/arm64/Makefile +4 -7
index 1fbe24d4fdb6..6dd8ecacc428 100644
@@ -30,11 +30,8 @@ LDFLAGS_vmlinux	+= --fix-cortex-a53-843419
   endif
 endif
 
-# Check for binutils support for specific extensions
-lseinstr := $(call as-instr,.arch_extension lse,-DCONFIG_AS_LSE=1)
-
-ifeq ($(CONFIG_ARM64_LSE_ATOMICS), y)
-  ifeq ($(lseinstr),)
+ifeq ($(CONFIG_ARM64_USE_LSE_ATOMICS), y)
+  ifneq ($(CONFIG_ARM64_LSE_ATOMICS), y)
 $(warning LSE atomics not supported by binutils)
   endif
 endif
@@ -53,11 +50,11 @@ $(warning Detected assembler with broken .inst; disassembly will be unreliable)
   endif
 endif
 
-KBUILD_CFLAGS	+= -mgeneral-regs-only $(lseinstr) $(brokengasinst)	\
+KBUILD_CFLAGS	+= -mgeneral-regs-only $(brokengasinst)	\
 		   $(compat_vdso) $(cc_has_k_constraint)
 KBUILD_CFLAGS	+= -fno-asynchronous-unwind-tables
 KBUILD_CFLAGS	+= $(call cc-disable-warning, psabi)
-KBUILD_AFLAGS	+= $(lseinstr) $(brokengasinst) $(compat_vdso)
+KBUILD_AFLAGS	+= $(brokengasinst) $(compat_vdso)
 
 KBUILD_CFLAGS	+= $(call cc-option,-mabi=lp64)
 KBUILD_AFLAGS	+= $(call cc-option,-mabi=lp64)
arch/arm64/include/asm/atomic_ll_sc.h +1 -1
index 7b012148bfd6..13869b76b58c 100644
@@ -12,7 +12,7 @@
 
 #include <linux/stringify.h>
 
-#if IS_ENABLED(CONFIG_ARM64_LSE_ATOMICS) && IS_ENABLED(CONFIG_AS_LSE)
+#ifdef CONFIG_ARM64_LSE_ATOMICS
 #define __LL_SC_FALLBACK(asm_ops)					\
 "	b	3f\n"							\
 "	.subsection	1\n"						\
arch/arm64/include/asm/lse.h +3 -3
index 80b388278149..4e1009fff686 100644
@@ -4,7 +4,7 @@
 
 #include <asm/atomic_ll_sc.h>
 
-#if defined(CONFIG_AS_LSE) && defined(CONFIG_ARM64_LSE_ATOMICS)
+#ifdef CONFIG_ARM64_LSE_ATOMICS
 
 #include <linux/compiler_types.h>
 #include <linux/export.h>
@@ -36,7 +36,7 @@ static inline bool system_uses_lse_atomics(void)
 #define ARM64_LSE_ATOMIC_INSN(llsc, lse)				\
 	ALTERNATIVE(llsc, lse, ARM64_HAS_LSE_ATOMICS)
 
-#else	/* CONFIG_AS_LSE && CONFIG_ARM64_LSE_ATOMICS */
+#else	/* CONFIG_ARM64_LSE_ATOMICS */
 
 static inline bool system_uses_lse_atomics(void) { return false; }
 
@@ -44,5 +44,5 @@ static inline bool system_uses_lse_atomics(void) { return false; }
 
 #define ARM64_LSE_ATOMIC_INSN(llsc, lse)	llsc
 
-#endif	/* CONFIG_AS_LSE && CONFIG_ARM64_LSE_ATOMICS */
+#endif	/* CONFIG_ARM64_LSE_ATOMICS */
 #endif	/* __ASM_LSE_H */
arch/arm64/kernel/cpufeature.c +2 -2
index 04cf64e9f0c9..2595c2886d3f 100644
@@ -1291,7 +1291,7 @@ static const struct arm64_cpu_capabilities arm64_features[] = {
 		.cpu_enable = cpu_enable_pan,
 	},
 #endif /* CONFIG_ARM64_PAN */
-#if defined(CONFIG_AS_LSE) && defined(CONFIG_ARM64_LSE_ATOMICS)
+#ifdef CONFIG_ARM64_LSE_ATOMICS
 	{
 		.desc = "LSE atomic instructions",
 		.capability = ARM64_HAS_LSE_ATOMICS,
@@ -1302,7 +1302,7 @@ static const struct arm64_cpu_capabilities arm64_features[] = {
 		.sign = FTR_UNSIGNED,
 		.min_field_value = 2,
 	},
-#endif /* CONFIG_AS_LSE && CONFIG_ARM64_LSE_ATOMICS */
+#endif /* CONFIG_ARM64_LSE_ATOMICS */
 	{
 		.desc = "Software prefetching using PRFM",
 		.capability = ARM64_HAS_NO_HW_PREFETCH,

_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

Reviewed-by Tested-by on the v2 series
#3 lore raw
In reply to Catalin Marinas
Quoted 15 lines · Catalin Marinas

Version two of the patch series moving the LSE assembler support detection from Makefile to Kconfig.

Changes since v1 [1]:

- Re-introduce the Makefile warning if the .config contains CONFIG_ARM64_USE_LSE_ATOMICS but the assembler does not support the feature, disabling CONFIG_ARM64_LSE_ATOMICS.

[1] http://lkml.kernel.org/r/[email protected]

Catalin Marinas (2):
kbuild: Add support for 'as-instr' to be used in Kconfig files
arm64: Move the LSE gas support detection to Kconfig

Quoted 9 lines
 arch/arm64/Kconfig                    |  5 +++++
 arch/arm64/Makefile                   | 11 ++++-------
 arch/arm64/include/asm/atomic_ll_sc.h |  2 +-
 arch/arm64/include/asm/lse.h          |  6 +++---
 arch/arm64/kernel/cpufeature.c        |  4 ++--
 scripts/Kconfig.include               |  4 ++++
 6 files changed, 19 insertions(+), 13 deletions(-)

with

aarch64-linux-gnu-gcc (crosstool-NG linaro-1.13.1-4.9-2014.09 - Linaro GCC 4.9-2014.09) 4.9.2 20140904 (prerelease)

I see (among other warnings)

arch/arm64/Makefile:35: LSE atomics not supported by binutils

while with

aarch64-none-linux-gnu-gcc (GNU Toolchain for the A-profile Architecture 9.2-2019.12 (arm-9.10)) 9.2.1 20191025

warning disappears.

FWIW:

Thanks
Vladimir

_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

maintainer
#4 lore raw
Quoted 38 lines · Vladimir Murzin
Quoted 15 lines · Catalin Marinas

Version two of the patch series moving the LSE assembler support detection from Makefile to Kconfig.

Changes since v1 [1]:

- Re-introduce the Makefile warning if the .config contains CONFIG_ARM64_USE_LSE_ATOMICS but the assembler does not support the feature, disabling CONFIG_ARM64_LSE_ATOMICS.

[1] http://lkml.kernel.org/r/[email protected]

Catalin Marinas (2):
kbuild: Add support for 'as-instr' to be used in Kconfig files
arm64: Move the LSE gas support detection to Kconfig

Quoted 9 lines
 arch/arm64/Kconfig                    |  5 +++++
 arch/arm64/Makefile                   | 11 ++++-------
 arch/arm64/include/asm/atomic_ll_sc.h |  2 +-
 arch/arm64/include/asm/lse.h          |  6 +++---
 arch/arm64/kernel/cpufeature.c        |  4 ++--
 scripts/Kconfig.include               |  4 ++++
 6 files changed, 19 insertions(+), 13 deletions(-)

with

aarch64-linux-gnu-gcc (crosstool-NG linaro-1.13.1-4.9-2014.09 - Linaro GCC 4.9-2014.09) 4.9.2 20140904 (prerelease)

I see (among other warnings)

arch/arm64/Makefile:35: LSE atomics not supported by binutils

while with

aarch64-none-linux-gnu-gcc (GNU Toolchain for the A-profile Architecture 9.2-2019.12 (arm-9.10)) 9.2.1 20191025

Quoted 7 lines

warning disappears.

FWIW:

Cheers, I've queued the patches with your tags.

Will

_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

#5 lore raw
Quoted 42 lines · Will Deacon
Quoted 41 lines · Vladimir Murzin
Quoted 15 lines · Catalin Marinas

Version two of the patch series moving the LSE assembler support detection from Makefile to Kconfig.

Changes since v1 [1]:

- Re-introduce the Makefile warning if the .config contains CONFIG_ARM64_USE_LSE_ATOMICS but the assembler does not support the feature, disabling CONFIG_ARM64_LSE_ATOMICS.

[1] http://lkml.kernel.org/r/[email protected]

Catalin Marinas (2):
kbuild: Add support for 'as-instr' to be used in Kconfig files
arm64: Move the LSE gas support detection to Kconfig

Quoted 9 lines
 arch/arm64/Kconfig                    |  5 +++++
 arch/arm64/Makefile                   | 11 ++++-------
 arch/arm64/include/asm/atomic_ll_sc.h |  2 +-
 arch/arm64/include/asm/lse.h          |  6 +++---
 arch/arm64/kernel/cpufeature.c        |  4 ++--
 scripts/Kconfig.include               |  4 ++++
 6 files changed, 19 insertions(+), 13 deletions(-)

with

aarch64-linux-gnu-gcc (crosstool-NG linaro-1.13.1-4.9-2014.09 - Linaro GCC 4.9-2014.09) 4.9.2 20140904 (prerelease)

I see (among other warnings)

arch/arm64/Makefile:35: LSE atomics not supported by binutils

while with

aarch64-none-linux-gnu-gcc (GNU Toolchain for the A-profile Architecture 9.2-2019.12 (arm-9.10)) 9.2.1 20191025

warning disappears.

Quoted 6 lines
Quoted 4 lines

FWIW:

Cheers, I've queued the patches with your tags.

Would you mind if I send follow-up patch for BROKEN_GAS_INST conversion (it depends on as-inst)?

Vladimir

Quoted 3 lines

Will

_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

maintainer
#6 lore raw
Quoted 45 lines · Vladimir Murzin
Quoted 44 lines · Will Deacon
Quoted 43 lines · Vladimir Murzin
Quoted 15 lines · Catalin Marinas

Version two of the patch series moving the LSE assembler support detection from Makefile to Kconfig.

Changes since v1 [1]:

- Re-introduce the Makefile warning if the .config contains CONFIG_ARM64_USE_LSE_ATOMICS but the assembler does not support the feature, disabling CONFIG_ARM64_LSE_ATOMICS.

[1] http://lkml.kernel.org/r/[email protected]

Catalin Marinas (2):
kbuild: Add support for 'as-instr' to be used in Kconfig files
arm64: Move the LSE gas support detection to Kconfig

Quoted 9 lines
 arch/arm64/Kconfig                    |  5 +++++
 arch/arm64/Makefile                   | 11 ++++-------
 arch/arm64/include/asm/atomic_ll_sc.h |  2 +-
 arch/arm64/include/asm/lse.h          |  6 +++---
 arch/arm64/kernel/cpufeature.c        |  4 ++--
 scripts/Kconfig.include               |  4 ++++
 6 files changed, 19 insertions(+), 13 deletions(-)

with

aarch64-linux-gnu-gcc (crosstool-NG linaro-1.13.1-4.9-2014.09 - Linaro GCC 4.9-2014.09) 4.9.2 20140904 (prerelease)

I see (among other warnings)

arch/arm64/Makefile:35: LSE atomics not supported by binutils

while with

aarch64-none-linux-gnu-gcc (GNU Toolchain for the A-profile Architecture 9.2-2019.12 (arm-9.10)) 9.2.1 20191025

warning disappears.

FWIW:

Quoted 7 lines
Quoted 4 lines
Quoted 2 lines

Cheers, I've queued the patches with your tags.

Would you mind if I send follow-up patch for BROKEN_GAS_INST conversion (it depends on as-inst)?

Sure, you can send whatever you like!

Will

_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel