xref: /openbmc/linux/arch/x86/include/asm/shstk.h (revision 7e24a55b2122746c2eef192296fc84624354f895)
198cfa463SRick Edgecombe /* SPDX-License-Identifier: GPL-2.0 */
298cfa463SRick Edgecombe #ifndef _ASM_X86_SHSTK_H
398cfa463SRick Edgecombe #define _ASM_X86_SHSTK_H
498cfa463SRick Edgecombe 
598cfa463SRick Edgecombe #ifndef __ASSEMBLY__
698cfa463SRick Edgecombe #include <linux/types.h>
798cfa463SRick Edgecombe 
898cfa463SRick Edgecombe struct task_struct;
905e36022SRick Edgecombe struct ksignal;
1098cfa463SRick Edgecombe 
1198cfa463SRick Edgecombe #ifdef CONFIG_X86_USER_SHADOW_STACK
122d39a6adSRick Edgecombe struct thread_shstk {
132d39a6adSRick Edgecombe 	u64	base;
142d39a6adSRick Edgecombe 	u64	size;
152d39a6adSRick Edgecombe };
162d39a6adSRick Edgecombe 
1767840ad0SRick Edgecombe long shstk_prctl(struct task_struct *task, int option, unsigned long arg2);
1898cfa463SRick Edgecombe void reset_thread_features(void);
19b2926a36SRick Edgecombe unsigned long shstk_alloc_thread_stack(struct task_struct *p, unsigned long clone_flags,
20b2926a36SRick Edgecombe 				       unsigned long stack_size);
212d39a6adSRick Edgecombe void shstk_free(struct task_struct *p);
2205e36022SRick Edgecombe int setup_signal_shadow_stack(struct ksignal *ksig);
2305e36022SRick Edgecombe int restore_signal_shadow_stack(void);
24*27465601SJiri Olsa int shstk_update_last_frame(unsigned long val);
2598cfa463SRick Edgecombe #else
shstk_prctl(struct task_struct * task,int option,unsigned long arg2)2698cfa463SRick Edgecombe static inline long shstk_prctl(struct task_struct *task, int option,
2798cfa463SRick Edgecombe 			       unsigned long arg2) { return -EINVAL; }
reset_thread_features(void)2898cfa463SRick Edgecombe static inline void reset_thread_features(void) {}
shstk_alloc_thread_stack(struct task_struct * p,unsigned long clone_flags,unsigned long stack_size)29b2926a36SRick Edgecombe static inline unsigned long shstk_alloc_thread_stack(struct task_struct *p,
30b2926a36SRick Edgecombe 						     unsigned long clone_flags,
31b2926a36SRick Edgecombe 						     unsigned long stack_size) { return 0; }
shstk_free(struct task_struct * p)322d39a6adSRick Edgecombe static inline void shstk_free(struct task_struct *p) {}
setup_signal_shadow_stack(struct ksignal * ksig)3305e36022SRick Edgecombe static inline int setup_signal_shadow_stack(struct ksignal *ksig) { return 0; }
restore_signal_shadow_stack(void)3405e36022SRick Edgecombe static inline int restore_signal_shadow_stack(void) { return 0; }
shstk_update_last_frame(unsigned long val)35*27465601SJiri Olsa static inline int shstk_update_last_frame(unsigned long val) { return 0; }
3698cfa463SRick Edgecombe #endif /* CONFIG_X86_USER_SHADOW_STACK */
3798cfa463SRick Edgecombe 
3898cfa463SRick Edgecombe #endif /* __ASSEMBLY__ */
3998cfa463SRick Edgecombe 
4098cfa463SRick Edgecombe #endif /* _ASM_X86_SHSTK_H */
41