xref: /linux/arch/arm64/include/asm/scs.h (revision 7f71507851fc7764b36a3221839607d3a45c2025)
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef _ASM_SCS_H
3 #define _ASM_SCS_H
4 
5 #ifdef __ASSEMBLY__
6 
7 #include <asm/asm-offsets.h>
8 #include <asm/sysreg.h>
9 
10 #ifdef CONFIG_SHADOW_CALL_STACK
11 	scs_sp	.req	x18
12 
13 	.macro scs_load_current
14 	get_current_task scs_sp
15 	ldr	scs_sp, [scs_sp, #TSK_TI_SCS_SP]
16 	.endm
17 
18 	.macro scs_save tsk
19 	str	scs_sp, [\tsk, #TSK_TI_SCS_SP]
20 	.endm
21 #else
22 	.macro scs_load_current
23 	.endm
24 
25 	.macro scs_save tsk
26 	.endm
27 #endif /* CONFIG_SHADOW_CALL_STACK */
28 
29 
30 #else
31 
32 #include <linux/scs.h>
33 #include <asm/cpufeature.h>
34 
35 #ifdef CONFIG_UNWIND_PATCH_PAC_INTO_SCS
36 static inline void dynamic_scs_init(void)
37 {
38 	extern bool __pi_dynamic_scs_is_enabled;
39 
40 	if (__pi_dynamic_scs_is_enabled) {
41 		pr_info("Enabling dynamic shadow call stack\n");
42 		static_branch_enable(&dynamic_scs_enabled);
43 	}
44 }
45 #else
46 static inline void dynamic_scs_init(void) {}
47 #endif
48 
49 enum {
50 	EDYNSCS_INVALID_CIE_HEADER		= 1,
51 	EDYNSCS_INVALID_CIE_SDATA_SIZE		= 2,
52 	EDYNSCS_INVALID_FDE_AUGM_DATA_SIZE	= 3,
53 	EDYNSCS_INVALID_CFA_OPCODE		= 4,
54 };
55 
56 int __pi_scs_patch(const u8 eh_frame[], int size);
57 
58 #endif /* __ASSEMBLY __ */
59 
60 #endif /* _ASM_SCS_H */
61