2 * Access to user system call parameters and results
4 * Copyright IBM Corp. 2008
5 * Author(s): Martin Schwidefsky (schwidefsky@de.ibm.com)
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License (version 2 only)
9 * as published by the Free Software Foundation.
12 #ifndef _ASM_SYSCALL_H
13 #define _ASM_SYSCALL_H 1
15 #include <uapi/linux/audit.h>
16 #include <linux/sched.h>
17 #include <linux/err.h>
18 #include <asm/ptrace.h>
21 * The syscall table always contains 32 bit pointers since we know that the
22 * address of the function to be called is (way) below 4GB. So the "int"
23 * type here is what we want [need] for both 32 bit and 64 bit systems.
25 extern const unsigned int sys_call_table[];
26 extern const unsigned int sys_call_table_emu[];
28 static inline long syscall_get_nr(struct task_struct *task,
31 return test_pt_regs_flag(regs, PIF_SYSCALL) ?
32 (regs->int_code & 0xffff) : -1;
35 static inline void syscall_rollback(struct task_struct *task,
38 regs->gprs[2] = regs->orig_gpr2;
41 static inline long syscall_get_error(struct task_struct *task,
44 unsigned long error = regs->gprs[2];
46 if (test_tsk_thread_flag(task, TIF_31BIT)) {
48 * Sign-extend the value so (int)-EFOO becomes (long)-EFOO
49 * and will match correctly in comparisons.
51 error = (long)(int)error;
54 return IS_ERR_VALUE(error) ? error : 0;
57 static inline long syscall_get_return_value(struct task_struct *task,
63 static inline void syscall_set_return_value(struct task_struct *task,
67 regs->gprs[2] = error ? error : val;
70 static inline void syscall_get_arguments(struct task_struct *task,
72 unsigned int i, unsigned int n,
75 unsigned long mask = -1UL;
78 * No arguments for this syscall, there's nothing to do.
85 if (test_tsk_thread_flag(task, TIF_31BIT))
90 args[n] = regs->gprs[2 + i + n] & mask;
92 args[0] = regs->orig_gpr2 & mask;
95 static inline void syscall_set_arguments(struct task_struct *task,
97 unsigned int i, unsigned int n,
98 const unsigned long *args)
103 regs->gprs[2 + i + n] = args[n];
105 regs->orig_gpr2 = args[0];
108 static inline int syscall_get_arch(void)
111 if (test_tsk_thread_flag(current, TIF_31BIT))
112 return AUDIT_ARCH_S390;
114 return AUDIT_ARCH_S390X;
116 #endif /* _ASM_SYSCALL_H */