1 /* SPDX-License-Identifier: GPL-2.0-only */
2 #ifndef __ASM_VDSO_PROCESSOR_H
3 #define __ASM_VDSO_PROCESSOR_H
4 
5 #ifndef __ASSEMBLY__
6 
7 #include <linux/jump_label.h>
8 #include <asm/barrier.h>
9 #include <asm/hwcap.h>
10 
11 static inline void cpu_relax(void)
12 {
13 	if (!static_branch_likely(&riscv_isa_ext_keys[RISCV_ISA_EXT_KEY_ZIHINTPAUSE])) {
14 #ifdef __riscv_muldiv
15 		int dummy;
16 		/* In lieu of a halt instruction, induce a long-latency stall. */
17 		__asm__ __volatile__ ("div %0, %0, zero" : "=r" (dummy));
18 #endif
19 	} else {
20 		/*
21 		 * Reduce instruction retirement.
22 		 * This assumes the PC changes.
23 		 */
24 #ifdef CONFIG_TOOLCHAIN_HAS_ZIHINTPAUSE
25 		__asm__ __volatile__ ("pause");
26 #else
27 		/* Encoding of the pause instruction */
28 		__asm__ __volatile__ (".4byte 0x100000F");
29 #endif
30 	}
31 	barrier();
32 }
33 
34 #endif /* __ASSEMBLY__ */
35 
36 #endif /* __ASM_VDSO_PROCESSOR_H */
37