| .. | .. |
|---|
| 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 tsk, tmp |
|---|
| 13 | + ldr scs_sp, [\tsk, #TSK_TI_SCS_SP] |
|---|
| 14 | + .endm |
|---|
| 12 | 15 | |
|---|
| 13 | | -static __always_inline void scs_save(struct task_struct *tsk) |
|---|
| 14 | | -{ |
|---|
| 15 | | - void *s; |
|---|
| 16 | + .macro scs_save tsk, tmp |
|---|
| 17 | + str scs_sp, [\tsk, #TSK_TI_SCS_SP] |
|---|
| 18 | + .endm |
|---|
| 19 | +#else |
|---|
| 20 | + .macro scs_load tsk, tmp |
|---|
| 21 | + .endm |
|---|
| 16 | 22 | |
|---|
| 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 | | - |
|---|
| 23 | + .macro scs_save tsk, tmp |
|---|
| 24 | + .endm |
|---|
| 33 | 25 | #endif /* CONFIG_SHADOW_CALL_STACK */ |
|---|
| 34 | 26 | |
|---|
| 35 | 27 | #endif /* __ASSEMBLY __ */ |
|---|