1*d2912cb1SThomas Gleixner /* SPDX-License-Identifier: GPL-2.0-only */
2d8f8b844SMickaël Salaün /*
3d8f8b844SMickaël Salaün * Access to user system call parameters and results
4d8f8b844SMickaël Salaün *
5d8f8b844SMickaël Salaün * See asm-generic/syscall.h for function descriptions.
6d8f8b844SMickaël Salaün *
7d8f8b844SMickaël Salaün * Copyright (C) 2015 Mickaël Salaün <mic@digikod.net>
8d8f8b844SMickaël Salaün */
9d8f8b844SMickaël Salaün
10d8f8b844SMickaël Salaün #ifndef __UM_SYSCALL_GENERIC_H
11d8f8b844SMickaël Salaün #define __UM_SYSCALL_GENERIC_H
12d8f8b844SMickaël Salaün
13d8f8b844SMickaël Salaün #include <asm/ptrace.h>
14d8f8b844SMickaël Salaün #include <linux/err.h>
15d8f8b844SMickaël Salaün #include <linux/sched.h>
16d8f8b844SMickaël Salaün #include <sysdep/ptrace.h>
17d8f8b844SMickaël Salaün
syscall_get_nr(struct task_struct * task,struct pt_regs * regs)18d8f8b844SMickaël Salaün static inline int syscall_get_nr(struct task_struct *task, struct pt_regs *regs)
19d8f8b844SMickaël Salaün {
20d8f8b844SMickaël Salaün
21d8f8b844SMickaël Salaün return PT_REGS_SYSCALL_NR(regs);
22d8f8b844SMickaël Salaün }
23d8f8b844SMickaël Salaün
syscall_rollback(struct task_struct * task,struct pt_regs * regs)24d8f8b844SMickaël Salaün static inline void syscall_rollback(struct task_struct *task,
25d8f8b844SMickaël Salaün struct pt_regs *regs)
26d8f8b844SMickaël Salaün {
27d8f8b844SMickaël Salaün /* do nothing */
28d8f8b844SMickaël Salaün }
29d8f8b844SMickaël Salaün
syscall_get_error(struct task_struct * task,struct pt_regs * regs)30d8f8b844SMickaël Salaün static inline long syscall_get_error(struct task_struct *task,
31d8f8b844SMickaël Salaün struct pt_regs *regs)
32d8f8b844SMickaël Salaün {
33d8f8b844SMickaël Salaün const long error = regs_return_value(regs);
34d8f8b844SMickaël Salaün
35d8f8b844SMickaël Salaün return IS_ERR_VALUE(error) ? error : 0;
36d8f8b844SMickaël Salaün }
37d8f8b844SMickaël Salaün
syscall_get_return_value(struct task_struct * task,struct pt_regs * regs)38d8f8b844SMickaël Salaün static inline long syscall_get_return_value(struct task_struct *task,
39d8f8b844SMickaël Salaün struct pt_regs *regs)
40d8f8b844SMickaël Salaün {
41d8f8b844SMickaël Salaün return regs_return_value(regs);
42d8f8b844SMickaël Salaün }
43d8f8b844SMickaël Salaün
syscall_set_return_value(struct task_struct * task,struct pt_regs * regs,int error,long val)44d8f8b844SMickaël Salaün static inline void syscall_set_return_value(struct task_struct *task,
45d8f8b844SMickaël Salaün struct pt_regs *regs,
46d8f8b844SMickaël Salaün int error, long val)
47d8f8b844SMickaël Salaün {
48d8f8b844SMickaël Salaün PT_REGS_SET_SYSCALL_RETURN(regs, (long) error ?: val);
49d8f8b844SMickaël Salaün }
50d8f8b844SMickaël Salaün
syscall_get_arguments(struct task_struct * task,struct pt_regs * regs,unsigned long * args)51d8f8b844SMickaël Salaün static inline void syscall_get_arguments(struct task_struct *task,
52d8f8b844SMickaël Salaün struct pt_regs *regs,
53d8f8b844SMickaël Salaün unsigned long *args)
54d8f8b844SMickaël Salaün {
55d8f8b844SMickaël Salaün const struct uml_pt_regs *r = ®s->regs;
56d8f8b844SMickaël Salaün
57d8f8b844SMickaël Salaün *args++ = UPT_SYSCALL_ARG1(r);
58d8f8b844SMickaël Salaün *args++ = UPT_SYSCALL_ARG2(r);
59d8f8b844SMickaël Salaün *args++ = UPT_SYSCALL_ARG3(r);
60d8f8b844SMickaël Salaün *args++ = UPT_SYSCALL_ARG4(r);
61d8f8b844SMickaël Salaün *args++ = UPT_SYSCALL_ARG5(r);
62b35f549dSSteven Rostedt (Red Hat) *args = UPT_SYSCALL_ARG6(r);
63d8f8b844SMickaël Salaün }
64d8f8b844SMickaël Salaün
65d8f8b844SMickaël Salaün /* See arch/x86/um/asm/syscall.h for syscall_get_arch() definition. */
66d8f8b844SMickaël Salaün
67d8f8b844SMickaël Salaün #endif /* __UM_SYSCALL_GENERIC_H */
68