summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormiod <miod@openbsd.org>2008-11-27 20:46:48 +0000
committermiod <miod@openbsd.org>2008-11-27 20:46:48 +0000
commit8e4a51b4a57c968c093643992a44d99581f66142 (patch)
tree4511163377cc23f809d48b62906afe54c8aa17d5
parentNetgear WG111v2 is not supported by upgt(4), apparently; (diff)
downloadwireguard-openbsd-8e4a51b4a57c968c093643992a44d99581f66142.tar.xz
wireguard-openbsd-8e4a51b4a57c968c093643992a44d99581f66142.zip
On 88100 cpus, make sure userland processes start with SNIP and SFIP valid
(i.e. with the valid bit set in them). Found the hard way by Anders Gavare trying his latest gxemul, proves the hardware is more permitting than one would expect it to be...
-rw-r--r--sys/arch/m88k/m88k/m88k_machdep.c15
-rw-r--r--sys/arch/m88k/m88k/trap.c4
2 files changed, 15 insertions, 4 deletions
diff --git a/sys/arch/m88k/m88k/m88k_machdep.c b/sys/arch/m88k/m88k/m88k_machdep.c
index 2d20ef838b0..be41eeb193a 100644
--- a/sys/arch/m88k/m88k/m88k_machdep.c
+++ b/sys/arch/m88k/m88k/m88k_machdep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: m88k_machdep.c,v 1.41 2007/12/26 22:21:39 miod Exp $ */
+/* $OpenBSD: m88k_machdep.c,v 1.42 2008/11/27 20:46:48 miod Exp $ */
/*
* Copyright (c) 1998, 1999, 2000, 2001 Steve Murphree, Jr.
* Copyright (c) 1996 Nivas Madhur
@@ -178,9 +178,20 @@ setregs(p, pack, stack, retval)
#ifdef M88100
if (CPU_IS88100) {
/*
- * m88100_syscall() will resume at sfip / sfip + 4.
+ * m88100_syscall() will resume at sfip / sfip + 4...
*/
tf->tf_sfip = ((pack->ep_entry + 8) & FIP_ADDR) | FIP_V;
+
+ /*
+ * ... unless we are starting init, in which case we
+ * won't be returning through the regular path, and
+ * need to explicitely set up nip and fip (note that
+ * 88110 do not need such a test).
+ */
+ if (p->p_pid == 1) {
+ tf->tf_snip = tf->tf_sfip;
+ tf->tf_sfip += 4;
+ }
}
#endif
tf->tf_r[2] = retval[0] = stack;
diff --git a/sys/arch/m88k/m88k/trap.c b/sys/arch/m88k/m88k/trap.c
index b8f35945129..b2137b3132e 100644
--- a/sys/arch/m88k/m88k/trap.c
+++ b/sys/arch/m88k/m88k/trap.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: trap.c,v 1.63 2008/05/02 21:44:46 miod Exp $ */
+/* $OpenBSD: trap.c,v 1.64 2008/11/27 20:46:48 miod Exp $ */
/*
* Copyright (c) 2004, Miodrag Vallat.
* Copyright (c) 1998 Steve Murphree, Jr.
@@ -1454,7 +1454,7 @@ child_return(arg)
/* skip br instruction as in syscall() */
#ifdef M88100
if (CPU_IS88100) {
- tf->tf_snip = tf->tf_sfip & XIP_ADDR;
+ tf->tf_snip = (tf->tf_sfip & XIP_ADDR) | XIP_V;
tf->tf_sfip = tf->tf_snip + 4;
}
#endif