aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteven Rostedt (VMware) <rostedt@goodmis.org>2019-03-27 20:07:31 -0400
committerSteven Rostedt (VMware) <rostedt@goodmis.org>2019-04-05 09:27:23 -0400
commit32d92586629a8b3637a3c9361709818e25f327ad (patch)
treeb04235048595f3292ceba737d0d8b9b161b10730
parentb35f549df1d7520d37ba1e6d4a8d4df6bd52d136 (diff)
syscalls: Remove start and number from syscall_set_arguments() args
After removing the start and count arguments of syscall_get_arguments() it seems reasonable to remove them from syscall_set_arguments(). Note, as of today, there are no users of syscall_set_arguments(). But we are told that there will be soon. But for now, at least make it consistent with syscall_get_arguments(). Link: http://lkml.kernel.org/r/20190327222014.GA32540@altlinux.org Cc: Oleg Nesterov <oleg@redhat.com> Cc: Kees Cook <keescook@chromium.org> Cc: Andy Lutomirski <luto@amacapital.net> Cc: Dominik Brodowski <linux@dominikbrodowski.net> Cc: Dave Martin <dave.martin@arm.com> Cc: "Dmitry V. Levin" <ldv@altlinux.org> Cc: x86@kernel.org Cc: linux-snps-arc@lists.infradead.org Cc: linux-kernel@vger.kernel.org Cc: linux-arm-kernel@lists.infradead.org Cc: linux-c6x-dev@linux-c6x.org Cc: uclinux-h8-devel@lists.sourceforge.jp Cc: linux-hexagon@vger.kernel.org Cc: linux-ia64@vger.kernel.org Cc: linux-mips@vger.kernel.org Cc: nios2-dev@lists.rocketboards.org Cc: openrisc@lists.librecores.org Cc: linux-parisc@vger.kernel.org Cc: linuxppc-dev@lists.ozlabs.org Cc: linux-riscv@lists.infradead.org Cc: linux-s390@vger.kernel.org Cc: linux-sh@vger.kernel.org Cc: sparclinux@vger.kernel.org Cc: linux-um@lists.infradead.org Cc: linux-xtensa@linux-xtensa.org Cc: linux-arch@vger.kernel.org Acked-by: Max Filippov <jcmvbkbc@gmail.com> # For xtensa changes Acked-by: Will Deacon <will.deacon@arm.com> # For the arm64 bits Reviewed-by: Thomas Gleixner <tglx@linutronix.de> # for x86 Reviewed-by: Dmitry V. Levin <ldv@altlinux.org> Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
-rw-r--r--arch/arm/include/asm/syscall.h22
-rw-r--r--arch/arm64/include/asm/syscall.h22
-rw-r--r--arch/c6x/include/asm/syscall.h38
-rw-r--r--arch/csky/include/asm/syscall.h14
-rw-r--r--arch/ia64/include/asm/syscall.h10
-rw-r--r--arch/ia64/kernel/ptrace.c7
-rw-r--r--arch/microblaze/include/asm/syscall.h4
-rw-r--r--arch/nds32/include/asm/syscall.h29
-rw-r--r--arch/nios2/include/asm/syscall.h42
-rw-r--r--arch/openrisc/include/asm/syscall.h6
-rw-r--r--arch/powerpc/include/asm/syscall.h7
-rw-r--r--arch/riscv/include/asm/syscall.h13
-rw-r--r--arch/s390/include/asm/syscall.h11
-rw-r--r--arch/sh/include/asm/syscall_32.h21
-rw-r--r--arch/sh/include/asm/syscall_64.h4
-rw-r--r--arch/sparc/include/asm/syscall.h7
-rw-r--r--arch/um/include/asm/syscall-generic.h39
-rw-r--r--arch/x86/include/asm/syscall.h69
-rw-r--r--arch/xtensa/include/asm/syscall.h17
-rw-r--r--include/asm-generic/syscall.h10
20 files changed, 88 insertions, 304 deletions
diff --git a/arch/arm/include/asm/syscall.h b/arch/arm/include/asm/syscall.h
index db969a2972ae..080ce70cab12 100644
--- a/arch/arm/include/asm/syscall.h
+++ b/arch/arm/include/asm/syscall.h
@@ -65,26 +65,12 @@ static inline void syscall_get_arguments(struct task_struct *task,
65 65
66static inline void syscall_set_arguments(struct task_struct *task, 66static inline void syscall_set_arguments(struct task_struct *task,
67 struct pt_regs *regs, 67 struct pt_regs *regs,
68 unsigned int i, unsigned int n,
69 const unsigned long *args) 68 const unsigned long *args)
70{ 69{
71 if (n == 0) 70 regs->ARM_ORIG_r0 = args[0];
72 return; 71 args++;
73 72
74 if (i + n > SYSCALL_MAX_ARGS) { 73 memcpy(&regs->ARM_r0 + 1, args, 5 * sizeof(args[0]));
75 pr_warn("%s called with max args %d, handling only %d\n",
76 __func__, i + n, SYSCALL_MAX_ARGS);
77 n = SYSCALL_MAX_ARGS - i;
78 }
79
80 if (i == 0) {
81 regs->ARM_ORIG_r0 = args[0];
82 args++;
83 i++;
84 n--;
85 }
86
87 memcpy(&regs->ARM_r0 + i, args, n * sizeof(args[0]));
88} 74}
89 75
90static inline int syscall_get_arch(void) 76static inline int syscall_get_arch(void)
diff --git a/arch/arm64/include/asm/syscall.h b/arch/arm64/include/asm/syscall.h
index 55b2dab21023..a179df3674a1 100644
--- a/arch/arm64/include/asm/syscall.h
+++ b/arch/arm64/include/asm/syscall.h
@@ -75,26 +75,12 @@ static inline void syscall_get_arguments(struct task_struct *task,
75 75
76static inline void syscall_set_arguments(struct task_struct *task, 76static inline void syscall_set_arguments(struct task_struct *task,
77 struct pt_regs *regs, 77 struct pt_regs *regs,
78 unsigned int i, unsigned int n,
79 const unsigned long *args) 78 const unsigned long *args)
80{ 79{
81 if (n == 0) 80 regs->orig_x0 = args[0];
82 return; 81 args++;
83 82
84 if (i + n > SYSCALL_MAX_ARGS) { 83 memcpy(&regs->regs[1], args, 5 * sizeof(args[0]));
85 pr_warning("%s called with max args %d, handling only %d\n",
86 __func__, i + n, SYSCALL_MAX_ARGS);
87 n = SYSCALL_MAX_ARGS - i;
88 }
89
90 if (i == 0) {
91 regs->orig_x0 = args[0];
92 args++;
93 i++;
94 n--;
95 }
96
97 memcpy(&regs->regs[i], args, n * sizeof(args[0]));
98} 84}
99 85
100/* 86/*
diff --git a/arch/c6x/include/asm/syscall.h b/arch/c6x/include/asm/syscall.h
index 06db3251926b..15ba8599858e 100644
--- a/arch/c6x/include/asm/syscall.h
+++ b/arch/c6x/include/asm/syscall.h
@@ -59,40 +59,14 @@ static inline void syscall_get_arguments(struct task_struct *task,
59 59
60static inline void syscall_set_arguments(struct task_struct *task, 60static inline void syscall_set_arguments(struct task_struct *task,
61 struct pt_regs *regs, 61 struct pt_regs *regs,
62 unsigned int i, unsigned int n,
63 const unsigned long *args) 62 const unsigned long *args)
64{ 63{
65 switch (i) { 64 regs->a4 = *args++;
66 case 0: 65 regs->b4 = *args++;
67 if (!n--) 66 regs->a6 = *args++;
68 break; 67 regs->b6 = *args++;
69 regs->a4 = *args++; 68 regs->a8 = *args++;
70 case 1: 69 regs->a9 = *args;
71 if (!n--)
72 break;
73 regs->b4 = *args++;
74 case 2:
75 if (!n--)
76 break;
77 regs->a6 = *args++;
78 case 3:
79 if (!n--)
80 break;
81 regs->b6 = *args++;
82 case 4:
83 if (!n--)
84 break;
85 regs->a8 = *args++;
86 case 5:
87 if (!n--)
88 break;
89 regs->a9 = *args++;
90 case 6:
91 if (!n)
92 break;
93 default:
94 BUG();
95 }
96} 70}
97 71
98#endif /* __ASM_C6X_SYSCALLS_H */ 72#endif /* __ASM_C6X_SYSCALLS_H */
diff --git a/arch/csky/include/asm/syscall.h b/arch/csky/include/asm/syscall.h
index c691fe92edc6..bda0a446c63e 100644
--- a/arch/csky/include/asm/syscall.h
+++ b/arch/csky/include/asm/syscall.h
@@ -52,17 +52,11 @@ syscall_get_arguments(struct task_struct *task, struct pt_regs *regs,
52 52
53static inline void 53static inline void
54syscall_set_arguments(struct task_struct *task, struct pt_regs *regs, 54syscall_set_arguments(struct task_struct *task, struct pt_regs *regs,
55 unsigned int i, unsigned int n, const unsigned long *args) 55 const unsigned long *args)
56{ 56{
57 BUG_ON(i + n > 6); 57 regs->orig_a0 = args[0];
58 if (i == 0) { 58 args++;
59 regs->orig_a0 = args[0]; 59 memcpy(&regs->a1, args, 5 * sizeof(regs->a1));
60 args++;
61 n--;
62 } else {
63 i--;
64 }
65 memcpy(&regs->a1 + i, args, n * sizeof(regs->a1));
66} 60}
67 61
68static inline int 62static inline int
diff --git a/arch/ia64/include/asm/syscall.h b/arch/ia64/include/asm/syscall.h
index 8204c1ff70ce..0d9e7fab4a79 100644
--- a/arch/ia64/include/asm/syscall.h
+++ b/arch/ia64/include/asm/syscall.h
@@ -59,23 +59,19 @@ static inline void syscall_set_return_value(struct task_struct *task,
59} 59}
60 60
61extern void ia64_syscall_get_set_arguments(struct task_struct *task, 61extern void ia64_syscall_get_set_arguments(struct task_struct *task,
62 struct pt_regs *regs, unsigned int i, unsigned int n, 62 struct pt_regs *regs, unsigned long *args, int rw);
63 unsigned long *args, int rw);
64static inline void syscall_get_arguments(struct task_struct *task, 63static inline void syscall_get_arguments(struct task_struct *task,
65 struct pt_regs *regs, 64 struct pt_regs *regs,
66 unsigned long *args) 65 unsigned long *args)
67{ 66{
68 ia64_syscall_get_set_arguments(task, regs, 0, 6, args, 0); 67 ia64_syscall_get_set_arguments(task, regs, args, 0);
69} 68}
70 69
71static inline void syscall_set_arguments(struct task_struct *task, 70static inline void syscall_set_arguments(struct task_struct *task,
72 struct pt_regs *regs, 71 struct pt_regs *regs,
73 unsigned int i, unsigned int n,
74 unsigned long *args) 72 unsigned long *args)
75{ 73{
76 BUG_ON(i + n > 6); 74 ia64_syscall_get_set_arguments(task, regs, args, 1);
77
78 ia64_syscall_get_set_arguments(task, regs, i, n, args, 1);
79} 75}
80 76
81static inline int syscall_get_arch(void) 77static inline int syscall_get_arch(void)
diff --git a/arch/ia64/kernel/ptrace.c b/arch/ia64/kernel/ptrace.c
index 6d50ede0ed69..bf9c24d9ce84 100644
--- a/arch/ia64/kernel/ptrace.c
+++ b/arch/ia64/kernel/ptrace.c
@@ -2179,12 +2179,11 @@ static void syscall_get_set_args_cb(struct unw_frame_info *info, void *data)
2179} 2179}
2180 2180
2181void ia64_syscall_get_set_arguments(struct task_struct *task, 2181void ia64_syscall_get_set_arguments(struct task_struct *task,
2182 struct pt_regs *regs, unsigned int i, unsigned int n, 2182 struct pt_regs *regs, unsigned long *args, int rw)
2183 unsigned long *args, int rw)
2184{ 2183{
2185 struct syscall_get_set_args data = { 2184 struct syscall_get_set_args data = {
2186 .i = i, 2185 .i = 0,
2187 .n = n, 2186 .n = 6,
2188 .args = args, 2187 .args = args,
2189 .regs = regs, 2188 .regs = regs,
2190 .rw = rw, 2189 .rw = rw,
diff --git a/arch/microblaze/include/asm/syscall.h b/arch/microblaze/include/asm/syscall.h
index 4b23e44e5c3c..833d3a53dab3 100644
--- a/arch/microblaze/include/asm/syscall.h
+++ b/arch/microblaze/include/asm/syscall.h
@@ -93,9 +93,11 @@ static inline void syscall_get_arguments(struct task_struct *task,
93 93
94static inline void syscall_set_arguments(struct task_struct *task, 94static inline void syscall_set_arguments(struct task_struct *task,
95 struct pt_regs *regs, 95 struct pt_regs *regs,
96 unsigned int i, unsigned int n,
97 const unsigned long *args) 96 const unsigned long *args)
98{ 97{
98 unsigned int i = 0;
99 unsigned int n = 6;
100
99 while (n--) 101 while (n--)
100 microblaze_set_syscall_arg(regs, i++, *args++); 102 microblaze_set_syscall_arg(regs, i++, *args++);
101} 103}
diff --git a/arch/nds32/include/asm/syscall.h b/arch/nds32/include/asm/syscall.h
index 89a6ec8731d8..671ebd357496 100644
--- a/arch/nds32/include/asm/syscall.h
+++ b/arch/nds32/include/asm/syscall.h
@@ -129,39 +129,20 @@ void syscall_get_arguments(struct task_struct *task, struct pt_regs *regs,
129 * syscall_set_arguments - change system call parameter value 129 * syscall_set_arguments - change system call parameter value
130 * @task: task of interest, must be in system call entry tracing 130 * @task: task of interest, must be in system call entry tracing
131 * @regs: task_pt_regs() of @task 131 * @regs: task_pt_regs() of @task
132 * @i: argument index [0,5]
133 * @n: number of arguments; n+i must be [1,6].
134 * @args: array of argument values to store 132 * @args: array of argument values to store
135 * 133 *
136 * Changes @n arguments to the system call starting with the @i'th argument. 134 * Changes 6 arguments to the system call. The first argument gets value
137 * Argument @i gets value @args[0], and so on. 135 * @args[0], and so on.
138 * An arch inline version is probably optimal when @i and @n are constants.
139 * 136 *
140 * It's only valid to call this when @task is stopped for tracing on 137 * It's only valid to call this when @task is stopped for tracing on
141 * entry to a system call, due to %TIF_SYSCALL_TRACE or %TIF_SYSCALL_AUDIT. 138 * entry to a system call, due to %TIF_SYSCALL_TRACE or %TIF_SYSCALL_AUDIT.
142 * It's invalid to call this with @i + @n > 6; we only support system calls
143 * taking up to 6 arguments.
144 */ 139 */
145void syscall_set_arguments(struct task_struct *task, struct pt_regs *regs, 140void syscall_set_arguments(struct task_struct *task, struct pt_regs *regs,
146 unsigned int i, unsigned int n,
147 const unsigned long *args) 141 const unsigned long *args)
148{ 142{
149 if (n == 0) 143 regs->orig_r0 = args[0];
150 return; 144 args++;
151
152 if (i + n > SYSCALL_MAX_ARGS) {
153 pr_warn("%s called with max args %d, handling only %d\n",
154 __func__, i + n, SYSCALL_MAX_ARGS);
155 n = SYSCALL_MAX_ARGS - i;
156 }
157
158 if (i == 0) {
159 regs->orig_r0 = args[0];
160 args++;
161 i++;
162 n--;
163 }
164 145
165 memcpy(&regs->uregs[0] + i, args, n * sizeof(args[0])); 146 memcpy(&regs->uregs[0] + 1, args, 5 * sizeof(args[0]));
166} 147}
167#endif /* _ASM_NDS32_SYSCALL_H */ 148#endif /* _ASM_NDS32_SYSCALL_H */
diff --git a/arch/nios2/include/asm/syscall.h b/arch/nios2/include/asm/syscall.h
index 792bd449d839..d7624ed06efb 100644
--- a/arch/nios2/include/asm/syscall.h
+++ b/arch/nios2/include/asm/syscall.h
@@ -69,42 +69,14 @@ static inline void syscall_get_arguments(struct task_struct *task,
69} 69}
70 70
71static inline void syscall_set_arguments(struct task_struct *task, 71static inline void syscall_set_arguments(struct task_struct *task,
72 struct pt_regs *regs, unsigned int i, unsigned int n, 72 struct pt_regs *regs, const unsigned long *args)
73 const unsigned long *args)
74{ 73{
75 BUG_ON(i + n > 6); 74 regs->r4 = *args++;
76 75 regs->r5 = *args++;
77 switch (i) { 76 regs->r6 = *args++;
78 case 0: 77 regs->r7 = *args++;
79 if (!n--) 78 regs->r8 = *args++;
80 break; 79 regs->r9 = *args;
81 regs->r4 = *args++;
82 case 1:
83 if (!n--)
84 break;
85 regs->r5 = *args++;
86 case 2:
87 if (!n--)
88 break;
89 regs->r6 = *args++;
90 case 3:
91 if (!n--)
92 break;
93 regs->r7 = *args++;
94 case 4:
95 if (!n--)
96 break;
97 regs->r8 = *args++;
98 case 5:
99 if (!n--)
100 break;
101 regs->r9 = *args++;
102 case 6:
103 if (!n)
104 break;
105 default:
106 BUG();
107 }
108} 80}
109 81
110#endif 82#endif
diff --git a/arch/openrisc/include/asm/syscall.h b/arch/openrisc/include/asm/syscall.h
index 72607860cd55..b4ff07c1baed 100644
--- a/arch/openrisc/include/asm/syscall.h
+++ b/arch/openrisc/include/asm/syscall.h
@@ -63,11 +63,9 @@ syscall_get_arguments(struct task_struct *task, struct pt_regs *regs,
63 63
64static inline void 64static inline void
65syscall_set_arguments(struct task_struct *task, struct pt_regs *regs, 65syscall_set_arguments(struct task_struct *task, struct pt_regs *regs,
66 unsigned int i, unsigned int n, const unsigned long *args) 66 const unsigned long *args)
67{ 67{
68 BUG_ON(i + n > 6); 68 memcpy(&regs->gpr[3], args, 6 * sizeof(args[0]));
69
70 memcpy(&regs->gpr[3 + i], args, n * sizeof(args[0]));
71} 69}
72 70
73static inline int syscall_get_arch(void) 71static inline int syscall_get_arch(void)
diff --git a/arch/powerpc/include/asm/syscall.h b/arch/powerpc/include/asm/syscall.h
index 5c9b9dc82b7e..1243045bad2d 100644
--- a/arch/powerpc/include/asm/syscall.h
+++ b/arch/powerpc/include/asm/syscall.h
@@ -86,15 +86,12 @@ static inline void syscall_get_arguments(struct task_struct *task,
86 86
87static inline void syscall_set_arguments(struct task_struct *task, 87static inline void syscall_set_arguments(struct task_struct *task,
88 struct pt_regs *regs, 88 struct pt_regs *regs,
89 unsigned int i, unsigned int n,
90 const unsigned long *args) 89 const unsigned long *args)
91{ 90{
92 BUG_ON(i + n > 6); 91 memcpy(&regs->gpr[3], args, 6 * sizeof(args[0]));
93 memcpy(&regs->gpr[3 + i], args, n * sizeof(args[0]));
94 92
95 /* Also copy the first argument into orig_gpr3 */ 93 /* Also copy the first argument into orig_gpr3 */
96 if (i == 0 && n > 0) 94 regs->orig_gpr3 = args[0];
97 regs->orig_gpr3 = args[0];
98} 95}
99 96
100static inline int syscall_get_arch(void) 97static inline int syscall_get_arch(void)
diff --git a/arch/riscv/include/asm/syscall.h b/arch/riscv/include/asm/syscall.h
index 6adca1804be1..a3d5273ded7c 100644
--- a/arch/riscv/include/asm/syscall.h
+++ b/arch/riscv/include/asm/syscall.h
@@ -81,18 +81,11 @@ static inline void syscall_get_arguments(struct task_struct *task,
81 81
82static inline void syscall_set_arguments(struct task_struct *task, 82static inline void syscall_set_arguments(struct task_struct *task,
83 struct pt_regs *regs, 83 struct pt_regs *regs,
84 unsigned int i, unsigned int n,
85 const unsigned long *args) 84 const unsigned long *args)
86{ 85{
87 BUG_ON(i + n > 6); 86 regs->orig_a0 = args[0];
88 if (i == 0) { 87 args++;
89 regs->orig_a0 = args[0]; 88 memcpy(&regs->a1, args, 5 * sizeof(regs->a1));
90 args++;
91 n--;
92 } else {
93 i--;
94 }
95 memcpy(&regs->a1 + i, args, n * sizeof(regs->a1));
96} 89}
97 90
98static inline int syscall_get_arch(void) 91static inline int syscall_get_arch(void)
diff --git a/arch/s390/include/asm/syscall.h b/arch/s390/include/asm/syscall.h
index ee0b1f6aa36d..59c3e91f2cdb 100644
--- a/arch/s390/include/asm/syscall.h
+++ b/arch/s390/include/asm/syscall.h
@@ -74,15 +74,14 @@ static inline void syscall_get_arguments(struct task_struct *task,
74 74
75static inline void syscall_set_arguments(struct task_struct *task, 75static inline void syscall_set_arguments(struct task_struct *task,
76 struct pt_regs *regs, 76 struct pt_regs *regs,
77 unsigned int i, unsigned int n,
78 const unsigned long *args) 77 const unsigned long *args)
79{ 78{
80 BUG_ON(i + n > 6); 79 unsigned int n = 6;
80
81 while (n-- > 0) 81 while (n-- > 0)
82 if (i + n > 0) 82 if (n > 0)
83 regs->gprs[2 + i + n] = args[n]; 83 regs->gprs[2 + n] = args[n];
84 if (i == 0) 84 regs->orig_gpr2 = args[0];
85 regs->orig_gpr2 = args[0];
86} 85}
87 86
88static inline int syscall_get_arch(void) 87static inline int syscall_get_arch(void)
diff --git a/arch/sh/include/asm/syscall_32.h b/arch/sh/include/asm/syscall_32.h
index 2bf1199a0595..8c9d7e5e5dcc 100644
--- a/arch/sh/include/asm/syscall_32.h
+++ b/arch/sh/include/asm/syscall_32.h
@@ -62,23 +62,14 @@ static inline void syscall_get_arguments(struct task_struct *task,
62 62
63static inline void syscall_set_arguments(struct task_struct *task, 63static inline void syscall_set_arguments(struct task_struct *task,
64 struct pt_regs *regs, 64 struct pt_regs *regs,
65 unsigned int i, unsigned int n,
66 const unsigned long *args) 65 const unsigned long *args)
67{ 66{
68 /* Same note as above applies */ 67 regs->regs[1] = args[5];
69 BUG_ON(i); 68 regs->regs[0] = args[4];
70 69 regs->regs[7] = args[3];
71 switch (n) { 70 regs->regs[6] = args[2];
72 case 6: regs->regs[1] = args[5]; 71 regs->regs[5] = args[1];
73 case 5: regs->regs[0] = args[4]; 72 regs->regs[4] = args[0];
74 case 4: regs->regs[7] = args[3];
75 case 3: regs->regs[6] = args[2];
76 case 2: regs->regs[5] = args[1];
77 case 1: regs->regs[4] = args[0];
78 break;
79 default:
80 BUG();
81 }
82} 73}
83 74
84static inline int syscall_get_arch(void) 75static inline int syscall_get_arch(void)
diff --git a/arch/sh/include/asm/syscall_64.h b/arch/sh/include/asm/syscall_64.h
index 4e8f6460c703..22fad97da066 100644
--- a/arch/sh/include/asm/syscall_64.h
+++ b/arch/sh/include/asm/syscall_64.h
@@ -54,11 +54,9 @@ static inline void syscall_get_arguments(struct task_struct *task,
54 54
55static inline void syscall_set_arguments(struct task_struct *task, 55static inline void syscall_set_arguments(struct task_struct *task,
56 struct pt_regs *regs, 56 struct pt_regs *regs,
57 unsigned int i, unsigned int n,
58 const unsigned long *args) 57 const unsigned long *args)
59{ 58{
60 BUG_ON(i + n > 6); 59 memcpy(&regs->regs[2], args, 6 * sizeof(args[0]));
61 memcpy(&regs->regs[2 + i], args, n * sizeof(args[0]));
62} 60}
63 61
64static inline int syscall_get_arch(void) 62static inline int syscall_get_arch(void)
diff --git a/arch/sparc/include/asm/syscall.h b/arch/sparc/include/asm/syscall.h
index 872dfee852d6..4d075434e816 100644
--- a/arch/sparc/include/asm/syscall.h
+++ b/arch/sparc/include/asm/syscall.h
@@ -119,13 +119,12 @@ static inline void syscall_get_arguments(struct task_struct *task,
119 119
120static inline void syscall_set_arguments(struct task_struct *task, 120static inline void syscall_set_arguments(struct task_struct *task,
121 struct pt_regs *regs, 121 struct pt_regs *regs,
122 unsigned int i, unsigned int n,
123 const unsigned long *args) 122 const unsigned long *args)
124{ 123{
125 unsigned int j; 124 unsigned int i;
126 125
127 for (j = 0; j < n; j++) 126 for (i = 0; i < 6; i++)
128 regs->u_regs[UREG_I0 + i + j] = args[j]; 127 regs->u_regs[UREG_I0 + i] = args[i];
129} 128}
130 129
131static inline int syscall_get_arch(void) 130static inline int syscall_get_arch(void)
diff --git a/arch/um/include/asm/syscall-generic.h b/arch/um/include/asm/syscall-generic.h
index 25d00acd1322..98e50c50c12e 100644
--- a/arch/um/include/asm/syscall-generic.h
+++ b/arch/um/include/asm/syscall-generic.h
@@ -67,43 +67,16 @@ static inline void syscall_get_arguments(struct task_struct *task,
67 67
68static inline void syscall_set_arguments(struct task_struct *task, 68static inline void syscall_set_arguments(struct task_struct *task,
69 struct pt_regs *regs, 69 struct pt_regs *regs,
70 unsigned int i, unsigned int n,
71 const unsigned long *args) 70 const unsigned long *args)
72{ 71{
73 struct uml_pt_regs *r = &regs->regs; 72 struct uml_pt_regs *r = &regs->regs;
74 73
75 switch (i) { 74 UPT_SYSCALL_ARG1(r) = *args++;
76 case 0: 75 UPT_SYSCALL_ARG2(r) = *args++;
77 if (!n--) 76 UPT_SYSCALL_ARG3(r) = *args++;
78 break; 77 UPT_SYSCALL_ARG4(r) = *args++;
79 UPT_SYSCALL_ARG1(r) = *args++; 78 UPT_SYSCALL_ARG5(r) = *args++;
80 case 1: 79 UPT_SYSCALL_ARG6(r) = *args;
81 if (!n--)
82 break;
83 UPT_SYSCALL_ARG2(r) = *args++;
84 case 2:
85 if (!n--)
86 break;
87 UPT_SYSCALL_ARG3(r) = *args++;
88 case 3:
89 if (!n--)
90 break;
91 UPT_SYSCALL_ARG4(r) = *args++;
92 case 4:
93 if (!n--)
94 break;
95 UPT_SYSCALL_ARG5(r) = *args++;
96 case 5:
97 if (!n--)
98 break;
99 UPT_SYSCALL_ARG6(r) = *args++;
100 case 6:
101 if (!n--)
102 break;
103 default:
104 BUG();
105 break;
106 }
107} 80}
108 81
109/* See arch/x86/um/asm/syscall.h for syscall_get_arch() definition. */ 82/* See arch/x86/um/asm/syscall.h for syscall_get_arch() definition. */
diff --git a/arch/x86/include/asm/syscall.h b/arch/x86/include/asm/syscall.h
index 8dbb5c379450..4c305471ec33 100644
--- a/arch/x86/include/asm/syscall.h
+++ b/arch/x86/include/asm/syscall.h
@@ -138,63 +138,26 @@ static inline void syscall_get_arguments(struct task_struct *task,
138 138
139static inline void syscall_set_arguments(struct task_struct *task, 139static inline void syscall_set_arguments(struct task_struct *task,
140 struct pt_regs *regs, 140 struct pt_regs *regs,
141 unsigned int i, unsigned int n,
142 const unsigned long *args) 141 const unsigned long *args)
143{ 142{
144# ifdef CONFIG_IA32_EMULATION 143# ifdef CONFIG_IA32_EMULATION
145 if (task->thread_info.status & TS_COMPAT) 144 if (task->thread_info.status & TS_COMPAT) {
146 switch (i) { 145 regs->bx = *args++;
147 case 0: 146 regs->cx = *args++;
148 if (!n--) break; 147 regs->dx = *args++;
149 regs->bx = *args++; 148 regs->si = *args++;
150 case 1: 149 regs->di = *args++;
151 if (!n--) break; 150 regs->bp = *args;
152 regs->cx = *args++; 151 } else
153 case 2:
154 if (!n--) break;
155 regs->dx = *args++;
156 case 3:
157 if (!n--) break;
158 regs->si = *args++;
159 case 4:
160 if (!n--) break;
161 regs->di = *args++;
162 case 5:
163 if (!n--) break;
164 regs->bp = *args++;
165 case 6:
166 if (!n--) break;
167 default:
168 BUG();
169 break;
170 }
171 else
172# endif 152# endif
173 switch (i) { 153 {
174 case 0: 154 regs->di = *args++;
175 if (!n--) break; 155 regs->si = *args++;
176 regs->di = *args++; 156 regs->dx = *args++;
177 case 1: 157 regs->r10 = *args++;
178 if (!n--) break; 158 regs->r8 = *args++;
179 regs->si = *args++; 159 regs->r9 = *args;
180 case 2: 160 }
181 if (!n--) break;
182 regs->dx = *args++;
183 case 3:
184 if (!n--) break;
185 regs->r10 = *args++;
186 case 4:
187 if (!n--) break;
188 regs->r8 = *args++;
189 case 5:
190 if (!n--) break;
191 regs->r9 = *args++;
192 case 6:
193 if (!n--) break;
194 default:
195 BUG();
196 break;
197 }
198} 161}
199 162
200static inline int syscall_get_arch(void) 163static inline int syscall_get_arch(void)
diff --git a/arch/xtensa/include/asm/syscall.h b/arch/xtensa/include/asm/syscall.h
index 1504ce9a233a..91dc06d58060 100644
--- a/arch/xtensa/include/asm/syscall.h
+++ b/arch/xtensa/include/asm/syscall.h
@@ -70,24 +70,13 @@ static inline void syscall_get_arguments(struct task_struct *task,
70 70
71static inline void syscall_set_arguments(struct task_struct *task, 71static inline void syscall_set_arguments(struct task_struct *task,
72 struct pt_regs *regs, 72 struct pt_regs *regs,
73 unsigned int i, unsigned int n,
74 const unsigned long *args) 73 const unsigned long *args)
75{ 74{
76 static const unsigned int reg[] = XTENSA_SYSCALL_ARGUMENT_REGS; 75 static const unsigned int reg[] = XTENSA_SYSCALL_ARGUMENT_REGS;
77 unsigned int j; 76 unsigned int i;
78
79 if (n == 0)
80 return;
81
82 if (WARN_ON_ONCE(i + n > SYSCALL_MAX_ARGS)) {
83 if (i < SYSCALL_MAX_ARGS)
84 n = SYSCALL_MAX_ARGS - i;
85 else
86 return;
87 }
88 77
89 for (j = 0; j < n; ++j) 78 for (i = 0; i < 6; ++i)
90 regs->areg[reg[i + j]] = args[j]; 79 regs->areg[reg[i]] = args[i];
91} 80}
92 81
93asmlinkage long xtensa_rt_sigreturn(struct pt_regs*); 82asmlinkage long xtensa_rt_sigreturn(struct pt_regs*);
diff --git a/include/asm-generic/syscall.h b/include/asm-generic/syscall.h
index 269e9412ef42..b88239e9efe4 100644
--- a/include/asm-generic/syscall.h
+++ b/include/asm-generic/syscall.h
@@ -120,21 +120,15 @@ void syscall_get_arguments(struct task_struct *task, struct pt_regs *regs,
120 * syscall_set_arguments - change system call parameter value 120 * syscall_set_arguments - change system call parameter value
121 * @task: task of interest, must be in system call entry tracing 121 * @task: task of interest, must be in system call entry tracing
122 * @regs: task_pt_regs() of @task 122 * @regs: task_pt_regs() of @task
123 * @i: argument index [0,5]
124 * @n: number of arguments; n+i must be [1,6].
125 * @args: array of argument values to store 123 * @args: array of argument values to store
126 * 124 *
127 * Changes @n arguments to the system call starting with the @i'th argument. 125 * Changes 6 arguments to the system call.
128 * Argument @i gets value @args[0], and so on. 126 * The first argument gets value @args[0], and so on.
129 * An arch inline version is probably optimal when @i and @n are constants.
130 * 127 *
131 * It's only valid to call this when @task is stopped for tracing on 128 * It's only valid to call this when @task is stopped for tracing on
132 * entry to a system call, due to %TIF_SYSCALL_TRACE or %TIF_SYSCALL_AUDIT. 129 * entry to a system call, due to %TIF_SYSCALL_TRACE or %TIF_SYSCALL_AUDIT.
133 * It's invalid to call this with @i + @n > 6; we only support system calls
134 * taking up to 6 arguments.
135 */ 130 */
136void syscall_set_arguments(struct task_struct *task, struct pt_regs *regs, 131void syscall_set_arguments(struct task_struct *task, struct pt_regs *regs,
137 unsigned int i, unsigned int n,
138 const unsigned long *args); 132 const unsigned long *args);
139 133
140/** 134/**