summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordg <dg@FreeBSD.org>1996-01-30 12:54:21 +0000
committerdg <dg@FreeBSD.org>1996-01-30 12:54:21 +0000
commit7b11911f521e96aa70e311bee69358da327490cb (patch)
treee9e10d3c352b0bb894ea16f16e909095c3542819
parented8a6cec36d5a133d2c4419aeb20ac9e162e9ab5 (diff)
downloadFreeBSD-src-7b11911f521e96aa70e311bee69358da327490cb.zip
FreeBSD-src-7b11911f521e96aa70e311bee69358da327490cb.tar.gz
savectx() strikes again: the saved stack pointer wasn't properly adjusted
to remove the return address. It's only the frame pointer and luck that allowed the code to work at all.
-rw-r--r--sys/amd64/amd64/cpu_switch.S7
-rw-r--r--sys/amd64/amd64/swtch.s7
-rw-r--r--sys/amd64/amd64/vm_machdep.c14
-rw-r--r--sys/i386/i386/swtch.s7
-rw-r--r--sys/i386/i386/vm_machdep.c14
5 files changed, 18 insertions, 31 deletions
diff --git a/sys/amd64/amd64/cpu_switch.S b/sys/amd64/amd64/cpu_switch.S
index fdaacd2..a07a559 100644
--- a/sys/amd64/amd64/cpu_switch.S
+++ b/sys/amd64/amd64/cpu_switch.S
@@ -33,7 +33,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: swtch.s,v 1.25 1996/01/03 21:41:29 wollman Exp $
+ * $Id: swtch.s,v 1.26 1996/01/23 02:39:16 davidg Exp $
*/
#include "npx.h" /* for NNPX */
@@ -510,7 +510,7 @@ ENTRY(mvesp)
* Update pcb, saving current processor state.
*/
ENTRY(savectx)
- /* PCB */
+ /* fetch PCB */
movl 4(%esp),%ecx
/* caller's return address - child won't execute this routine */
@@ -519,7 +519,8 @@ ENTRY(savectx)
movl $1,PCB_EAX(%ecx) /* return 1 in child */
movl %ebx,PCB_EBX(%ecx)
- movl %esp,PCB_ESP(%ecx)
+ leal 4(%esp),%eax /* stack minus return address */
+ movl %eax,PCB_ESP(%ecx)
movl %ebp,PCB_EBP(%ecx)
movl %esi,PCB_ESI(%ecx)
movl %edi,PCB_EDI(%ecx)
diff --git a/sys/amd64/amd64/swtch.s b/sys/amd64/amd64/swtch.s
index fdaacd2..a07a559 100644
--- a/sys/amd64/amd64/swtch.s
+++ b/sys/amd64/amd64/swtch.s
@@ -33,7 +33,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: swtch.s,v 1.25 1996/01/03 21:41:29 wollman Exp $
+ * $Id: swtch.s,v 1.26 1996/01/23 02:39:16 davidg Exp $
*/
#include "npx.h" /* for NNPX */
@@ -510,7 +510,7 @@ ENTRY(mvesp)
* Update pcb, saving current processor state.
*/
ENTRY(savectx)
- /* PCB */
+ /* fetch PCB */
movl 4(%esp),%ecx
/* caller's return address - child won't execute this routine */
@@ -519,7 +519,8 @@ ENTRY(savectx)
movl $1,PCB_EAX(%ecx) /* return 1 in child */
movl %ebx,PCB_EBX(%ecx)
- movl %esp,PCB_ESP(%ecx)
+ leal 4(%esp),%eax /* stack minus return address */
+ movl %eax,PCB_ESP(%ecx)
movl %ebp,PCB_EBP(%ecx)
movl %esi,PCB_ESI(%ecx)
movl %edi,PCB_EDI(%ecx)
diff --git a/sys/amd64/amd64/vm_machdep.c b/sys/amd64/amd64/vm_machdep.c
index a8edbbd..5f1f50f 100644
--- a/sys/amd64/amd64/vm_machdep.c
+++ b/sys/amd64/amd64/vm_machdep.c
@@ -38,7 +38,7 @@
*
* from: @(#)vm_machdep.c 7.3 (Berkeley) 5/13/91
* Utah $Hdr: vm_machdep.c 1.16.1.1 89/06/23$
- * $Id: vm_machdep.c,v 1.51 1996/01/19 03:57:43 dyson Exp $
+ * $Id: vm_machdep.c,v 1.52 1996/01/23 02:39:17 davidg Exp $
*/
#include "npx.h"
@@ -587,17 +587,9 @@ cpu_fork(p1, p2)
pmap_activate(&p2->p_vmspace->vm_pmap, &up->u_pcb);
/*
- *
- * Arrange for a non-local goto when the new process
- * is started, to resume here, returning nonzero from setjmp.
+ * Return (0) in parent, (1) in child.
*/
- if (savectx(&up->u_pcb)) {
- /*
- * Return 1 in child.
- */
- return (1);
- }
- return (0);
+ return (savectx(&up->u_pcb));
}
void
diff --git a/sys/i386/i386/swtch.s b/sys/i386/i386/swtch.s
index fdaacd2..a07a559 100644
--- a/sys/i386/i386/swtch.s
+++ b/sys/i386/i386/swtch.s
@@ -33,7 +33,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: swtch.s,v 1.25 1996/01/03 21:41:29 wollman Exp $
+ * $Id: swtch.s,v 1.26 1996/01/23 02:39:16 davidg Exp $
*/
#include "npx.h" /* for NNPX */
@@ -510,7 +510,7 @@ ENTRY(mvesp)
* Update pcb, saving current processor state.
*/
ENTRY(savectx)
- /* PCB */
+ /* fetch PCB */
movl 4(%esp),%ecx
/* caller's return address - child won't execute this routine */
@@ -519,7 +519,8 @@ ENTRY(savectx)
movl $1,PCB_EAX(%ecx) /* return 1 in child */
movl %ebx,PCB_EBX(%ecx)
- movl %esp,PCB_ESP(%ecx)
+ leal 4(%esp),%eax /* stack minus return address */
+ movl %eax,PCB_ESP(%ecx)
movl %ebp,PCB_EBP(%ecx)
movl %esi,PCB_ESI(%ecx)
movl %edi,PCB_EDI(%ecx)
diff --git a/sys/i386/i386/vm_machdep.c b/sys/i386/i386/vm_machdep.c
index a8edbbd..5f1f50f 100644
--- a/sys/i386/i386/vm_machdep.c
+++ b/sys/i386/i386/vm_machdep.c
@@ -38,7 +38,7 @@
*
* from: @(#)vm_machdep.c 7.3 (Berkeley) 5/13/91
* Utah $Hdr: vm_machdep.c 1.16.1.1 89/06/23$
- * $Id: vm_machdep.c,v 1.51 1996/01/19 03:57:43 dyson Exp $
+ * $Id: vm_machdep.c,v 1.52 1996/01/23 02:39:17 davidg Exp $
*/
#include "npx.h"
@@ -587,17 +587,9 @@ cpu_fork(p1, p2)
pmap_activate(&p2->p_vmspace->vm_pmap, &up->u_pcb);
/*
- *
- * Arrange for a non-local goto when the new process
- * is started, to resume here, returning nonzero from setjmp.
+ * Return (0) in parent, (1) in child.
*/
- if (savectx(&up->u_pcb)) {
- /*
- * Return 1 in child.
- */
- return (1);
- }
- return (0);
+ return (savectx(&up->u_pcb));
}
void
OpenPOWER on IntegriCloud