diff options
author | Philip Guenthe <guenther@cvs.openbsd.org> | 2012-06-21 00:57:00 +0000 |
---|---|---|
committer | Philip Guenthe <guenther@cvs.openbsd.org> | 2012-06-21 00:57:00 +0000 |
commit | 867c8588faf5fba418fc7c3a85aa2bd4c3327e01 (patch) | |
tree | e98c388fcdff4a138a38722ee463c1b12f6c133a /sys/arch/sparc | |
parent | 28222fd1268ab97426703666e99f70ed942e847b (diff) |
__tfork() needs to set the stack address of the new thread in the kernel,
so that it can't get a signal while still running on the parent thread's
stack. Also, pass in sizeof(struct __tfork) to provide forward compat
when more members are added. This is an ABI change, so switch syscall
numbers and bump lib majors this time.
ok deraadt@ matthew@
Diffstat (limited to 'sys/arch/sparc')
-rw-r--r-- | sys/arch/sparc/sparc/vm_machdep.c | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/sys/arch/sparc/sparc/vm_machdep.c b/sys/arch/sparc/sparc/vm_machdep.c index 80b24f37955..8f28e16bd3f 100644 --- a/sys/arch/sparc/sparc/vm_machdep.c +++ b/sys/arch/sparc/sparc/vm_machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: vm_machdep.c,v 1.54 2011/04/07 15:30:16 miod Exp $ */ +/* $OpenBSD: vm_machdep.c,v 1.55 2012/06/21 00:56:59 guenther Exp $ */ /* $NetBSD: vm_machdep.c,v 1.30 1997/03/10 23:55:40 pk Exp $ */ /* @@ -407,12 +407,6 @@ cpu_fork(p1, p2, stack, stacksize, func, arg) /* Copy parent's trapframe */ *tf2 = *(struct trapframe *)((int)opcb + USPACE - sizeof(*tf2)); - /* - * If specified, give the child a different stack. - */ - if (stack != NULL) - tf2->tf_out[6] = (u_int)stack + stacksize; - /* Duplicate efforts of syscall(), but slightly differently */ if (tf2->tf_global[1] & SYSCALL_G2RFLAG) { /* jmp %g2 (or %g7, deprecated) on success */ @@ -439,6 +433,16 @@ cpu_fork(p1, p2, stack, stacksize, func, arg) rp->rw_local[0] = (int)func; /* Function to call */ rp->rw_local[1] = (int)arg; /* and its argument */ + /* + * If specified, give the child a different stack, with space + * reserved for the frame, and zero the frame pointer. + */ + if (stack != NULL) { + tf2->tf_out[6] = (u_int)stack + stacksize + - sizeof(struct frame); + rp->rw_in[6] = 0; + } + npcb->pcb_pc = (int)proc_trampoline - 8; npcb->pcb_sp = (int)rp; npcb->pcb_psr &= ~PSR_CWP; /* Run in window #0 */ |