summaryrefslogtreecommitdiff
path: root/arch/arm64/include/asm/scs.h
diff options
context:
space:
mode:
Diffstat (limited to 'arch/arm64/include/asm/scs.h')
-rw-r--r--arch/arm64/include/asm/scs.h46
1 files changed, 46 insertions, 0 deletions
diff --git a/arch/arm64/include/asm/scs.h b/arch/arm64/include/asm/scs.h
new file mode 100644
index 000000000000..96549353b0cb
--- /dev/null
+++ b/arch/arm64/include/asm/scs.h
@@ -0,0 +1,46 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#ifndef _ASM_SCS_H
+#define _ASM_SCS_H
+
+#ifdef __ASSEMBLY__
+
+#ifdef CONFIG_SHADOW_CALL_STACK
+ .macro scs_load tsk, tmp
+ ldp x18, \tmp, [\tsk, #TSK_TI_SCS_BASE]
+ add x18, x18, \tmp
+ .endm
+
+ .macro scs_save tsk, tmp
+ ldr \tmp, [\tsk, #TSK_TI_SCS_BASE]
+ sub \tmp, x18, \tmp
+ str \tmp, [\tsk, #TSK_TI_SCS_OFFSET]
+ .endm
+#else
+ .macro scs_load tsk, tmp
+ .endm
+
+ .macro scs_save tsk, tmp
+ .endm
+#endif /* CONFIG_SHADOW_CALL_STACK */
+
+#else /* __ASSEMBLY__ */
+
+#include <linux/scs.h>
+
+#ifdef CONFIG_SHADOW_CALL_STACK
+
+static inline void scs_overflow_check(struct task_struct *tsk)
+{
+ if (unlikely(scs_corrupted(tsk)))
+ panic("corrupted shadow stack detected inside scheduler\n");
+}
+
+#else /* CONFIG_SHADOW_CALL_STACK */
+
+static inline void scs_overflow_check(struct task_struct *tsk) {}
+
+#endif /* CONFIG_SHADOW_CALL_STACK */
+
+#endif /* __ASSEMBLY __ */
+
+#endif /* _ASM_SCS_H */