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.
This commit is contained in:
parent
8cbf6e5894
commit
b09fb6432d
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue