summaryrefslogtreecommitdiff
path: root/include/linux/syscall_user_dispatch.h
blob: 3dd30f4b279977534f526db1d09af4acf2909d41 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
/* SPDX-License-Identifier: GPL-2.0 */
/*
 * Copyright (C) 2020 Collabora Ltd.
 */
#ifndef _SYSCALL_USER_DISPATCH_H
#define _SYSCALL_USER_DISPATCH_H

#include <linux/thread_info.h>
#include <linux/sched.h>
#include <linux/syscall_user_dispatch_types.h>

struct pt_regs;

#ifdef CONFIG_SYSCALL_USER_DISPATCH

bool syscall_user_dispatch(struct pt_regs *regs);

static __always_inline bool syscall_user_dispatch_clear_on_dispatch(void)
{
	if (likely(!current->syscall_dispatch.on_dispatch))
		return false;

	current->syscall_dispatch.on_dispatch = false;
	return true;
}

int set_syscall_user_dispatch(unsigned long mode, unsigned long offset,
			      unsigned long len, char __user *selector);

#define clear_syscall_work_syscall_user_dispatch(tsk) \
	clear_task_syscall_work(tsk, SYSCALL_USER_DISPATCH)

int syscall_user_dispatch_get_config(struct task_struct *task, unsigned long size,
				     void __user *data);

int syscall_user_dispatch_set_config(struct task_struct *task, unsigned long size,
				     void __user *data);

#else

static __always_inline bool syscall_user_dispatch(struct pt_regs *regs)
{
	return false;
}

static __always_inline bool syscall_user_dispatch_clear_on_dispatch(void)
{
	return false;
}

static inline int set_syscall_user_dispatch(unsigned long mode, unsigned long offset,
					    unsigned long len, char __user *selector)
{
	return -EINVAL;
}

static inline void clear_syscall_work_syscall_user_dispatch(struct task_struct *tsk)
{
}

static inline int syscall_user_dispatch_get_config(struct task_struct *task,
						   unsigned long size, void __user *data)
{
	return -EINVAL;
}

static inline int syscall_user_dispatch_set_config(struct task_struct *task,
						   unsigned long size, void __user *data)
{
	return -EINVAL;
}

#endif /* CONFIG_SYSCALL_USER_DISPATCH */

#endif /* _SYSCALL_USER_DISPATCH_H */