blob: 51a7ce87cdfe07c55409d766118dfedda56d9535 [file] [log] [blame]
Amit Daniel Kachhap689eae422020-03-13 14:34:58 +05301/* SPDX-License-Identifier: GPL-2.0 */
2#ifndef __ASM_COMPILER_H
3#define __ASM_COMPILER_H
4
Amit Daniel Kachhap689eae422020-03-13 14:34:58 +05305/*
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
Amit Daniel Kachhap689eae422020-03-13 14:34:58 +053020#endif /* __ASM_COMPILER_H */