1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef __ASM_COMPILER_H
3 #define __ASM_COMPILER_H
6 #define ARM64_ASM_PREAMBLE ".arch " ARM64_ASM_ARCH "\n"
8 #define ARM64_ASM_PREAMBLE
12 * The EL0/EL1 pointer bits used by a pointer authentication code.
13 * This is dependent on TBI0/TBI1 being enabled, or bits 63:56 would also apply.
15 #define ptrauth_user_pac_mask() GENMASK_ULL(54, vabits_actual)
16 #define ptrauth_kernel_pac_mask() GENMASK_ULL(63, vabits_actual)
18 /* Valid for EL0 TTBR0 and EL1 TTBR1 instruction pointers */
19 #define ptrauth_clear_pac(ptr) \
20 ((ptr & BIT_ULL(55)) ? (ptr | ptrauth_kernel_pac_mask()) : \
21 (ptr & ~ptrauth_user_pac_mask()))
23 #define __builtin_return_address(val) \
24 (void *)(ptrauth_clear_pac((unsigned long)__builtin_return_address(val)))
26 #ifdef CONFIG_CFI_CLANG
28 * With CONFIG_CFI_CLANG, the compiler replaces function address
29 * references with the address of the function's CFI jump table
30 * entry. The function_nocfi macro always returns the address of the
31 * actual function instead.
33 #define function_nocfi(x) ({ \
35 asm("adrp %0, " __stringify(x) "\n\t" \
36 "add %0, %0, :lo12:" __stringify(x) \
42 #endif /* __ASM_COMPILER_H */