xref: /linux/arch/arm64/include/asm/scs.h (revision 42d37fc0c819b81f6f6afd108b55d04ba9d32d0f)
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 int __pi_scs_patch(const u8 eh_frame[], int size);
50 asmlinkage void __pi_scs_patch_vmlinux(void);
51 
52 #endif /* __ASSEMBLY __ */
53 
54 #endif /* _ASM_SCS_H */
55