1 /* SPDX-License-Identifier: GPL-2.0 */ 2 #ifndef _ASM_SCS_H 3 #define _ASM_SCS_H 4 5 #ifndef __ASSEMBLY__ 6 7 #include <linux/scs.h> 8 9 #ifdef CONFIG_SHADOW_CALL_STACK 10 11 extern void scs_init_irq(void); 12 scs_save(struct task_struct * tsk)13static __always_inline void scs_save(struct task_struct *tsk) 14 { 15 void *s; 16 17 asm volatile("mov %0, x18" : "=r" (s)); 18 task_set_scs(tsk, s); 19 } 20 scs_overflow_check(struct task_struct * tsk)21static 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 scs_init_irq(void)29static inline void scs_init_irq(void) {} scs_save(struct task_struct * tsk)30static inline void scs_save(struct task_struct *tsk) {} scs_overflow_check(struct task_struct * tsk)31static inline void scs_overflow_check(struct task_struct *tsk) {} 32 33 #endif /* CONFIG_SHADOW_CALL_STACK */ 34 35 #endif /* __ASSEMBLY __ */ 36 37 #endif /* _ASM_SCS_H */ 38