File Index
Files and directories
Sign in
FILE

syscall-generic.h

File preview with syntax highlighting.

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