1 /* SPDX-License-Identifier: GPL-2.0 */ 2 /* 3 * Copyright (C) 2020 Collabora Ltd. 4 */ 5 #ifndef _SYSCALL_USER_DISPATCH_H 6 #define _SYSCALL_USER_DISPATCH_H 7 8 #include <linux/thread_info.h> 9 #include <linux/sched.h> 10 #include <linux/syscall_user_dispatch_types.h> 11 12 struct pt_regs; 13 14 #ifdef CONFIG_SYSCALL_USER_DISPATCH 15 16 bool syscall_user_dispatch(struct pt_regs *regs); 17 18 static __always_inline bool syscall_user_dispatch_clear_on_dispatch(void) 19 { 20 if (likely(!current->syscall_dispatch.on_dispatch)) 21 return false; 22 23 current->syscall_dispatch.on_dispatch = false; 24 return true; 25 } 26 27 int set_syscall_user_dispatch(unsigned long mode, unsigned long offset, 28 unsigned long len, char __user *selector); 29 30 #define clear_syscall_work_syscall_user_dispatch(tsk) \ 31 clear_task_syscall_work(tsk, SYSCALL_USER_DISPATCH) 32 33 int syscall_user_dispatch_get_config(struct task_struct *task, unsigned long size, 34 void __user *data); 35 36 int syscall_user_dispatch_set_config(struct task_struct *task, unsigned long size, 37 void __user *data); 38 39 #else 40 41 static __always_inline bool syscall_user_dispatch(struct pt_regs *regs) 42 { 43 return false; 44 } 45 46 static __always_inline bool syscall_user_dispatch_clear_on_dispatch(void) 47 { 48 return false; 49 } 50 51 static inline int set_syscall_user_dispatch(unsigned long mode, unsigned long offset, 52 unsigned long len, char __user *selector) 53 { 54 return -EINVAL; 55 } 56 57 static inline void clear_syscall_work_syscall_user_dispatch(struct task_struct *tsk) 58 { 59 } 60 61 static inline int syscall_user_dispatch_get_config(struct task_struct *task, 62 unsigned long size, void __user *data) 63 { 64 return -EINVAL; 65 } 66 67 static inline int syscall_user_dispatch_set_config(struct task_struct *task, 68 unsigned long size, void __user *data) 69 { 70 return -EINVAL; 71 } 72 73 #endif /* CONFIG_SYSCALL_USER_DISPATCH */ 74 75 #endif /* _SYSCALL_USER_DISPATCH_H */ 76