162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */
262306a36Sopenharmony_ci#ifndef _ASM_X86_SHSTK_H
362306a36Sopenharmony_ci#define _ASM_X86_SHSTK_H
462306a36Sopenharmony_ci
562306a36Sopenharmony_ci#ifndef __ASSEMBLY__
662306a36Sopenharmony_ci#include <linux/types.h>
762306a36Sopenharmony_ci
862306a36Sopenharmony_cistruct task_struct;
962306a36Sopenharmony_cistruct ksignal;
1062306a36Sopenharmony_ci
1162306a36Sopenharmony_ci#ifdef CONFIG_X86_USER_SHADOW_STACK
1262306a36Sopenharmony_cistruct thread_shstk {
1362306a36Sopenharmony_ci	u64	base;
1462306a36Sopenharmony_ci	u64	size;
1562306a36Sopenharmony_ci};
1662306a36Sopenharmony_ci
1762306a36Sopenharmony_cilong shstk_prctl(struct task_struct *task, int option, unsigned long arg2);
1862306a36Sopenharmony_civoid reset_thread_features(void);
1962306a36Sopenharmony_ciunsigned long shstk_alloc_thread_stack(struct task_struct *p, unsigned long clone_flags,
2062306a36Sopenharmony_ci				       unsigned long stack_size);
2162306a36Sopenharmony_civoid shstk_free(struct task_struct *p);
2262306a36Sopenharmony_ciint setup_signal_shadow_stack(struct ksignal *ksig);
2362306a36Sopenharmony_ciint restore_signal_shadow_stack(void);
2462306a36Sopenharmony_ci#else
2562306a36Sopenharmony_cistatic inline long shstk_prctl(struct task_struct *task, int option,
2662306a36Sopenharmony_ci			       unsigned long arg2) { return -EINVAL; }
2762306a36Sopenharmony_cistatic inline void reset_thread_features(void) {}
2862306a36Sopenharmony_cistatic inline unsigned long shstk_alloc_thread_stack(struct task_struct *p,
2962306a36Sopenharmony_ci						     unsigned long clone_flags,
3062306a36Sopenharmony_ci						     unsigned long stack_size) { return 0; }
3162306a36Sopenharmony_cistatic inline void shstk_free(struct task_struct *p) {}
3262306a36Sopenharmony_cistatic inline int setup_signal_shadow_stack(struct ksignal *ksig) { return 0; }
3362306a36Sopenharmony_cistatic inline int restore_signal_shadow_stack(void) { return 0; }
3462306a36Sopenharmony_ci#endif /* CONFIG_X86_USER_SHADOW_STACK */
3562306a36Sopenharmony_ci
3662306a36Sopenharmony_ci#endif /* __ASSEMBLY__ */
3762306a36Sopenharmony_ci
3862306a36Sopenharmony_ci#endif /* _ASM_X86_SHSTK_H */
39