]> git.ipfire.org Git - thirdparty/kernel/stable.git/blame - arch/s390/include/asm/syscall.h
s390: appldata: add SPDX identifiers to the remaining files
[thirdparty/kernel/stable.git] / arch / s390 / include / asm / syscall.h
CommitLineData
753c4dd6
MS
1/*
2 * Access to user system call parameters and results
3 *
4 * Copyright IBM Corp. 2008
5 * Author(s): Martin Schwidefsky (schwidefsky@de.ibm.com)
6 *
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.
10 */
11
12#ifndef _ASM_SYSCALL_H
13#define _ASM_SYSCALL_H 1
14
579ec9e1 15#include <uapi/linux/audit.h>
9bf1226b 16#include <linux/sched.h>
20b40a79 17#include <linux/err.h>
753c4dd6
MS
18#include <asm/ptrace.h>
19
e7b8e675
MF
20/*
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.
24 */
25extern const unsigned int sys_call_table[];
61649881 26extern const unsigned int sys_call_table_emu[];
e7b8e675 27
753c4dd6
MS
28static inline long syscall_get_nr(struct task_struct *task,
29 struct pt_regs *regs)
30{
d3a73acb 31 return test_pt_regs_flag(regs, PIF_SYSCALL) ?
aa33c8cb 32 (regs->int_code & 0xffff) : -1;
753c4dd6
MS
33}
34
35static inline void syscall_rollback(struct task_struct *task,
36 struct pt_regs *regs)
37{
38 regs->gprs[2] = regs->orig_gpr2;
39}
40
41static inline long syscall_get_error(struct task_struct *task,
42 struct pt_regs *regs)
43{
20b40a79 44 return IS_ERR_VALUE(regs->gprs[2]) ? regs->gprs[2] : 0;
753c4dd6
MS
45}
46
47static inline long syscall_get_return_value(struct task_struct *task,
48 struct pt_regs *regs)
49{
50 return regs->gprs[2];
51}
52
53static inline void syscall_set_return_value(struct task_struct *task,
54 struct pt_regs *regs,
55 int error, long val)
56{
dc295880 57 regs->gprs[2] = error ? error : val;
753c4dd6
MS
58}
59
60static inline void syscall_get_arguments(struct task_struct *task,
61 struct pt_regs *regs,
62 unsigned int i, unsigned int n,
63 unsigned long *args)
64{
59da2139
MS
65 unsigned long mask = -1UL;
66
c46fc042
JO
67 /*
68 * No arguments for this syscall, there's nothing to do.
69 */
70 if (!n)
71 return;
72
753c4dd6
MS
73 BUG_ON(i + n > 6);
74#ifdef CONFIG_COMPAT
59da2139
MS
75 if (test_tsk_thread_flag(task, TIF_31BIT))
76 mask = 0xffffffff;
753c4dd6 77#endif
59da2139
MS
78 while (n-- > 0)
79 if (i + n > 0)
80 args[n] = regs->gprs[2 + i + n] & mask;
81 if (i == 0)
82 args[0] = regs->orig_gpr2 & mask;
753c4dd6
MS
83}
84
85static inline void syscall_set_arguments(struct task_struct *task,
86 struct pt_regs *regs,
87 unsigned int i, unsigned int n,
88 const unsigned long *args)
89{
90 BUG_ON(i + n > 6);
59da2139
MS
91 while (n-- > 0)
92 if (i + n > 0)
93 regs->gprs[2 + i + n] = args[n];
94 if (i == 0)
95 regs->orig_gpr2 = args[0];
753c4dd6
MS
96}
97
5e937a9a 98static inline int syscall_get_arch(void)
c63cb468
HC
99{
100#ifdef CONFIG_COMPAT
5e937a9a 101 if (test_tsk_thread_flag(current, TIF_31BIT))
c63cb468
HC
102 return AUDIT_ARCH_S390;
103#endif
1a327ffd 104 return AUDIT_ARCH_S390X;
c63cb468 105}
753c4dd6 106#endif /* _ASM_SYSCALL_H */