Skip to content

Commit 952b64d

Browse files
Merge patch series "Fix RISC-V toolchain extension support detection"
Conor Dooley <[email protected]> says: From: Conor Dooley <[email protected]> This came up due to a report from Kevin @ kernel-ci, who had been running a mixed configuration of GNU binutils and clang. Their compiler was relatively recent & supports Zicbom but binutils @ 2.35.2 did not. Our current checks for extension support only cover the compiler, but it appears to me that we need to check both the compiler & linker support in case of "pot-luck" configurations that mix different versions of LD,AS,CC etc. Linker support does not seem possible to actually check, since the ISA string is emitted into the object files - so I put in version checks for that. The checks have gotten a bit ugly since 32 & 64 bit support need to be checked independently but ahh well. As I was going, I fell into the trap of there being duplicated checks for CC support in both the Makefile and Kconfig, so as part of renaming the Kconfig symbol to TOOLCHAIN_HAS_FOO, I dropped the extra checks in the Makefile. This has the added advantage of the TOOLCHAIN_HAS_FOO symbol for Zihintpause appearing in .config. I pushed out a version of this that specificly checked for assember support for LKP to test & it looked /okay/ - but I did some more testing today and realised that this is redudant & have since dropped the as check. I tested locally with a fair few different combinations, to try and cover each of AS, LD, CC missing support for the extension. * b4-shazam-merge: riscv: fix detection of toolchain Zihintpause support riscv: fix detection of toolchain Zicbom support Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Palmer Dabbelt <[email protected]>
2 parents 9f2ac64 + aae538c commit 952b64d

File tree

3 files changed

+16
-9
lines changed

3 files changed

+16
-9
lines changed

arch/riscv/Kconfig

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -411,14 +411,16 @@ config RISCV_ISA_SVPBMT
411411

412412
If you don't know what to do here, say Y.
413413

414-
config CC_HAS_ZICBOM
414+
config TOOLCHAIN_HAS_ZICBOM
415415
bool
416-
default y if 64BIT && $(cc-option,-mabi=lp64 -march=rv64ima_zicbom)
417-
default y if 32BIT && $(cc-option,-mabi=ilp32 -march=rv32ima_zicbom)
416+
default y
417+
depends on !64BIT || $(cc-option,-mabi=lp64 -march=rv64ima_zicbom)
418+
depends on !32BIT || $(cc-option,-mabi=ilp32 -march=rv32ima_zicbom)
419+
depends on LLD_VERSION >= 150000 || LD_VERSION >= 23800
418420

419421
config RISCV_ISA_ZICBOM
420422
bool "Zicbom extension support for non-coherent DMA operation"
421-
depends on CC_HAS_ZICBOM
423+
depends on TOOLCHAIN_HAS_ZICBOM
422424
depends on !XIP_KERNEL && MMU
423425
select RISCV_DMA_NONCOHERENT
424426
select RISCV_ALTERNATIVE
@@ -433,6 +435,13 @@ config RISCV_ISA_ZICBOM
433435

434436
If you don't know what to do here, say Y.
435437

438+
config TOOLCHAIN_HAS_ZIHINTPAUSE
439+
bool
440+
default y
441+
depends on !64BIT || $(cc-option,-mabi=lp64 -march=rv64ima_zihintpause)
442+
depends on !32BIT || $(cc-option,-mabi=ilp32 -march=rv32ima_zihintpause)
443+
depends on LLD_VERSION >= 150000 || LD_VERSION >= 23600
444+
436445
config FPU
437446
bool "FPU support"
438447
default y

arch/riscv/Makefile

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,12 +59,10 @@ toolchain-need-zicsr-zifencei := $(call cc-option-yn, -march=$(riscv-march-y)_zi
5959
riscv-march-$(toolchain-need-zicsr-zifencei) := $(riscv-march-y)_zicsr_zifencei
6060

6161
# Check if the toolchain supports Zicbom extension
62-
toolchain-supports-zicbom := $(call cc-option-yn, -march=$(riscv-march-y)_zicbom)
63-
riscv-march-$(toolchain-supports-zicbom) := $(riscv-march-y)_zicbom
62+
riscv-march-$(CONFIG_TOOLCHAIN_HAS_ZICBOM) := $(riscv-march-y)_zicbom
6463

6564
# Check if the toolchain supports Zihintpause extension
66-
toolchain-supports-zihintpause := $(call cc-option-yn, -march=$(riscv-march-y)_zihintpause)
67-
riscv-march-$(toolchain-supports-zihintpause) := $(riscv-march-y)_zihintpause
65+
riscv-march-$(CONFIG_TOOLCHAIN_HAS_ZIHINTPAUSE) := $(riscv-march-y)_zihintpause
6866

6967
KBUILD_CFLAGS += -march=$(subst fd,,$(riscv-march-y))
7068
KBUILD_AFLAGS += -march=$(riscv-march-y)

arch/riscv/include/asm/vdso/processor.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ static inline void cpu_relax(void)
2121
* Reduce instruction retirement.
2222
* This assumes the PC changes.
2323
*/
24-
#ifdef __riscv_zihintpause
24+
#ifdef CONFIG_TOOLCHAIN_HAS_ZIHINTPAUSE
2525
__asm__ __volatile__ ("pause");
2626
#else
2727
/* Encoding of the pause instruction */

0 commit comments

Comments
 (0)