It is not sufficient to check if a toolchain supports a particular extension without checking if the linker supports that extension too. For example, Clang 15 supports Zihintpause but GNU bintutils 2.35.2 does not, leading build errors like so: riscv64-linux-gnu-ld: -march=rv64i2p0_m2p0_a2p0_c2p0_zihintpause2p0: Invalid or unknown z ISA extension: 'zihintpause' Add a TOOLCHAIN_HAS_ZIHINTPAUSE which checks if each of the compiler, assembler and linker support the extension. Replace the ifdef in the vdso with one depending on this new symbol. Fixes: 8eb060e10185 ("arch/riscv: add Zihintpause support") Signed-off-by: Conor Dooley <conor.dooley@microchip.com> Reviewed-by: Heiko Stuebner <heiko@sntech.de> Reviewed-by: Nathan Chancellor <nathan@kernel.org> Link: https://lore.kernel.org/r/20221006173520.1785507-3-conor@kernel.org Signed-off-by: Palmer Dabbelt <palmer@rivosinc.com>
37 lines
843 B
C
37 lines
843 B
C
/* SPDX-License-Identifier: GPL-2.0-only */
|
|
#ifndef __ASM_VDSO_PROCESSOR_H
|
|
#define __ASM_VDSO_PROCESSOR_H
|
|
|
|
#ifndef __ASSEMBLY__
|
|
|
|
#include <linux/jump_label.h>
|
|
#include <asm/barrier.h>
|
|
#include <asm/hwcap.h>
|
|
|
|
static inline void cpu_relax(void)
|
|
{
|
|
if (!static_branch_likely(&riscv_isa_ext_keys[RISCV_ISA_EXT_KEY_ZIHINTPAUSE])) {
|
|
#ifdef __riscv_muldiv
|
|
int dummy;
|
|
/* In lieu of a halt instruction, induce a long-latency stall. */
|
|
__asm__ __volatile__ ("div %0, %0, zero" : "=r" (dummy));
|
|
#endif
|
|
} else {
|
|
/*
|
|
* Reduce instruction retirement.
|
|
* This assumes the PC changes.
|
|
*/
|
|
#ifdef CONFIG_TOOLCHAIN_HAS_ZIHINTPAUSE
|
|
__asm__ __volatile__ ("pause");
|
|
#else
|
|
/* Encoding of the pause instruction */
|
|
__asm__ __volatile__ (".4byte 0x100000F");
|
|
#endif
|
|
}
|
|
barrier();
|
|
}
|
|
|
|
#endif /* __ASSEMBLY__ */
|
|
|
|
#endif /* __ASM_VDSO_PROCESSOR_H */
|