xref: /linux/arch/riscv/include/asm/scs.h (revision 5643c6b2c8308b206cb01cbfd0e6ac80f9f1bc9a)
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef _ASM_SCS_H
3 #define _ASM_SCS_H
4 
5 #ifdef __ASSEMBLER__
6 #include <asm/asm-offsets.h>
7 
8 #ifdef CONFIG_SHADOW_CALL_STACK
9 
10 /* Load init_shadow_call_stack to gp. */
11 .macro scs_load_init_stack
12 	la	gp, init_shadow_call_stack
13 .endm
14 
15 /* Load the per-CPU IRQ shadow call stack to gp. */
16 .macro scs_load_irq_stack tmp
17 	load_per_cpu gp, irq_shadow_call_stack_ptr, \tmp
18 .endm
19 
20 /* Load task_scs_sp(current) to gp. */
21 .macro scs_load_current
22 	REG_L	gp, TASK_TI_SCS_SP(tp)
23 .endm
24 
25 /* Load task_scs_sp(current) to gp, but only if tp has changed. */
26 .macro scs_load_current_if_task_changed prev
27 	beq	\prev, tp, _skip_scs
28 	scs_load_current
29 _skip_scs:
30 .endm
31 
32 /* Save gp to task_scs_sp(current). */
33 .macro scs_save_current
34 	REG_S	gp, TASK_TI_SCS_SP(tp)
35 .endm
36 
37 #else /* CONFIG_SHADOW_CALL_STACK */
38 
39 .macro scs_load_init_stack
40 .endm
41 .macro scs_load_irq_stack tmp
42 .endm
43 .macro scs_load_current
44 .endm
45 .macro scs_load_current_if_task_changed prev
46 .endm
47 .macro scs_save_current
48 .endm
49 
50 #endif /* CONFIG_SHADOW_CALL_STACK */
51 #endif /* __ASSEMBLER__ */
52 
53 #endif /* _ASM_SCS_H */
54