blob: c50d2b0c6c5fcbe2817363d4b95168ba85986785 [file] [log] [blame]
b.liue9582032025-04-17 19:18:16 +08001/* 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
11extern void scs_init_irq(void);
12
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
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
29static inline void scs_init_irq(void) {}
30static inline void scs_save(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 */