Amit Daniel Kachhap | 689eae42 | 2020-03-13 14:34:58 +0530 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
| 2 | #ifndef __ASM_COMPILER_H |
| 3 | #define __ASM_COMPILER_H |
| 4 | |
| 5 | #if defined(CONFIG_ARM64_PTR_AUTH) |
| 6 | |
| 7 | /* |
| 8 | * The EL0/EL1 pointer bits used by a pointer authentication code. |
| 9 | * This is dependent on TBI0/TBI1 being enabled, or bits 63:56 would also apply. |
| 10 | */ |
| 11 | #define ptrauth_user_pac_mask() GENMASK_ULL(54, vabits_actual) |
| 12 | #define ptrauth_kernel_pac_mask() GENMASK_ULL(63, vabits_actual) |
| 13 | |
| 14 | /* Valid for EL0 TTBR0 and EL1 TTBR1 instruction pointers */ |
| 15 | #define ptrauth_clear_pac(ptr) \ |
| 16 | ((ptr & BIT_ULL(55)) ? (ptr | ptrauth_kernel_pac_mask()) : \ |
| 17 | (ptr & ~ptrauth_user_pac_mask())) |
| 18 | |
| 19 | #define __builtin_return_address(val) \ |
| 20 | (void *)(ptrauth_clear_pac((unsigned long)__builtin_return_address(val))) |
| 21 | |
| 22 | #endif /* CONFIG_ARM64_PTR_AUTH */ |
| 23 | |
| 24 | #endif /* __ASM_COMPILER_H */ |