.. | .. |
---|
2 | 2 | #ifndef _ASM_SCS_H |
---|
3 | 3 | #define _ASM_SCS_H |
---|
4 | 4 | |
---|
5 | | -#ifndef __ASSEMBLY__ |
---|
| 5 | +#ifdef __ASSEMBLY__ |
---|
6 | 6 | |
---|
7 | | -#include <linux/scs.h> |
---|
| 7 | +#include <asm/asm-offsets.h> |
---|
8 | 8 | |
---|
9 | 9 | #ifdef CONFIG_SHADOW_CALL_STACK |
---|
| 10 | + scs_sp .req x18 |
---|
10 | 11 | |
---|
11 | | -extern void scs_init_irq(void); |
---|
| 12 | + .macro scs_load_current |
---|
| 13 | + get_current_task scs_sp |
---|
| 14 | + ldr scs_sp, [scs_sp, #TSK_TI_SCS_SP] |
---|
| 15 | + .endm |
---|
12 | 16 | |
---|
13 | | -static __always_inline void scs_save(struct task_struct *tsk) |
---|
14 | | -{ |
---|
15 | | - void *s; |
---|
| 17 | + .macro scs_save tsk, tmp |
---|
| 18 | + str scs_sp, [\tsk, #TSK_TI_SCS_SP] |
---|
| 19 | + .endm |
---|
| 20 | +#else |
---|
| 21 | + .macro scs_load_current |
---|
| 22 | + .endm |
---|
16 | 23 | |
---|
17 | | - asm volatile("mov %0, x18" : "=r" (s)); |
---|
18 | | - task_set_scs(tsk, s); |
---|
19 | | -} |
---|
20 | | - |
---|
21 | | -static inline void scs_overflow_check(struct task_struct *tsk) |
---|
22 | | -{ |
---|
23 | | - if (unlikely(scs_corrupted(tsk))) |
---|
24 | | - panic("corrupted shadow stack detected inside scheduler\n"); |
---|
25 | | -} |
---|
26 | | - |
---|
27 | | -#else /* CONFIG_SHADOW_CALL_STACK */ |
---|
28 | | - |
---|
29 | | -static inline void scs_init_irq(void) {} |
---|
30 | | -static inline void scs_save(struct task_struct *tsk) {} |
---|
31 | | -static inline void scs_overflow_check(struct task_struct *tsk) {} |
---|
32 | | - |
---|
| 24 | + .macro scs_save tsk, tmp |
---|
| 25 | + .endm |
---|
33 | 26 | #endif /* CONFIG_SHADOW_CALL_STACK */ |
---|
34 | 27 | |
---|
35 | 28 | #endif /* __ASSEMBLY __ */ |
---|