at v6.19 81 lines 1.7 kB view raw
1/* SPDX-License-Identifier: GPL-2.0 */ 2 3#ifndef __ASM_SYSCALL_H 4#define __ASM_SYSCALL_H 5 6#include <linux/sched.h> 7#include <linux/err.h> 8#include <abi/regdef.h> 9#include <uapi/linux/audit.h> 10 11extern void *sys_call_table[]; 12 13static inline int 14syscall_get_nr(struct task_struct *task, struct pt_regs *regs) 15{ 16 return regs_syscallid(regs); 17} 18 19static inline void 20syscall_set_nr(struct task_struct *task, struct pt_regs *regs, 21 int sysno) 22{ 23 regs_syscallid(regs) = sysno; 24} 25 26static inline void 27syscall_rollback(struct task_struct *task, struct pt_regs *regs) 28{ 29 regs->a0 = regs->orig_a0; 30} 31 32static inline long 33syscall_get_error(struct task_struct *task, struct pt_regs *regs) 34{ 35 unsigned long error = regs->a0; 36 37 return IS_ERR_VALUE(error) ? error : 0; 38} 39 40static inline long 41syscall_get_return_value(struct task_struct *task, struct pt_regs *regs) 42{ 43 return regs->a0; 44} 45 46static inline void 47syscall_set_return_value(struct task_struct *task, struct pt_regs *regs, 48 int error, long val) 49{ 50 regs->a0 = (long) error ?: val; 51} 52 53static inline void 54syscall_get_arguments(struct task_struct *task, struct pt_regs *regs, 55 unsigned long *args) 56{ 57 args[0] = regs->orig_a0; 58 args++; 59 memcpy(args, &regs->a1, 5 * sizeof(args[0])); 60} 61 62static inline void 63syscall_set_arguments(struct task_struct *task, struct pt_regs *regs, 64 const unsigned long *args) 65{ 66 memcpy(&regs->a0, args, 6 * sizeof(regs->a0)); 67 /* 68 * Also copy the first argument into orig_a0 69 * so that syscall_get_arguments() would return it 70 * instead of the previous value. 71 */ 72 regs->orig_a0 = regs->a0; 73} 74 75static inline int 76syscall_get_arch(struct task_struct *task) 77{ 78 return AUDIT_ARCH_CSKY; 79} 80 81#endif /* __ASM_SYSCALL_H */