1b2441318SGreg Kroah-Hartman /* SPDX-License-Identifier: GPL-2.0 */ 2bf2c9f98SWade Farnsworth /* 3bf2c9f98SWade Farnsworth * Access to user system call parameters and results 4bf2c9f98SWade Farnsworth * 5bf2c9f98SWade Farnsworth * See asm-generic/syscall.h for descriptions of what we must do here. 6bf2c9f98SWade Farnsworth */ 7bf2c9f98SWade Farnsworth 8bf2c9f98SWade Farnsworth #ifndef _ASM_ARM_SYSCALL_H 9bf2c9f98SWade Farnsworth #define _ASM_ARM_SYSCALL_H 10bf2c9f98SWade Farnsworth 11579ec9e1SEric Paris #include <uapi/linux/audit.h> /* for AUDIT_ARCH_* */ 121f59d13bSWill Drewry #include <linux/elf.h> /* for ELF_EM */ 13bf2c9f98SWade Farnsworth #include <linux/err.h> 148ef102c6SWade Farnsworth #include <linux/sched.h> 15bf2c9f98SWade Farnsworth 161f66e06fSWade Farnsworth #include <asm/unistd.h> 171f66e06fSWade Farnsworth 181f66e06fSWade Farnsworth #define NR_syscalls (__NR_syscalls) 191f66e06fSWade Farnsworth 20bf2c9f98SWade Farnsworth extern const unsigned long sys_call_table[]; 21bf2c9f98SWade Farnsworth 22bf2c9f98SWade Farnsworth static inline int syscall_get_nr(struct task_struct *task, 23bf2c9f98SWade Farnsworth struct pt_regs *regs) 24bf2c9f98SWade Farnsworth { 25bf2c9f98SWade Farnsworth return task_thread_info(task)->syscall; 26bf2c9f98SWade Farnsworth } 27bf2c9f98SWade Farnsworth 28bf2c9f98SWade Farnsworth static inline void syscall_rollback(struct task_struct *task, 29bf2c9f98SWade Farnsworth struct pt_regs *regs) 30bf2c9f98SWade Farnsworth { 31bf2c9f98SWade Farnsworth regs->ARM_r0 = regs->ARM_ORIG_r0; 32bf2c9f98SWade Farnsworth } 33bf2c9f98SWade Farnsworth 34bf2c9f98SWade Farnsworth static inline long syscall_get_error(struct task_struct *task, 35bf2c9f98SWade Farnsworth struct pt_regs *regs) 36bf2c9f98SWade Farnsworth { 37bf2c9f98SWade Farnsworth unsigned long error = regs->ARM_r0; 38bf2c9f98SWade Farnsworth return IS_ERR_VALUE(error) ? error : 0; 39bf2c9f98SWade Farnsworth } 40bf2c9f98SWade Farnsworth 41bf2c9f98SWade Farnsworth static inline long syscall_get_return_value(struct task_struct *task, 42bf2c9f98SWade Farnsworth struct pt_regs *regs) 43bf2c9f98SWade Farnsworth { 44bf2c9f98SWade Farnsworth return regs->ARM_r0; 45bf2c9f98SWade Farnsworth } 46bf2c9f98SWade Farnsworth 47bf2c9f98SWade Farnsworth static inline void syscall_set_return_value(struct task_struct *task, 48bf2c9f98SWade Farnsworth struct pt_regs *regs, 49bf2c9f98SWade Farnsworth int error, long val) 50bf2c9f98SWade Farnsworth { 51bf2c9f98SWade Farnsworth regs->ARM_r0 = (long) error ? error : val; 52bf2c9f98SWade Farnsworth } 53bf2c9f98SWade Farnsworth 54bf2c9f98SWade Farnsworth #define SYSCALL_MAX_ARGS 7 55bf2c9f98SWade Farnsworth 56bf2c9f98SWade Farnsworth static inline void syscall_get_arguments(struct task_struct *task, 57bf2c9f98SWade Farnsworth struct pt_regs *regs, 58bf2c9f98SWade Farnsworth unsigned long *args) 59bf2c9f98SWade Farnsworth { 60bf2c9f98SWade Farnsworth args[0] = regs->ARM_ORIG_r0; 61bf2c9f98SWade Farnsworth args++; 62bf2c9f98SWade Farnsworth 63b35f549dSSteven Rostedt (Red Hat) memcpy(args, ®s->ARM_r0 + 1, 5 * sizeof(args[0])); 64bf2c9f98SWade Farnsworth } 65bf2c9f98SWade Farnsworth 66bf2c9f98SWade Farnsworth static inline void syscall_set_arguments(struct task_struct *task, 67bf2c9f98SWade Farnsworth struct pt_regs *regs, 68bf2c9f98SWade Farnsworth const unsigned long *args) 69bf2c9f98SWade Farnsworth { 70bf2c9f98SWade Farnsworth regs->ARM_ORIG_r0 = args[0]; 71bf2c9f98SWade Farnsworth args++; 72bf2c9f98SWade Farnsworth 7332d92586SSteven Rostedt (VMware) memcpy(®s->ARM_r0 + 1, args, 5 * sizeof(args[0])); 74bf2c9f98SWade Farnsworth } 75bf2c9f98SWade Farnsworth 765e937a9aSEric Paris static inline int syscall_get_arch(void) 771f59d13bSWill Drewry { 781f59d13bSWill Drewry /* ARM tasks don't change audit architectures on the fly. */ 791f59d13bSWill Drewry return AUDIT_ARCH_ARM; 801f59d13bSWill Drewry } 811f59d13bSWill Drewry 82bf2c9f98SWade Farnsworth #endif /* _ASM_ARM_SYSCALL_H */ 83