#include <linux/sched.h>
#include <linux/bitops.h>
#include <linux/types.h>
#include <linux/mm.h>
#include <linux/mman.h>
#include <linux/slab.h>
#include <linux/uaccess.h>
#include <linux/sched/signal.h>
#include <linux/compat.h>
#include <linux/sizes.h>
#include <linux/user.h>
#include <linux/syscalls.h>
#include <asm/msr.h>
#include <asm/fpu/xstate.h>
#include <asm/fpu/types.h>
#include <asm/shstk.h>
#include <asm/special_insns.h>
#include <asm/fpu/api.h>
#include <asm/prctl.h>
#define SS_FRAME_SIZE …
static bool features_enabled(unsigned long features)
{ … }
static void features_set(unsigned long features)
{ … }
static void features_clr(unsigned long features)
{ … }
static int create_rstor_token(unsigned long ssp, unsigned long *token_addr)
{ … }
static unsigned long alloc_shstk(unsigned long addr, unsigned long size,
unsigned long token_offset, bool set_res_tok)
{ … }
static unsigned long adjust_shstk_size(unsigned long size)
{ … }
static void unmap_shadow_stack(u64 base, u64 size)
{ … }
static int shstk_setup(void)
{ … }
void reset_thread_features(void)
{ … }
unsigned long shstk_alloc_thread_stack(struct task_struct *tsk, unsigned long clone_flags,
unsigned long stack_size)
{ … }
static unsigned long get_user_shstk_addr(void)
{ … }
#define SHSTK_DATA_BIT …
static int put_shstk_data(u64 __user *addr, u64 data)
{ … }
static int get_shstk_data(unsigned long *data, unsigned long __user *addr)
{ … }
static int shstk_push_sigframe(unsigned long *ssp)
{ … }
static int shstk_pop_sigframe(unsigned long *ssp)
{ … }
int setup_signal_shadow_stack(struct ksignal *ksig)
{ … }
int restore_signal_shadow_stack(void)
{ … }
void shstk_free(struct task_struct *tsk)
{ … }
static int wrss_control(bool enable)
{ … }
static int shstk_disable(void)
{ … }
SYSCALL_DEFINE3(map_shadow_stack, unsigned long, addr, unsigned long, size, unsigned int, flags)
{ … }
long shstk_prctl(struct task_struct *task, int option, unsigned long arg2)
{ … }
int shstk_update_last_frame(unsigned long val)
{ … }
bool shstk_is_enabled(void)
{ … }