int isvfork;
vm_fork(p1, p2, isvfork)	register struct proc *p1, *p2;	int isvfork;{	register struct user *up;	vm_offset_t addr;#if defined(i386) || defined(pc532)	/*	 * avoid copying any of the parent's pagetables or other per-process	 * objects that reside in the map by marking all of them non-inheritable	 */	(void)vm_map_inherit(&p1->p_vmspace->vm_map,		VM_MAXUSER_ADDRESS, VM_MAX_ADDRESS, VM_INHERIT_NONE);#endif	p2->p_vmspace = vmspace_fork(p1->p_vmspace);#ifdef SYSVSHM	if (p1->p_vmspace->vm_shm)		shmfork(p1, p2, isvfork);#endif#if !defined(i386) && !defined(pc532)	/*	 * Allocate a wired-down (for now) pcb and kernel stack for the process	 */#ifdef pica	addr = kmem_alloc_upage(kernel_map, USPACE);#else	addr = kmem_alloc_pageable(kernel_map, USPACE);#endif	if (addr == 0)		panic("vm_fork: no more kernel virtual memory");	vm_map_pageable(kernel_map, addr, addr + USPACE, FALSE);#else	/*	 * XXX somehow, on 386, ocassionally pageout removes active, wired down	 * kstack and pagetables, WITHOUT going thru vm_page_unwire! Why this	 * appears to work is not yet clear, yet it does...	 */	addr = kmem_alloc(kernel_map, USPACE);	if (addr == 0)		panic("vm_fork: no more kernel virtual memory");#endif	up = (struct user *)addr;	p2->p_addr = up;	/*	 * p_stats and p_sigacts currently point at fields	 * in the user struct but not at &u, instead at p_addr.	 * Copy p_sigacts and parts of p_stats; zero the rest	 * of p_stats (statistics).	 */	p2->p_stats = &up->u_stats;	p2->p_sigacts = &up->u_sigacts;	up->u_sigacts = *p1->p_sigacts;	bzero(&up->u_stats.pstat_startzero,	    (unsigned) ((caddr_t)&up->u_stats.pstat_endzero -	    (caddr_t)&up->u_stats.pstat_startzero));	bcopy(&p1->p_stats->pstat_startcopy, &up->u_stats.pstat_startcopy,	    ((caddr_t)&up->u_stats.pstat_endcopy -	     (caddr_t)&up->u_stats.pstat_startcopy));#if defined(i386) || defined(pc532)	{ vm_offset_t addr = VM_MAXUSER_ADDRESS; struct vm_map *vp;	/* ream out old pagetables and kernel stack */	vp = &p2->p_vmspace->vm_map;	(void)vm_deallocate(vp, addr, VM_MAX_ADDRESS - addr);	(void)vm_allocate(vp, &addr, VM_MAX_ADDRESS - addr, FALSE);	(void)vm_map_inherit(vp, addr, VM_MAX_ADDRESS, VM_INHERIT_NONE);	}#endif	/*	 * cpu_fork will copy and update the kernel stack and pcb,	 * and make the child ready to run.  It marks the child	 * so that it can return differently than the parent.	 * It returns twice, once in the parent process and	 * once in the child.	 */	return (cpu_fork(p1, p2));}