Skip to content

Commit 8a2f20a

Browse files
author
Alexandre Ghiti
committed
riscv: Make sure toolchain supports zba before using zba instructions
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>
1 parent 3f70231 commit 8a2f20a

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

arch/riscv/Kconfig

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -735,6 +735,14 @@ config TOOLCHAIN_HAS_VECTOR_CRYPTO
735735
def_bool $(as-instr, .option arch$(comma) +v$(comma) +zvkb)
736736
depends on AS_HAS_OPTION_ARCH
737737

738+
config TOOLCHAIN_HAS_ZBA
739+
bool
740+
default y
741+
depends on !64BIT || $(cc-option,-mabi=lp64 -march=rv64ima_zba)
742+
depends on !32BIT || $(cc-option,-mabi=ilp32 -march=rv32ima_zba)
743+
depends on LLD_VERSION >= 150000 || LD_VERSION >= 23900
744+
depends on AS_HAS_OPTION_ARCH
745+
738746
config RISCV_ISA_ZBA
739747
bool "Zba extension support for bit manipulation instructions"
740748
default y

arch/riscv/include/asm/runtime-const.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,8 @@
7777
".long 1b - .\n\t" \
7878
".popsection" \
7979

80-
#if defined(CONFIG_RISCV_ISA_ZBA) && defined(CONFIG_RISCV_ISA_ZBKB)
80+
#if defined(CONFIG_RISCV_ISA_ZBA) && defined(CONFIG_TOOLCHAIN_HAS_ZBA) \
81+
&& defined(CONFIG_RISCV_ISA_ZBKB)
8182
#define runtime_const_ptr(sym) \
8283
({ \
8384
typeof(sym) __ret, __tmp; \
@@ -93,7 +94,7 @@
9394
: [__ret] "=r" (__ret), [__tmp] "=r" (__tmp)); \
9495
__ret; \
9596
})
96-
#elif defined(CONFIG_RISCV_ISA_ZBA)
97+
#elif defined(CONFIG_RISCV_ISA_ZBA) && defined(CONFIG_TOOLCHAIN_HAS_ZBA)
9798
#define runtime_const_ptr(sym) \
9899
({ \
99100
typeof(sym) __ret, __tmp; \

0 commit comments

Comments
 (0)