]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
riscv: Make sure toolchain supports zba before using zba instructions
authorAlexandre Ghiti <alexghiti@rivosinc.com>
Fri, 28 Mar 2025 11:54:22 +0000 (12:54 +0100)
committerAlexandre Ghiti <alexghiti@rivosinc.com>
Tue, 1 Apr 2025 07:07:13 +0000 (07:07 +0000)
Old toolchain like gcc 8.5.0 does not support zba, so we must check that
the toolchain supports this extension before using it in the kernel.

Reported-by: kernel test robot <lkp@intel.com>
Closes: https://lore.kernel.org/oe-kbuild-all/202503281836.8pntHm6I-lkp@intel.com/
Link: https://lore.kernel.org/r/20250328115422.253670-1-alexghiti@rivosinc.com
Signed-off-by: Alexandre Ghiti <alexghiti@rivosinc.com>
arch/riscv/Kconfig
arch/riscv/include/asm/runtime-const.h

index 0d8def968a7ef3042344f6279c448ffab8c85187..ae6303f15b287409c3d08f4c95a424b6c20d1bc6 100644 (file)
@@ -735,6 +735,14 @@ config TOOLCHAIN_HAS_VECTOR_CRYPTO
        def_bool $(as-instr, .option arch$(comma) +v$(comma) +zvkb)
        depends on AS_HAS_OPTION_ARCH
 
+config TOOLCHAIN_HAS_ZBA
+       bool
+       default y
+       depends on !64BIT || $(cc-option,-mabi=lp64 -march=rv64ima_zba)
+       depends on !32BIT || $(cc-option,-mabi=ilp32 -march=rv32ima_zba)
+       depends on LLD_VERSION >= 150000 || LD_VERSION >= 23900
+       depends on AS_HAS_OPTION_ARCH
+
 config RISCV_ISA_ZBA
        bool "Zba extension support for bit manipulation instructions"
        default y
index ea2e49c7149cdcee61a1cb37a58db358cf3eaecf..c07d049fdd5d2999c57d8a90e7363829c5462368 100644 (file)
@@ -77,7 +77,8 @@
        ".long 1b - .\n\t"                                      \
        ".popsection"                                           \
 
-#if defined(CONFIG_RISCV_ISA_ZBA) && defined(CONFIG_RISCV_ISA_ZBKB)
+#if defined(CONFIG_RISCV_ISA_ZBA) && defined(CONFIG_TOOLCHAIN_HAS_ZBA) \
+       && defined(CONFIG_RISCV_ISA_ZBKB)
 #define runtime_const_ptr(sym)                                         \
 ({                                                                     \
        typeof(sym) __ret, __tmp;                                       \
@@ -93,7 +94,7 @@
                : [__ret] "=r" (__ret), [__tmp] "=r" (__tmp));          \
        __ret;                                                          \
 })
-#elif defined(CONFIG_RISCV_ISA_ZBA)
+#elif defined(CONFIG_RISCV_ISA_ZBA) && defined(CONFIG_TOOLCHAIN_HAS_ZBA)
 #define runtime_const_ptr(sym)                                         \
 ({                                                                     \
        typeof(sym) __ret, __tmp;                                       \