Merge tag 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mst/vhost
[cris-mirror.git] / arch / sh / include / asm / syscall_64.h
blob43882580c7f99bec93e519f1b4182c1daad2fbf0
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef __ASM_SH_SYSCALL_64_H
3 #define __ASM_SH_SYSCALL_64_H
5 #include <uapi/linux/audit.h>
6 #include <linux/kernel.h>
7 #include <linux/sched.h>
8 #include <asm/ptrace.h>
10 /* The system call number is given by the user in R9 */
11 static inline long syscall_get_nr(struct task_struct *task,
12 struct pt_regs *regs)
14 return (regs->syscall_nr >= 0) ? regs->regs[9] : -1L;
17 static inline void syscall_rollback(struct task_struct *task,
18 struct pt_regs *regs)
21 * XXX: This needs some thought. On SH we don't
22 * save away the original R9 value anywhere.
26 static inline long syscall_get_error(struct task_struct *task,
27 struct pt_regs *regs)
29 return IS_ERR_VALUE(regs->regs[9]) ? regs->regs[9] : 0;
32 static inline long syscall_get_return_value(struct task_struct *task,
33 struct pt_regs *regs)
35 return regs->regs[9];
38 static inline void syscall_set_return_value(struct task_struct *task,
39 struct pt_regs *regs,
40 int error, long val)
42 if (error)
43 regs->regs[9] = -error;
44 else
45 regs->regs[9] = val;
48 static inline void syscall_get_arguments(struct task_struct *task,
49 struct pt_regs *regs,
50 unsigned int i, unsigned int n,
51 unsigned long *args)
53 BUG_ON(i + n > 6);
54 memcpy(args, &regs->regs[2 + i], n * sizeof(args[0]));
57 static inline void syscall_set_arguments(struct task_struct *task,
58 struct pt_regs *regs,
59 unsigned int i, unsigned int n,
60 const unsigned long *args)
62 BUG_ON(i + n > 6);
63 memcpy(&regs->regs[2 + i], args, n * sizeof(args[0]));
66 static inline int syscall_get_arch(void)
68 int arch = AUDIT_ARCH_SH;
70 #ifdef CONFIG_64BIT
71 arch |= __AUDIT_ARCH_64BIT;
72 #endif
73 #ifdef CONFIG_CPU_LITTLE_ENDIAN
74 arch |= __AUDIT_ARCH_LE;
75 #endif
77 return arch;
79 #endif /* __ASM_SH_SYSCALL_64_H */