summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkettenis <kettenis@openbsd.org>2005-08-18 18:40:51 +0000
committerkettenis <kettenis@openbsd.org>2005-08-18 18:40:51 +0000
commit2573742b00dc6d8d0878266f3694f6aede407b43 (patch)
tree9c33911db29441d4139e4d4c88951f2792fff384
parentOops, previous fix would prevent standard input from being processed at all (diff)
downloadwireguard-openbsd-2573742b00dc6d8d0878266f3694f6aede407b43.tar.xz
wireguard-openbsd-2573742b00dc6d8d0878266f3694f6aede407b43.zip
Skip (trap) instruction in cpu_fork() instead of proc_trampoline().
Add special handling for init(8) in setregs(). Fixes returning from fork(2) in the child with a pending signal. ok deraadt@, art@ (screaming in agony)
-rw-r--r--sys/arch/sparc/sparc/locore.s6
-rw-r--r--sys/arch/sparc/sparc/machdep.c7
-rw-r--r--sys/arch/sparc/sparc/vm_machdep.c6
3 files changed, 14 insertions, 5 deletions
diff --git a/sys/arch/sparc/sparc/locore.s b/sys/arch/sparc/sparc/locore.s
index 5ddf51820cb..fdc2f559511 100644
--- a/sys/arch/sparc/sparc/locore.s
+++ b/sys/arch/sparc/sparc/locore.s
@@ -1,4 +1,4 @@
-/* $OpenBSD: locore.s,v 1.64 2005/04/17 18:47:50 miod Exp $ */
+/* $OpenBSD: locore.s,v 1.65 2005/08/18 18:40:51 kettenis Exp $ */
/* $NetBSD: locore.s,v 1.73 1997/09/13 20:36:48 pk Exp $ */
/*
@@ -4829,9 +4829,9 @@ ENTRY(proc_trampoline)
*/
mov PSR_S, %l0 ! user psr (no need to load it)
!?wr %g0, 2, %wim ! %wim = 2
- ld [%sp + CCFSZ + 8], %l1 ! pc = tf->tf_npc from execve/fork
+ ld [%sp + CCFSZ + 4], %l1 ! pc
b return_from_syscall
- add %l1, 4, %l2 ! npc = pc+4
+ ld [%sp + CCFSZ + 8], %l2 ! npc
/* probeget and probeset are meant to be used during autoconfiguration */
diff --git a/sys/arch/sparc/sparc/machdep.c b/sys/arch/sparc/sparc/machdep.c
index ec45d7fad67..7112f2b4c31 100644
--- a/sys/arch/sparc/sparc/machdep.c
+++ b/sys/arch/sparc/sparc/machdep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: machdep.c,v 1.105 2005/04/11 15:13:01 deraadt Exp $ */
+/* $OpenBSD: machdep.c,v 1.106 2005/08/18 18:40:51 kettenis Exp $ */
/* $NetBSD: machdep.c,v 1.85 1997/09/12 08:55:02 pk Exp $ */
/*
@@ -413,6 +413,11 @@ setregs(p, pack, stack, retval)
tf->tf_npc = pack->ep_entry & ~3;
tf->tf_global[1] = (int)PS_STRINGS;
tf->tf_global[2] = tf->tf_global[7] = tf->tf_npc;
+ /* XXX exec of init(8) returns via proc_trampoline() */
+ if (p->p_pid == 1) {
+ tf->tf_pc = tf->tf_npc;
+ tf->tf_npc += 4;
+ }
stack -= sizeof(struct rwindow);
tf->tf_out[6] = stack;
retval[1] = 0;
diff --git a/sys/arch/sparc/sparc/vm_machdep.c b/sys/arch/sparc/sparc/vm_machdep.c
index 766cc7259be..5d8a9bf6553 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.45 2002/12/10 23:45:02 miod Exp $ */
+/* $OpenBSD: vm_machdep.c,v 1.46 2005/08/18 18:40:51 kettenis Exp $ */
/* $NetBSD: vm_machdep.c,v 1.30 1997/03/10 23:55:40 pk Exp $ */
/*
@@ -456,6 +456,10 @@ cpu_fork(p1, p2, stack, stacksize, func, arg)
tf2->tf_out[0] = 0;
tf2->tf_out[1] = 1;
+ /* Skip trap instruction. */
+ tf2->tf_pc = tf2->tf_npc;
+ tf2->tf_npc += 4;
+
/* Construct kernel frame to return to in cpu_switch() */
rp = (struct rwindow *)((u_int)npcb + TOPFRAMEOFF);
rp->rw_local[0] = (int)func; /* Function to call */