hc
2023-12-11 d2ccde1c8e90d38cee87a1b0309ad2827f3fd30d
kernel/arch/arm64/include/asm/syscall.h
....@@ -1,17 +1,6 @@
1
+/* SPDX-License-Identifier: GPL-2.0-only */
12 /*
23 * Copyright (C) 2012 ARM Ltd.
3
- *
4
- * This program is free software; you can redistribute it and/or modify
5
- * it under the terms of the GNU General Public License version 2 as
6
- * published by the Free Software Foundation.
7
- *
8
- * This program is distributed in the hope that it will be useful,
9
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
10
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
- * GNU General Public License for more details.
12
- *
13
- * You should have received a copy of the GNU General Public License
14
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
154 */
165 #ifndef __ASM_SYSCALL_H
176 #define __ASM_SYSCALL_H
....@@ -40,22 +29,23 @@
4029 regs->regs[0] = regs->orig_x0;
4130 }
4231
32
+static inline long syscall_get_return_value(struct task_struct *task,
33
+ struct pt_regs *regs)
34
+{
35
+ unsigned long val = regs->regs[0];
36
+
37
+ if (is_compat_thread(task_thread_info(task)))
38
+ val = sign_extend64(val, 31);
39
+
40
+ return val;
41
+}
4342
4443 static inline long syscall_get_error(struct task_struct *task,
4544 struct pt_regs *regs)
4645 {
47
- unsigned long error = regs->regs[0];
48
-
49
- if (is_compat_thread(task_thread_info(task)))
50
- error = sign_extend64(error, 31);
46
+ unsigned long error = syscall_get_return_value(task, regs);
5147
5248 return IS_ERR_VALUE(error) ? error : 0;
53
-}
54
-
55
-static inline long syscall_get_return_value(struct task_struct *task,
56
- struct pt_regs *regs)
57
-{
58
- return regs->regs[0];
5949 }
6050
6151 static inline void syscall_set_return_value(struct task_struct *task,
....@@ -75,61 +65,31 @@
7565
7666 static inline void syscall_get_arguments(struct task_struct *task,
7767 struct pt_regs *regs,
78
- unsigned int i, unsigned int n,
7968 unsigned long *args)
8069 {
81
- if (n == 0)
82
- return;
70
+ args[0] = regs->orig_x0;
71
+ args++;
8372
84
- if (i + n > SYSCALL_MAX_ARGS) {
85
- unsigned long *args_bad = args + SYSCALL_MAX_ARGS - i;
86
- unsigned int n_bad = n + i - SYSCALL_MAX_ARGS;
87
- pr_warning("%s called with max args %d, handling only %d\n",
88
- __func__, i + n, SYSCALL_MAX_ARGS);
89
- memset(args_bad, 0, n_bad * sizeof(args[0]));
90
- }
91
-
92
- if (i == 0) {
93
- args[0] = regs->orig_x0;
94
- args++;
95
- i++;
96
- n--;
97
- }
98
-
99
- memcpy(args, &regs->regs[i], n * sizeof(args[0]));
73
+ memcpy(args, &regs->regs[1], 5 * sizeof(args[0]));
10074 }
10175
10276 static inline void syscall_set_arguments(struct task_struct *task,
10377 struct pt_regs *regs,
104
- unsigned int i, unsigned int n,
10578 const unsigned long *args)
10679 {
107
- if (n == 0)
108
- return;
80
+ regs->orig_x0 = args[0];
81
+ args++;
10982
110
- if (i + n > SYSCALL_MAX_ARGS) {
111
- pr_warning("%s called with max args %d, handling only %d\n",
112
- __func__, i + n, SYSCALL_MAX_ARGS);
113
- n = SYSCALL_MAX_ARGS - i;
114
- }
115
-
116
- if (i == 0) {
117
- regs->orig_x0 = args[0];
118
- args++;
119
- i++;
120
- n--;
121
- }
122
-
123
- memcpy(&regs->regs[i], args, n * sizeof(args[0]));
83
+ memcpy(&regs->regs[1], args, 5 * sizeof(args[0]));
12484 }
12585
12686 /*
12787 * We don't care about endianness (__AUDIT_ARCH_LE bit) here because
12888 * AArch64 has the same system calls both on little- and big- endian.
12989 */
130
-static inline int syscall_get_arch(void)
90
+static inline int syscall_get_arch(struct task_struct *task)
13191 {
132
- if (is_compat_task())
92
+ if (is_compat_thread(task_thread_info(task)))
13393 return AUDIT_ARCH_ARM;
13494
13595 return AUDIT_ARCH_AARCH64;