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 { 254e57a4ddSArnd Bergmann if (IS_ENABLED(CONFIG_AEABI) && !IS_ENABLED(CONFIG_OABI_COMPAT)) 264e57a4ddSArnd Bergmann return task_thread_info(task)->abi_syscall; 274e57a4ddSArnd Bergmann 284e57a4ddSArnd Bergmann return task_thread_info(task)->abi_syscall & __NR_SYSCALL_MASK; 29bf2c9f98SWade Farnsworth } 30bf2c9f98SWade Farnsworth 31*249dbe74SArnd Bergmann static inline bool __in_oabi_syscall(struct task_struct *task) 32*249dbe74SArnd Bergmann { 33*249dbe74SArnd Bergmann return IS_ENABLED(CONFIG_OABI_COMPAT) && 34*249dbe74SArnd Bergmann (task_thread_info(task)->abi_syscall & __NR_OABI_SYSCALL_BASE); 35*249dbe74SArnd Bergmann } 36*249dbe74SArnd Bergmann 37*249dbe74SArnd Bergmann static inline bool in_oabi_syscall(void) 38*249dbe74SArnd Bergmann { 39*249dbe74SArnd Bergmann return __in_oabi_syscall(current); 40*249dbe74SArnd Bergmann } 41*249dbe74SArnd Bergmann 42bf2c9f98SWade Farnsworth static inline void syscall_rollback(struct task_struct *task, 43bf2c9f98SWade Farnsworth struct pt_regs *regs) 44bf2c9f98SWade Farnsworth { 45bf2c9f98SWade Farnsworth regs->ARM_r0 = regs->ARM_ORIG_r0; 46bf2c9f98SWade Farnsworth } 47bf2c9f98SWade Farnsworth 48bf2c9f98SWade Farnsworth static inline long syscall_get_error(struct task_struct *task, 49bf2c9f98SWade Farnsworth struct pt_regs *regs) 50bf2c9f98SWade Farnsworth { 51bf2c9f98SWade Farnsworth unsigned long error = regs->ARM_r0; 52bf2c9f98SWade Farnsworth return IS_ERR_VALUE(error) ? error : 0; 53bf2c9f98SWade Farnsworth } 54bf2c9f98SWade Farnsworth 55bf2c9f98SWade Farnsworth static inline long syscall_get_return_value(struct task_struct *task, 56bf2c9f98SWade Farnsworth struct pt_regs *regs) 57bf2c9f98SWade Farnsworth { 58bf2c9f98SWade Farnsworth return regs->ARM_r0; 59bf2c9f98SWade Farnsworth } 60bf2c9f98SWade Farnsworth 61bf2c9f98SWade Farnsworth static inline void syscall_set_return_value(struct task_struct *task, 62bf2c9f98SWade Farnsworth struct pt_regs *regs, 63bf2c9f98SWade Farnsworth int error, long val) 64bf2c9f98SWade Farnsworth { 65bf2c9f98SWade Farnsworth regs->ARM_r0 = (long) error ? error : val; 66bf2c9f98SWade Farnsworth } 67bf2c9f98SWade Farnsworth 68bf2c9f98SWade Farnsworth #define SYSCALL_MAX_ARGS 7 69bf2c9f98SWade Farnsworth 70bf2c9f98SWade Farnsworth static inline void syscall_get_arguments(struct task_struct *task, 71bf2c9f98SWade Farnsworth struct pt_regs *regs, 72bf2c9f98SWade Farnsworth unsigned long *args) 73bf2c9f98SWade Farnsworth { 74bf2c9f98SWade Farnsworth args[0] = regs->ARM_ORIG_r0; 75bf2c9f98SWade Farnsworth args++; 76bf2c9f98SWade Farnsworth 77b35f549dSSteven Rostedt (Red Hat) memcpy(args, ®s->ARM_r0 + 1, 5 * sizeof(args[0])); 78bf2c9f98SWade Farnsworth } 79bf2c9f98SWade Farnsworth 80bf2c9f98SWade Farnsworth static inline void syscall_set_arguments(struct task_struct *task, 81bf2c9f98SWade Farnsworth struct pt_regs *regs, 82bf2c9f98SWade Farnsworth const unsigned long *args) 83bf2c9f98SWade Farnsworth { 84bf2c9f98SWade Farnsworth regs->ARM_ORIG_r0 = args[0]; 85bf2c9f98SWade Farnsworth args++; 86bf2c9f98SWade Farnsworth 8732d92586SSteven Rostedt (VMware) memcpy(®s->ARM_r0 + 1, args, 5 * sizeof(args[0])); 88bf2c9f98SWade Farnsworth } 89bf2c9f98SWade Farnsworth 9016add411SDmitry V. Levin static inline int syscall_get_arch(struct task_struct *task) 911f59d13bSWill Drewry { 921f59d13bSWill Drewry /* ARM tasks don't change audit architectures on the fly. */ 931f59d13bSWill Drewry return AUDIT_ARCH_ARM; 941f59d13bSWill Drewry } 951f59d13bSWill Drewry 96bf2c9f98SWade Farnsworth #endif /* _ASM_ARM_SYSCALL_H */ 97