]> git.ipfire.org Git - thirdparty/kernel/stable.git/blame - arch/s390/include/asm/syscall.h
Merge tag 'clang-format-for-linus-v5.1-rc5' of git://github.com/ojeda/linux
[thirdparty/kernel/stable.git] / arch / s390 / include / asm / syscall.h
CommitLineData
0b73214f 1/* SPDX-License-Identifier: GPL-2.0 */
753c4dd6
MS
2/*
3 * Access to user system call parameters and results
4 *
5 * Copyright IBM Corp. 2008
6 * Author(s): Martin Schwidefsky (schwidefsky@de.ibm.com)
753c4dd6
MS
7 */
8
9#ifndef _ASM_SYSCALL_H
10#define _ASM_SYSCALL_H 1
11
579ec9e1 12#include <uapi/linux/audit.h>
9bf1226b 13#include <linux/sched.h>
20b40a79 14#include <linux/err.h>
753c4dd6
MS
15#include <asm/ptrace.h>
16
e7b8e675
MF
17/*
18 * The syscall table always contains 32 bit pointers since we know that the
19 * address of the function to be called is (way) below 4GB. So the "int"
20 * type here is what we want [need] for both 32 bit and 64 bit systems.
21 */
22extern const unsigned int sys_call_table[];
61649881 23extern const unsigned int sys_call_table_emu[];
e7b8e675 24
753c4dd6
MS
25static inline long syscall_get_nr(struct task_struct *task,
26 struct pt_regs *regs)
27{
d3a73acb 28 return test_pt_regs_flag(regs, PIF_SYSCALL) ?
aa33c8cb 29 (regs->int_code & 0xffff) : -1;
753c4dd6
MS
30}
31
32static inline void syscall_rollback(struct task_struct *task,
33 struct pt_regs *regs)
34{
35 regs->gprs[2] = regs->orig_gpr2;
36}
37
38static inline long syscall_get_error(struct task_struct *task,
39 struct pt_regs *regs)
40{
20b40a79 41 return IS_ERR_VALUE(regs->gprs[2]) ? regs->gprs[2] : 0;
753c4dd6
MS
42}
43
44static inline long syscall_get_return_value(struct task_struct *task,
45 struct pt_regs *regs)
46{
47 return regs->gprs[2];
48}
49
50static inline void syscall_set_return_value(struct task_struct *task,
51 struct pt_regs *regs,
52 int error, long val)
53{
dc295880 54 regs->gprs[2] = error ? error : val;
753c4dd6
MS
55}
56
57static inline void syscall_get_arguments(struct task_struct *task,
58 struct pt_regs *regs,
753c4dd6
MS
59 unsigned long *args)
60{
59da2139 61 unsigned long mask = -1UL;
b35f549d 62 unsigned int n = 6;
59da2139 63
753c4dd6 64#ifdef CONFIG_COMPAT
59da2139
MS
65 if (test_tsk_thread_flag(task, TIF_31BIT))
66 mask = 0xffffffff;
753c4dd6 67#endif
59da2139 68 while (n-- > 0)
b35f549d
SRRH
69 if (n > 0)
70 args[n] = regs->gprs[2 + n] & mask;
71
72 args[0] = regs->orig_gpr2 & mask;
753c4dd6
MS
73}
74
75static inline void syscall_set_arguments(struct task_struct *task,
76 struct pt_regs *regs,
753c4dd6
MS
77 const unsigned long *args)
78{
32d92586
SRV
79 unsigned int n = 6;
80
59da2139 81 while (n-- > 0)
32d92586
SRV
82 if (n > 0)
83 regs->gprs[2 + n] = args[n];
84 regs->orig_gpr2 = args[0];
753c4dd6
MS
85}
86
5e937a9a 87static inline int syscall_get_arch(void)
c63cb468
HC
88{
89#ifdef CONFIG_COMPAT
5e937a9a 90 if (test_tsk_thread_flag(current, TIF_31BIT))
c63cb468
HC
91 return AUDIT_ARCH_S390;
92#endif
1a327ffd 93 return AUDIT_ARCH_S390X;
c63cb468 94}
753c4dd6 95#endif /* _ASM_SYSCALL_H */