Skip to content

Commit 8eae10e

Browse files
author
Al Viro
committed
m32r: switch to generic sys_execve()
... and get rid of the horrors in fork()/vfork()/clone() prototypes. It's fscking faster to calculate pt_regs in question than to fetch the pointer from stack... Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
1 parent ea4a1da commit 8eae10e

3 files changed

Lines changed: 13 additions & 36 deletions

File tree

‎arch/m32r/include/asm/ptrace.h‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,8 @@ extern void withdraw_debug_trap(struct pt_regs *regs);
139139

140140
#define task_pt_regs(task) \
141141
((struct pt_regs *)(task_stack_page(task) + THREAD_SIZE) - 1)
142+
#define current_pt_regs() ((struct pt_regs *) \
143+
((unsigned long)current_thread_info() + THREAD_SIZE) - 1)
142144

143145
#endif /* __KERNEL */
144146

‎arch/m32r/include/asm/unistd.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -352,6 +352,7 @@
352352
#define __ARCH_WANT_SYS_OLDUMOUNT
353353
#define __ARCH_WANT_SYS_RT_SIGACTION
354354
#define __ARCH_WANT_SYS_RT_SIGSUSPEND
355+
#define __ARCH_WANT_SYS_EXECVE
355356

356357
#define __IGNORE_lchown
357358
#define __IGNORE_setuid

‎arch/m32r/kernel/process.c‎

Lines changed: 10 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -216,27 +216,25 @@ int copy_thread(unsigned long clone_flags, unsigned long spu,
216216
return 0;
217217
}
218218

219-
asmlinkage int sys_fork(unsigned long r0, unsigned long r1, unsigned long r2,
220-
unsigned long r3, unsigned long r4, unsigned long r5, unsigned long r6,
221-
struct pt_regs regs)
219+
asmlinkage int sys_fork(void)
222220
{
223221
#ifdef CONFIG_MMU
224-
return do_fork(SIGCHLD, regs.spu, &regs, 0, NULL, NULL);
222+
struct pt_regs *regs = current_pt_regs();
223+
return do_fork(SIGCHLD, regs->spu, regs, 0, NULL, NULL);
225224
#else
226225
return -EINVAL;
227226
#endif /* CONFIG_MMU */
228227
}
229228

230229
asmlinkage int sys_clone(unsigned long clone_flags, unsigned long newsp,
231230
unsigned long parent_tidptr,
232-
unsigned long child_tidptr,
233-
unsigned long r4, unsigned long r5, unsigned long r6,
234-
struct pt_regs regs)
231+
unsigned long child_tidptr)
235232
{
233+
struct pt_regs *regs = current_pt_regs();
236234
if (!newsp)
237-
newsp = regs.spu;
235+
newsp = regs->spu;
238236

239-
return do_fork(clone_flags, newsp, &regs, 0,
237+
return do_fork(clone_flags, newsp, regs, 0,
240238
(int __user *)parent_tidptr, (int __user *)child_tidptr);
241239
}
242240

@@ -250,37 +248,13 @@ asmlinkage int sys_clone(unsigned long clone_flags, unsigned long newsp,
250248
* do not have enough call-clobbered registers to hold all
251249
* the information you need.
252250
*/
253-
asmlinkage int sys_vfork(unsigned long r0, unsigned long r1, unsigned long r2,
254-
unsigned long r3, unsigned long r4, unsigned long r5, unsigned long r6,
255-
struct pt_regs regs)
251+
asmlinkage int sys_vfork(void)
256252
{
257-
return do_fork(CLONE_VFORK | CLONE_VM | SIGCHLD, regs.spu, &regs, 0,
253+
struct pt_regs *regs = current_pt_regs();
254+
return do_fork(CLONE_VFORK | CLONE_VM | SIGCHLD, regs->spu, regs, 0,
258255
NULL, NULL);
259256
}
260257

261-
/*
262-
* sys_execve() executes a new program.
263-
*/
264-
asmlinkage int sys_execve(const char __user *ufilename,
265-
const char __user *const __user *uargv,
266-
const char __user *const __user *uenvp,
267-
unsigned long r3, unsigned long r4, unsigned long r5,
268-
unsigned long r6, struct pt_regs regs)
269-
{
270-
int error;
271-
struct filename *filename;
272-
273-
filename = getname(ufilename);
274-
error = PTR_ERR(filename);
275-
if (IS_ERR(filename))
276-
goto out;
277-
278-
error = do_execve(filename->name, uargv, uenvp, &regs);
279-
putname(filename);
280-
out:
281-
return error;
282-
}
283-
284258
/*
285259
* These bracket the sleeping functions..
286260
*/

0 commit comments

Comments
 (0)