Split out the code that prepares a VM space for exec into a new

vmspace_exec() function.
This commit is contained in:
thorpej 1997-12-31 07:47:41 +00:00
parent 1679a04502
commit a322314f51
3 changed files with 39 additions and 16 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: kern_exec.c,v 1.85 1997/09/11 23:02:32 mycroft Exp $ */
/* $NetBSD: kern_exec.c,v 1.86 1997/12/31 07:47:44 thorpej Exp $ */
/*-
* Copyright (C) 1993, 1994, 1996 Christopher G. Demetriou
@ -224,7 +224,7 @@ sys_execve(p, v, retval)
size_t len;
char *stack;
struct ps_strings arginfo;
struct vmspace *vm = p->p_vmspace;
struct vmspace *vm;
char **tmpfap;
int szsigcode;
extern struct emul emul_netbsd;
@ -357,20 +357,15 @@ sys_execve(p, v, retval)
/* adjust "active stack depth" for process VSZ */
pack.ep_ssize = len; /* maybe should go elsewhere, but... */
/* Unmap old program */
/* XXX cgd 960926: the sparc #ifdef should be a MD hook */
#ifdef sparc
kill_user_windows(p); /* before stack addresses go away */
#endif
/* Kill shared memory and unmap old program */
#ifdef SYSVSHM
if (vm->vm_shm)
shmexit(p);
#endif
vm_deallocate(&vm->vm_map, VM_MIN_ADDRESS,
VM_MAXUSER_ADDRESS - VM_MIN_ADDRESS);
/*
* Do whatever is necessary to prepare the address space
* for remapping. Note that this might replace the current
* vmspace with another!
*/
vmspace_exec(p);
/* Now map address space */
vm = p->p_vmspace;
vm->vm_taddr = (char *) pack.ep_taddr;
vm->vm_tsize = btoc(pack.ep_tsize);
vm->vm_daddr = (char *) pack.ep_daddr;

View File

@ -1,4 +1,4 @@
/* $NetBSD: vm_extern.h,v 1.27 1997/08/27 02:35:38 mrg Exp $ */
/* $NetBSD: vm_extern.h,v 1.28 1997/12/31 07:47:41 thorpej Exp $ */
/*-
* Copyright (c) 1992, 1993
@ -132,6 +132,7 @@ void vm_set_page_size __P((void));
void vmmeter __P((void));
struct vmspace *vmspace_alloc __P((vm_offset_t, vm_offset_t, int));
struct vmspace *vmspace_fork __P((struct vmspace *));
void vmspace_exec __P((struct proc *));
void vmspace_free __P((struct vmspace *));
void vmtotal __P((struct vmtotal *));
void vnode_pager_setsize __P((struct vnode *, u_quad_t));

View File

@ -1,4 +1,4 @@
/* $NetBSD: vm_map.c,v 1.29 1997/10/16 23:29:26 christos Exp $ */
/* $NetBSD: vm_map.c,v 1.30 1997/12/31 07:47:42 thorpej Exp $ */
/*
* Copyright (c) 1991, 1993
@ -72,6 +72,10 @@
#include <sys/systm.h>
#include <sys/malloc.h>
#ifdef SYSVSHM
#include <sys/shm.h>
#endif
#include <vm/vm.h>
#include <vm/vm_page.h>
#include <vm/vm_object.h>
@ -201,6 +205,29 @@ vmspace_alloc(min, max, pageable)
return (vm);
}
/*
* Perform operations on VM space that need to happen during exec.
*/
void
vmspace_exec(p)
struct proc *p;
{
struct vmspace *ovm = p->p_vmspace;
vm_map_t map = &ovm->vm_map;
#ifdef sparc
/* XXX cgd 960926: the sparc #ifdef should be a MD hook */
kill_user_windows(p); /* before stack addresses go away */
#endif
/* Kill shared memory and unmap old program. */
#ifdef SYSVSHM
if (ovm->vm_shm)
shmexit(p);
#endif
vm_deallocate(map, VM_MIN_ADDRESS,
VM_MAXUSER_ADDRESS - VM_MIN_ADDRESS);
}
void
vmspace_free(vm)
register struct vmspace *vm;