Skip to content

Commit 415bfae

Browse files
author
Al Viro
committed
parisc: switch to generic fork/vfork/clone
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
1 parent 92bbe6c commit 415bfae

4 files changed

Lines changed: 22 additions & 69 deletions

File tree

‎arch/parisc/Kconfig‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ config PARISC
2424
select MODULES_USE_ELF_RELA
2525
select GENERIC_KERNEL_THREAD
2626
select GENERIC_KERNEL_EXECVE
27+
select CLONE_BACKWARDS
2728

2829
help
2930
The PA-RISC microprocessor is designed by Hewlett-Packard and used

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,9 @@ type name(type1 arg1, type2 arg2, type3 arg3, type4 arg4, type5 arg5) \
164164
#define __ARCH_WANT_SYS_RT_SIGSUSPEND
165165
#define __ARCH_WANT_COMPAT_SYS_RT_SIGSUSPEND
166166
#define __ARCH_WANT_SYS_EXECVE
167+
#define __ARCH_WANT_SYS_FORK
168+
#define __ARCH_WANT_SYS_VFORK
169+
#define __ARCH_WANT_SYS_CLONE
167170

168171
#endif /* __ASSEMBLY__ */
169172

‎arch/parisc/kernel/entry.S‎

Lines changed: 8 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1688,18 +1688,20 @@ dtlb_fault:
16881688
LDREG PT_GR18(\regs),%r18
16891689
.endm
16901690

1691-
ENTRY(sys_fork_wrapper)
1691+
.macro fork_like name
1692+
ENTRY(sys_\name\()_wrapper)
16921693
LDREG TI_TASK-THREAD_SZ_ALGN-FRAME_SIZE(%r30), %r1
16931694
ldo TASK_REGS(%r1),%r1
16941695
reg_save %r1
16951696
mfctl %cr27, %r28
1697+
b sys_\name
16961698
STREG %r28, PT_CR27(%r1)
1699+
ENDPROC(sys_\name\()_wrapper)
1700+
.endm
16971701

1698-
LDREG PT_GR30(%r1),%r25
1699-
copy %r1,%r24
1700-
b sys_clone
1701-
ldi SIGCHLD,%r26
1702-
ENDPROC(sys_fork_wrapper)
1702+
fork_like clone
1703+
fork_like fork
1704+
fork_like vfork
17031705

17041706
/* Set the return value for the child */
17051707
ENTRY(child_return)
@@ -1716,30 +1718,6 @@ finish_child_return:
17161718
copy %r0,%r28
17171719
ENDPROC(child_return)
17181720

1719-
1720-
ENTRY(sys_clone_wrapper)
1721-
LDREG TI_TASK-THREAD_SZ_ALGN-FRAME_SIZE(%r30),%r1
1722-
ldo TASK_REGS(%r1),%r1 /* get pt regs */
1723-
reg_save %r1
1724-
mfctl %cr27, %r28
1725-
STREG %r28, PT_CR27(%r1)
1726-
b sys_clone
1727-
copy %r1,%r24
1728-
ENDPROC(sys_clone_wrapper)
1729-
1730-
1731-
ENTRY(sys_vfork_wrapper)
1732-
LDREG TI_TASK-THREAD_SZ_ALGN-FRAME_SIZE(%r30),%r1
1733-
ldo TASK_REGS(%r1),%r1 /* get pt regs */
1734-
reg_save %r1
1735-
mfctl %cr27, %r28
1736-
STREG %r28, PT_CR27(%r1)
1737-
1738-
b sys_vfork
1739-
copy %r1,%r26
1740-
ENDPROC(sys_vfork_wrapper)
1741-
1742-
17431721
ENTRY(sys_rt_sigreturn_wrapper)
17441722
LDREG TI_TASK-THREAD_SZ_ALGN-FRAME_SIZE(%r30),%r26
17451723
ldo TASK_REGS(%r26),%r26 /* get pt regs */

‎arch/parisc/kernel/process.c‎

Lines changed: 10 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -202,46 +202,10 @@ int dump_task_fpu (struct task_struct *tsk, elf_fpregset_t *r)
202202
return 1;
203203
}
204204

205-
/* Note that "fork()" is implemented in terms of clone, with
206-
parameters (SIGCHLD, regs->gr[30], regs). */
207-
int
208-
sys_clone(unsigned long clone_flags, unsigned long usp,
209-
struct pt_regs *regs)
210-
{
211-
/* Arugments from userspace are:
212-
r26 = Clone flags.
213-
r25 = Child stack.
214-
r24 = parent_tidptr.
215-
r23 = Is the TLS storage descriptor
216-
r22 = child_tidptr
217-
218-
However, these last 3 args are only examined
219-
if the proper flags are set. */
220-
int __user *parent_tidptr = (int __user *)regs->gr[24];
221-
int __user *child_tidptr = (int __user *)regs->gr[22];
222-
223-
/* usp must be word aligned. This also prevents users from
224-
* passing in the value 1 (which is the signal for a special
225-
* return for a kernel thread) */
226-
usp = ALIGN(usp, 4);
227-
228-
/* A zero value for usp means use the current stack */
229-
if (usp == 0)
230-
usp = regs->gr[30];
231-
232-
return do_fork(clone_flags, usp, regs, 0, parent_tidptr, child_tidptr);
233-
}
234-
235-
int
236-
sys_vfork(struct pt_regs *regs)
237-
{
238-
return do_fork(CLONE_VFORK | CLONE_VM | SIGCHLD, regs->gr[30], regs, 0, NULL, NULL);
239-
}
240-
241205
int
242206
copy_thread(unsigned long clone_flags, unsigned long usp,
243207
unsigned long arg,
244-
struct task_struct *p, struct pt_regs *pregs)
208+
struct task_struct *p, struct pt_regs *unused)
245209
{
246210
struct pt_regs * cregs = &(p->thread.regs);
247211
void *stack = task_stack_page(p);
@@ -278,7 +242,14 @@ copy_thread(unsigned long clone_flags, unsigned long usp,
278242
cregs->gr[25] = arg;
279243
} else {
280244
/* user thread */
281-
cregs->gr[30] = usp;
245+
/* usp must be word aligned. This also prevents users from
246+
* passing in the value 1 (which is the signal for a special
247+
* return for a kernel thread) */
248+
if (usp) {
249+
usp = ALIGN(usp, 4);
250+
if (likely(usp))
251+
cregs->gr[30] = usp;
252+
}
282253
cregs->ksp = (unsigned long)stack + THREAD_SZ_ALGN + FRAME_SIZE;
283254
if (personality(p->personality) == PER_HPUX) {
284255
#ifdef CONFIG_HPUX
@@ -291,7 +262,7 @@ copy_thread(unsigned long clone_flags, unsigned long usp,
291262
}
292263
/* Setup thread TLS area from the 4th parameter in clone */
293264
if (clone_flags & CLONE_SETTLS)
294-
cregs->cr27 = pregs->gr[23];
265+
cregs->cr27 = cregs->gr[23];
295266
}
296267

297268
return 0;

0 commit comments

Comments
 (0)