1 /* SPDX-License-Identifier: GPL-2.0 */
3 * Access to user system call parameters and results
5 * Copyright IBM Corp. 2008
10 #define _ASM_SYSCALL_H 1
12 #include <uapi/linux/audit.h>
13 #include <linux/sched.h>
14 #include <linux/err.h>
15 #include <asm/ptrace.h>
17 extern const unsigned long sys_call_table[];
18 extern const unsigned long sys_call_table_emu[];
20 static inline long syscall_get_nr(struct task_struct *task,
23 return test_pt_regs_flag(regs, PIF_SYSCALL) ?
24 (regs->int_code & 0xffff) : -1;
27 static inline void syscall_rollback(struct task_struct *task,
30 regs->gprs[2] = regs->orig_gpr2;
33 static inline long syscall_get_error(struct task_struct *task,
36 unsigned long error = regs->gprs[2];
38 if (test_tsk_thread_flag(task, TIF_31BIT)) {
40 * Sign-extend the value so (int)-EFOO becomes (long)-EFOO
41 * and will match correctly in comparisons.
43 error = (long)(int)error;
46 return IS_ERR_VALUE(error) ? error : 0;
49 static inline long syscall_get_return_value(struct task_struct *task,
55 static inline void syscall_set_return_value(struct task_struct *task,
59 regs->gprs[2] = error ? error : val;
62 static inline void syscall_get_arguments(struct task_struct *task,
66 unsigned long mask = -1UL;
70 if (test_tsk_thread_flag(task, TIF_31BIT))
75 args[n] = regs->gprs[2 + n] & mask;
77 args[0] = regs->orig_gpr2 & mask;
80 static inline void syscall_set_arguments(struct task_struct *task,
82 const unsigned long *args)
88 regs->gprs[2 + n] = args[n];
89 regs->orig_gpr2 = args[0];
92 static inline int syscall_get_arch(struct task_struct *task)
95 if (test_tsk_thread_flag(task, TIF_31BIT))
96 return AUDIT_ARCH_S390;
98 return AUDIT_ARCH_S390X;
100 #endif /* _ASM_SYSCALL_H */