int error;
int rv;
uvm_fork(p1, p2, shared, stack, stacksize, func, arg)	struct proc *p1, *p2;	boolean_t shared;	void *stack;	size_t stacksize;	void (*func) __P((void *));	void *arg;{	struct user *up = p2->p_addr;	int error;	if (shared == TRUE) {		p2->p_vmspace = NULL;		uvmspace_share(p1, p2);			/* share vmspace */	} else		p2->p_vmspace = uvmspace_fork(p1->p_vmspace); /* fork vmspace */	/*	 * Wire down the U-area for the process, which contains the PCB	 * and the kernel stack.  Wired state is stored in p->p_flag's	 * P_INMEM bit rather than in the vm_map_entry's wired count	 * to prevent kernel_map fragmentation.	 *	 * Note the kernel stack gets read/write accesses right off	 * the bat.	 */	error = uvm_fault_wire(kernel_map, (vaddr_t)up,	    (vaddr_t)up + USPACE, VM_PROT_READ | VM_PROT_WRITE);	if (error)		panic("uvm_fork: uvm_fault_wire failed: %d", error);	/*	 * p_stats currently points at a field in the user struct.  Copy	 * parts of p_stats, and zero out the rest.	 */	p2->p_stats = &up->u_stats;	memset(&up->u_stats.pstat_startzero, 0,	       ((caddr_t)&up->u_stats.pstat_endzero -		(caddr_t)&up->u_stats.pstat_startzero));	memcpy(&up->u_stats.pstat_startcopy, &p1->p_stats->pstat_startcopy,	       ((caddr_t)&up->u_stats.pstat_endcopy -		(caddr_t)&up->u_stats.pstat_startcopy));	/*	 * cpu_fork() copy and update the pcb, and make the child ready	 * to run.  If this is a normal user fork, the child will exit	 * directly to user mode via child_return() on its first time	 * slice and will not return here.  If this is a kernel thread,	 * the specified entry point will be executed.	 */	cpu_fork(p1, p2, stack, stacksize, func, arg);}