Skip to content

Commit e0e431a

Browse files
author
Al Viro
committed
alpha: simplify fork and friends
* no need to restore everything from switch_stack when we only need $26 * no need to pass current_pt_regs() manually, we can just as easily calculate it in alpha_clone/alpha_vfork ($8 + constant) * interpretation of zero usp as "use the parent's" is simpler in copy_thread(); let fork and vfork just pass 0. Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
1 parent 2b067fc commit e0e431a

2 files changed

Lines changed: 14 additions & 19 deletions

File tree

‎arch/alpha/kernel/entry.S‎

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -617,15 +617,16 @@ ret_from_kernel_thread:
617617
.ent sys_fork
618618
sys_fork:
619619
.prologue 0
620-
mov $sp, $21
621620
bsr $1, do_switch_stack
622621
bis $31, SIGCHLD, $16
623622
mov $31, $17
624623
mov $31, $18
625624
mov $31, $19
626625
mov $31, $20
627626
jsr $26, alpha_clone
628-
bsr $1, undo_switch_stack
627+
fork_out:
628+
ldq $26, 56($sp)
629+
lda $sp, SWITCH_STACK_SIZE($sp)
629630
ret
630631
.end sys_fork
631632

@@ -634,24 +635,20 @@ sys_fork:
634635
.ent sys_clone
635636
sys_clone:
636637
.prologue 0
637-
mov $sp, $21
638638
bsr $1, do_switch_stack
639639
/* $16, $17, $18, $19, $20 come from the user. */
640-
jsr $26, alpha_clone
641-
bsr $1, undo_switch_stack
642-
ret
640+
lda $26, fork_out
641+
jsr $31, alpha_clone
643642
.end sys_clone
644643

645644
.align 4
646645
.globl sys_vfork
647646
.ent sys_vfork
648647
sys_vfork:
649648
.prologue 0
650-
mov $sp, $16
651649
bsr $1, do_switch_stack
652-
jsr $26, alpha_vfork
653-
bsr $1, undo_switch_stack
654-
ret
650+
lda $26, fork_out
651+
jsr $31, alpha_vfork
655652
.end sys_vfork
656653

657654
.align 4

‎arch/alpha/kernel/process.c‎

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -246,19 +246,17 @@ release_thread(struct task_struct *dead_task)
246246
int
247247
alpha_clone(unsigned long clone_flags, unsigned long usp,
248248
int __user *parent_tid, int __user *child_tid,
249-
unsigned long tls_value, struct pt_regs *regs)
249+
unsigned long tls_value)
250250
{
251-
if (!usp)
252-
usp = rdusp();
253-
254-
return do_fork(clone_flags, usp, regs, 0, parent_tid, child_tid);
251+
return do_fork(clone_flags, usp, current_pt_regs(), 0,
252+
parent_tid, child_tid);
255253
}
256254

257255
int
258-
alpha_vfork(struct pt_regs *regs)
256+
alpha_vfork(void)
259257
{
260-
return do_fork(CLONE_VFORK | CLONE_VM | SIGCHLD, rdusp(),
261-
regs, 0, NULL, NULL);
258+
return do_fork(CLONE_VFORK | CLONE_VM | SIGCHLD, 0,
259+
current_pt_regs(), 0, NULL, NULL);
262260
}
263261

264262
/*
@@ -301,7 +299,7 @@ copy_thread(unsigned long clone_flags, unsigned long usp,
301299
stack = ((struct switch_stack *) regs) - 1;
302300
*childstack = *stack;
303301
childstack->r26 = (unsigned long) ret_from_fork;
304-
childti->pcb.usp = usp;
302+
childti->pcb.usp = usp ?: rdusp();
305303
childti->pcb.ksp = (unsigned long) childstack;
306304
childti->pcb.flags = 1; /* set FEN, clear everything else */
307305

0 commit comments

Comments
 (0)