blob: fd02761ba06cf5f1a2e780ee4ece115f7861c262 [file] [log] [blame]
Greg Kroah-Hartmanb2441312017-11-01 15:07:57 +01001/* SPDX-License-Identifier: GPL-2.0 */
Wade Farnsworthbf2c9f92012-04-04 16:19:02 +01002/*
3 * Access to user system call parameters and results
4 *
5 * See asm-generic/syscall.h for descriptions of what we must do here.
6 */
7
8#ifndef _ASM_ARM_SYSCALL_H
9#define _ASM_ARM_SYSCALL_H
10
Eric Paris579ec9e2014-03-11 12:55:42 -040011#include <uapi/linux/audit.h> /* for AUDIT_ARCH_* */
Will Drewry1f59d132012-11-15 22:11:29 +010012#include <linux/elf.h> /* for ELF_EM */
Wade Farnsworthbf2c9f92012-04-04 16:19:02 +010013#include <linux/err.h>
Wade Farnsworth8ef102c6b2012-10-02 17:08:30 +010014#include <linux/sched.h>
Wade Farnsworthbf2c9f92012-04-04 16:19:02 +010015
Wade Farnsworth1f66e062012-09-07 18:18:25 +010016#include <asm/unistd.h>
17
18#define NR_syscalls (__NR_syscalls)
19
Wade Farnsworthbf2c9f92012-04-04 16:19:02 +010020extern const unsigned long sys_call_table[];
21
22static inline int syscall_get_nr(struct task_struct *task,
23 struct pt_regs *regs)
24{
25 return task_thread_info(task)->syscall;
26}
27
28static inline void syscall_rollback(struct task_struct *task,
29 struct pt_regs *regs)
30{
31 regs->ARM_r0 = regs->ARM_ORIG_r0;
32}
33
34static inline long syscall_get_error(struct task_struct *task,
35 struct pt_regs *regs)
36{
37 unsigned long error = regs->ARM_r0;
38 return IS_ERR_VALUE(error) ? error : 0;
39}
40
41static inline long syscall_get_return_value(struct task_struct *task,
42 struct pt_regs *regs)
43{
44 return regs->ARM_r0;
45}
46
47static inline void syscall_set_return_value(struct task_struct *task,
48 struct pt_regs *regs,
49 int error, long val)
50{
51 regs->ARM_r0 = (long) error ? error : val;
52}
53
54#define SYSCALL_MAX_ARGS 7
55
56static inline void syscall_get_arguments(struct task_struct *task,
57 struct pt_regs *regs,
Wade Farnsworthbf2c9f92012-04-04 16:19:02 +010058 unsigned long *args)
59{
Steven Rostedt (Red Hat)b35f5492016-11-07 16:26:37 -050060 args[0] = regs->ARM_ORIG_r0;
61 args++;
AKASHI Takahiro3c1532d2013-10-09 15:58:29 +010062
Steven Rostedt (Red Hat)b35f5492016-11-07 16:26:37 -050063 memcpy(args, &regs->ARM_r0 + 1, 5 * sizeof(args[0]));
Wade Farnsworthbf2c9f92012-04-04 16:19:02 +010064}
65
66static inline void syscall_set_arguments(struct task_struct *task,
67 struct pt_regs *regs,
Wade Farnsworthbf2c9f92012-04-04 16:19:02 +010068 const unsigned long *args)
69{
Steven Rostedt (VMware)32d92582019-03-27 20:07:31 -040070 regs->ARM_ORIG_r0 = args[0];
71 args++;
AKASHI Takahiro3c1532d2013-10-09 15:58:29 +010072
Steven Rostedt (VMware)32d92582019-03-27 20:07:31 -040073 memcpy(&regs->ARM_r0 + 1, args, 5 * sizeof(args[0]));
Wade Farnsworthbf2c9f92012-04-04 16:19:02 +010074}
75
Dmitry V. Levin16add412019-03-18 02:30:18 +030076static inline int syscall_get_arch(struct task_struct *task)
Will Drewry1f59d132012-11-15 22:11:29 +010077{
78 /* ARM tasks don't change audit architectures on the fly. */
79 return AUDIT_ARCH_ARM;
80}
81
Wade Farnsworthbf2c9f92012-04-04 16:19:02 +010082#endif /* _ASM_ARM_SYSCALL_H */