xref: /openbmc/linux/arch/arm64/include/asm/compiler.h (revision 4bb1eb3c)
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef __ASM_COMPILER_H
3 #define __ASM_COMPILER_H
4 
5 /*
6  * The EL0/EL1 pointer bits used by a pointer authentication code.
7  * This is dependent on TBI0/TBI1 being enabled, or bits 63:56 would also apply.
8  */
9 #define ptrauth_user_pac_mask()		GENMASK_ULL(54, vabits_actual)
10 #define ptrauth_kernel_pac_mask()	GENMASK_ULL(63, vabits_actual)
11 
12 /* Valid for EL0 TTBR0 and EL1 TTBR1 instruction pointers */
13 #define ptrauth_clear_pac(ptr)						\
14 	((ptr & BIT_ULL(55)) ? (ptr | ptrauth_kernel_pac_mask()) :	\
15 			       (ptr & ~ptrauth_user_pac_mask()))
16 
17 #define __builtin_return_address(val)					\
18 	(void *)(ptrauth_clear_pac((unsigned long)__builtin_return_address(val)))
19 
20 #endif /* __ASM_COMPILER_H */
21