xref: /openbsd-src/sys/kern/init_main.c (revision daf88648c0e349d5c02e1504293082072c981640)
1 /*	$OpenBSD: init_main.c,v 1.134 2007/01/12 07:41:31 art Exp $	*/
2 /*	$NetBSD: init_main.c,v 1.84.4.1 1996/06/02 09:08:06 mrg Exp $	*/
3 
4 /*
5  * Copyright (c) 1995 Christopher G. Demetriou.  All rights reserved.
6  * Copyright (c) 1982, 1986, 1989, 1991, 1992, 1993
7  *	The Regents of the University of California.  All rights reserved.
8  * (c) UNIX System Laboratories, Inc.
9  * All or some portions of this file are derived from material licensed
10  * to the University of California by American Telephone and Telegraph
11  * Co. or Unix System Laboratories, Inc. and are reproduced herein with
12  * the permission of UNIX System Laboratories, Inc.
13  *
14  * Redistribution and use in source and binary forms, with or without
15  * modification, are permitted provided that the following conditions
16  * are met:
17  * 1. Redistributions of source code must retain the above copyright
18  *    notice, this list of conditions and the following disclaimer.
19  * 2. Redistributions in binary form must reproduce the above copyright
20  *    notice, this list of conditions and the following disclaimer in the
21  *    documentation and/or other materials provided with the distribution.
22  * 3. Neither the name of the University nor the names of its contributors
23  *    may be used to endorse or promote products derived from this software
24  *    without specific prior written permission.
25  *
26  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
27  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
28  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
29  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
30  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
31  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
32  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
33  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
34  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
35  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
36  * SUCH DAMAGE.
37  *
38  *	@(#)init_main.c	8.9 (Berkeley) 1/21/94
39  */
40 
41 #include <sys/param.h>
42 #include <sys/filedesc.h>
43 #include <sys/file.h>
44 #include <sys/errno.h>
45 #include <sys/exec.h>
46 #include <sys/kernel.h>
47 #include <sys/kthread.h>
48 #include <sys/mount.h>
49 #include <sys/proc.h>
50 #include <sys/resourcevar.h>
51 #include <sys/signalvar.h>
52 #include <sys/systm.h>
53 #include <sys/namei.h>
54 #include <sys/vnode.h>
55 #include <sys/tty.h>
56 #include <sys/conf.h>
57 #include <sys/buf.h>
58 #include <sys/device.h>
59 #include <sys/socketvar.h>
60 #include <sys/lockf.h>
61 #include <sys/protosw.h>
62 #include <sys/reboot.h>
63 #include <sys/user.h>
64 #ifdef SYSVSHM
65 #include <sys/shm.h>
66 #endif
67 #ifdef SYSVSEM
68 #include <sys/sem.h>
69 #endif
70 #ifdef SYSVMSG
71 #include <sys/msg.h>
72 #endif
73 #include <sys/domain.h>
74 #include <sys/mbuf.h>
75 #include <sys/pipe.h>
76 
77 #include <sys/syscall.h>
78 #include <sys/syscallargs.h>
79 
80 #include <dev/rndvar.h>
81 
82 #include <ufs/ufs/quota.h>
83 
84 #include <machine/cpu.h>
85 
86 #include <uvm/uvm.h>
87 
88 #include <net/if.h>
89 #include <net/raw_cb.h>
90 
91 #if defined(CRYPTO)
92 #include <crypto/cryptodev.h>
93 #include <crypto/cryptosoft.h>
94 #endif
95 
96 #if defined(NFSSERVER) || defined(NFSCLIENT)
97 extern void nfs_init(void);
98 #endif
99 
100 const char	copyright[] =
101 "Copyright (c) 1982, 1986, 1989, 1991, 1993\n"
102 "\tThe Regents of the University of California.  All rights reserved.\n"
103 "Copyright (c) 1995-2007 OpenBSD. All rights reserved.  http://www.OpenBSD.org\n";
104 
105 /* Components of the first process -- never freed. */
106 struct	session session0;
107 struct	pgrp pgrp0;
108 struct	proc proc0;
109 struct	pcred cred0;
110 struct	plimit limit0;
111 struct	vmspace vmspace0;
112 struct	sigacts sigacts0;
113 #if !defined(__HAVE_CPUINFO) && !defined(curproc)
114 struct	proc *curproc;
115 #endif
116 struct	proc *initproc;
117 
118 int	cmask = CMASK;
119 extern	struct user *proc0paddr;
120 
121 void	(*md_diskconf)(void) = NULL;
122 struct	vnode *rootvp, *swapdev_vp;
123 int	boothowto;
124 struct	timeval boottime;
125 #ifndef __HAVE_CPUINFO
126 struct	timeval runtime;
127 #endif
128 int	ncpus =  1;
129 __volatile int start_init_exec;		/* semaphore for start_init() */
130 
131 #if !defined(NO_PROPOLICE)
132 long	__guard[8];
133 #endif
134 
135 /* XXX return int so gcc -Werror won't complain */
136 int	main(void *);
137 void	check_console(struct proc *);
138 void	start_init(void *);
139 void	start_cleaner(void *);
140 void	start_update(void *);
141 void	start_reaper(void *);
142 void	start_crypto(void *);
143 void	init_exec(void);
144 void	kqueue_init(void);
145 
146 extern char sigcode[], esigcode[];
147 #ifdef SYSCALL_DEBUG
148 extern char *syscallnames[];
149 #endif
150 
151 struct emul emul_native = {
152 	"native",
153 	NULL,
154 	sendsig,
155 	SYS_syscall,
156 	SYS_MAXSYSCALL,
157 	sysent,
158 #ifdef SYSCALL_DEBUG
159 	syscallnames,
160 #else
161 	NULL,
162 #endif
163 	0,
164 	copyargs,
165 	setregs,
166 	NULL,
167 	sigcode,
168 	esigcode,
169 	EMUL_ENABLED | EMUL_NATIVE,
170 };
171 
172 
173 /*
174  * System startup; initialize the world, create process 0, mount root
175  * filesystem, and fork to create init and pagedaemon.  Most of the
176  * hard work is done in the lower-level initialization routines including
177  * startup(), which does memory initialization and autoconfiguration.
178  */
179 /* XXX return int, so gcc -Werror won't complain */
180 int
181 main(void *framep)
182 {
183 	struct proc *p;
184 	struct pdevinit *pdev;
185 	struct timeval rtv;
186 	quad_t lim;
187 	int s, i;
188 	extern struct pdevinit pdevinit[];
189 	extern void scheduler_start(void);
190 	extern void disk_init(void);
191 	extern void endtsleep(void *);
192 	extern void realitexpire(void *);
193 
194 	/*
195 	 * Initialize the current process pointer (curproc) before
196 	 * any possible traps/probes to simplify trap processing.
197 	 */
198 	curproc = p = &proc0;
199 #ifdef __HAVE_CPUINFO
200 	p->p_cpu = curcpu();
201 #endif
202 
203 	/*
204 	 * Initialize timeouts.
205 	 */
206 	timeout_startup();
207 
208 	/*
209 	 * Attempt to find console and initialize
210 	 * in case of early panic or other messages.
211 	 */
212 	config_init();		/* init autoconfiguration data structures */
213 	consinit();
214 
215 	printf("%s\n", copyright);
216 
217 	KERNEL_LOCK_INIT();
218 
219 	uvm_init();
220 	disk_init();		/* must come before autoconfiguration */
221 	tty_init();		/* initialise tty's */
222 	cpu_startup();
223 
224 	/*
225 	 * Initialize mbuf's.  Do this now because we might attempt to
226 	 * allocate mbufs or mbuf clusters during autoconfiguration.
227 	 */
228 	mbinit();
229 
230 	/* Initialize sockets. */
231 	soinit();
232 
233 	/*
234 	 * Initialize process and pgrp structures.
235 	 */
236 	procinit();
237 
238 	/* Initialize file locking. */
239 	lf_init();
240 
241 	/*
242 	 * Initialize filedescriptors.
243 	 */
244 	filedesc_init();
245 
246 	/*
247 	 * Initialize pipes.
248 	 */
249 	pipe_init();
250 
251 	/*
252 	 * Initialize kqueues.
253 	 */
254 	kqueue_init();
255 
256 	/*
257 	 * Create process 0 (the swapper).
258 	 */
259 	LIST_INSERT_HEAD(&allproc, p, p_list);
260 	p->p_pgrp = &pgrp0;
261 	LIST_INSERT_HEAD(PIDHASH(0), p, p_hash);
262 	LIST_INSERT_HEAD(PGRPHASH(0), &pgrp0, pg_hash);
263 	LIST_INIT(&pgrp0.pg_members);
264 	LIST_INSERT_HEAD(&pgrp0.pg_members, p, p_pglist);
265 
266 	pgrp0.pg_session = &session0;
267 	session0.s_count = 1;
268 	session0.s_leader = p;
269 
270 	p->p_thrparent = p;
271 	LIST_INIT(&p->p_thrchildren);
272 
273 	p->p_flag = P_SYSTEM | P_NOCLDWAIT;
274 	p->p_stat = SONPROC;
275 	p->p_nice = NZERO;
276 	p->p_emul = &emul_native;
277 	bcopy("swapper", p->p_comm, sizeof ("swapper"));
278 
279 	/* Init timeouts. */
280 	timeout_set(&p->p_sleep_to, endtsleep, p);
281 	timeout_set(&p->p_realit_to, realitexpire, p);
282 
283 	/* Create credentials. */
284 	cred0.p_refcnt = 1;
285 	p->p_cred = &cred0;
286 	p->p_ucred = crget();
287 	p->p_ucred->cr_ngroups = 1;	/* group 0 */
288 
289 	/* Initialize signal state for process 0. */
290 	signal_init();
291 	p->p_sigacts = &sigacts0;
292 	siginit(p);
293 
294 	/* Create the file descriptor table. */
295 	p->p_fd = fdinit(NULL);
296 
297 	/* Create the limits structures. */
298 	p->p_limit = &limit0;
299 	for (i = 0; i < sizeof(p->p_rlimit)/sizeof(p->p_rlimit[0]); i++)
300 		limit0.pl_rlimit[i].rlim_cur =
301 		    limit0.pl_rlimit[i].rlim_max = RLIM_INFINITY;
302 	limit0.pl_rlimit[RLIMIT_NOFILE].rlim_cur = NOFILE;
303 	limit0.pl_rlimit[RLIMIT_NOFILE].rlim_max = MIN(NOFILE_MAX,
304 	    (maxfiles - NOFILE > NOFILE) ?  maxfiles - NOFILE : NOFILE);
305 	limit0.pl_rlimit[RLIMIT_NPROC].rlim_cur = MAXUPRC;
306 	lim = ptoa(uvmexp.free);
307 	limit0.pl_rlimit[RLIMIT_RSS].rlim_max = lim;
308 	limit0.pl_rlimit[RLIMIT_MEMLOCK].rlim_max = lim;
309 	limit0.pl_rlimit[RLIMIT_MEMLOCK].rlim_cur = lim / 3;
310 	limit0.p_refcnt = 1;
311 
312 	/* Allocate a prototype map so we have something to fork. */
313 	uvmspace_init(&vmspace0, pmap_kernel(), round_page(VM_MIN_ADDRESS),
314 	    trunc_page(VM_MAX_ADDRESS), TRUE);
315 	p->p_vmspace = &vmspace0;
316 
317 	p->p_addr = proc0paddr;				/* XXX */
318 
319 	/*
320 	 * We continue to place resource usage info in the
321 	 * user struct so they're pageable.
322 	 */
323 	p->p_stats = &p->p_addr->u_stats;
324 
325 	/*
326 	 * Charge root for one process.
327 	 */
328 	(void)chgproccnt(0, 1);
329 
330 	/* Initialize run queues */
331 	rqinit();
332 
333 	/* Configure the devices */
334 	cpu_configure();
335 
336 	/* Configure virtual memory system, set vm rlimits. */
337 	uvm_init_limits(p);
338 
339 	/* Initialize the file systems. */
340 #if defined(NFSSERVER) || defined(NFSCLIENT)
341 	nfs_init();			/* initialize server/shared data */
342 #endif
343 	vfsinit();
344 
345 	/* Start real time and statistics clocks. */
346 	initclocks();
347 
348 	/* Lock the kernel on behalf of proc0. */
349 	KERNEL_PROC_LOCK(p);
350 
351 #ifdef SYSVSHM
352 	/* Initialize System V style shared memory. */
353 	shminit();
354 #endif
355 
356 #ifdef SYSVSEM
357 	/* Initialize System V style semaphores. */
358 	seminit();
359 #endif
360 
361 #ifdef SYSVMSG
362 	/* Initialize System V style message queues. */
363 	msginit();
364 #endif
365 
366 	/* Attach pseudo-devices. */
367 	randomattach();
368 	for (pdev = pdevinit; pdev->pdev_attach != NULL; pdev++)
369 		if (pdev->pdev_count > 0)
370 			(*pdev->pdev_attach)(pdev->pdev_count);
371 
372 #ifdef CRYPTO
373 	swcr_init();
374 #endif /* CRYPTO */
375 
376 	/*
377 	 * Initialize protocols.  Block reception of incoming packets
378 	 * until everything is ready.
379 	 */
380 	s = splnet();
381 	ifinit();
382 	domaininit();
383 	if_attachdomain();
384 	splx(s);
385 
386 #ifdef GPROF
387 	/* Initialize kernel profiling. */
388 	kmstartup();
389 #endif
390 
391 #if !defined(NO_PROPOLICE)
392 	{
393 		volatile long newguard[8];
394 		int i;
395 
396 		arc4random_bytes((long *)newguard, sizeof(newguard));
397 
398 		for (i = sizeof(__guard)/sizeof(__guard[0]) - 1; i; i--)
399 			__guard[i] = newguard[i];
400 	}
401 #endif
402 
403 	/* init exec and emul */
404 	init_exec();
405 
406 	/* Start the scheduler */
407 	scheduler_start();
408 
409 	/*
410 	 * Create process 1 (init(8)).  We do this now, as Unix has
411 	 * historically had init be process 1, and changing this would
412 	 * probably upset a lot of people.
413 	 *
414 	 * Note that process 1 won't immediately exec init(8), but will
415 	 * wait for us to inform it that the root file system has been
416 	 * mounted.
417 	 */
418 	if (fork1(p, SIGCHLD, FORK_FORK, NULL, 0, start_init, NULL, NULL,
419 	    &initproc))
420 		panic("fork init");
421 
422 	/*
423 	 * Create any kernel threads whose creation was deferred because
424 	 * initproc had not yet been created.
425 	 */
426 	kthread_run_deferred_queue();
427 
428 	/*
429 	 * Now that device driver threads have been created, wait for
430 	 * them to finish any deferred autoconfiguration.  Note we don't
431 	 * need to lock this semaphore, since we haven't booted any
432 	 * secondary processors, yet.
433 	 */
434 	while (config_pending)
435 		(void) tsleep((void *)&config_pending, PWAIT, "cfpend", 0);
436 
437 	dostartuphooks();
438 
439 	/* Configure root/swap devices */
440 	if (md_diskconf)
441 		(*md_diskconf)();
442 
443 	/* Mount the root file system. */
444 	if (vfs_mountroot())
445 		panic("cannot mount root");
446 	CIRCLEQ_FIRST(&mountlist)->mnt_flag |= MNT_ROOTFS;
447 
448 	/* Get the vnode for '/'.  Set p->p_fd->fd_cdir to reference it. */
449 	if (VFS_ROOT(CIRCLEQ_FIRST(&mountlist), &rootvnode))
450 		panic("cannot find root vnode");
451 	p->p_fd->fd_cdir = rootvnode;
452 	VREF(p->p_fd->fd_cdir);
453 	VOP_UNLOCK(rootvnode, 0, p);
454 	p->p_fd->fd_rdir = NULL;
455 
456 	/*
457 	 * Now that root is mounted, we can fixup initproc's CWD
458 	 * info.  All other processes are kthreads, which merely
459 	 * share proc0's CWD info.
460 	 */
461 	initproc->p_fd->fd_cdir = rootvnode;
462 	VREF(initproc->p_fd->fd_cdir);
463 	initproc->p_fd->fd_rdir = NULL;
464 
465 	/*
466 	 * Now can look at time, having had a chance to verify the time
467 	 * from the file system.  Reset p->p_rtime as it may have been
468 	 * munched in mi_switch() after the time got set.
469 	 */
470 #ifdef __HAVE_TIMECOUNTER
471 	microtime(&boottime);
472 #else
473 	boottime = mono_time = time;
474 #endif
475 #ifndef __HAVE_CPUINFO
476 	microuptime(&runtime);
477 #endif
478 	LIST_FOREACH(p, &allproc, p_list) {
479 		p->p_stats->p_start = boottime;
480 #ifdef __HAVE_CPUINFO
481 		microuptime(&p->p_cpu->ci_schedstate.spc_runtime);
482 #endif
483 		p->p_rtime.tv_sec = p->p_rtime.tv_usec = 0;
484 	}
485 
486 	uvm_swap_init();
487 
488 	/* Create the pageout daemon kernel thread. */
489 	if (kthread_create(uvm_pageout, NULL, NULL, "pagedaemon"))
490 		panic("fork pagedaemon");
491 
492 	/* Create the reaper daemon kernel thread. */
493 	if (kthread_create(start_reaper, NULL, NULL, "reaper"))
494 		panic("fork reaper");
495 
496 	/* Create the cleaner daemon kernel thread. */
497 	if (kthread_create(start_cleaner, NULL, NULL, "cleaner"))
498 		panic("fork cleaner");
499 
500 	/* Create the update daemon kernel thread. */
501 	if (kthread_create(start_update, NULL, NULL, "update"))
502 		panic("fork update");
503 
504 	/* Create the aiodone daemon kernel thread. */
505 	if (kthread_create(uvm_aiodone_daemon, NULL, NULL, "aiodoned"))
506 		panic("fork aiodoned");
507 
508 #ifdef CRYPTO
509 	/* Create the crypto kernel thread. */
510 	if (kthread_create(start_crypto, NULL, NULL, "crypto"))
511 		panic("crypto thread");
512 #endif /* CRYPTO */
513 
514 	microtime(&rtv);
515 	srandom((u_long)(rtv.tv_sec ^ rtv.tv_usec));
516 
517 	randompid = 1;
518 
519 #if defined(MULTIPROCESSOR)
520 	/* Boot the secondary processors. */
521 	cpu_boot_secondary_processors();
522 #endif
523 
524 	domountroothooks();
525 
526 	/*
527 	 * Okay, now we can let init(8) exec!  It's off to userland!
528 	 */
529 	start_init_exec = 1;
530 	wakeup((void *)&start_init_exec);
531 
532 	/* The scheduler is an infinite loop. */
533 	uvm_scheduler();
534 	/* NOTREACHED */
535 }
536 
537 /*
538  * List of paths to try when searching for "init".
539  */
540 static char *initpaths[] = {
541 	"/sbin/init",
542 	"/sbin/oinit",
543 	"/sbin/init.bak",
544 	NULL,
545 };
546 
547 void
548 check_console(struct proc *p)
549 {
550 	struct nameidata nd;
551 	int error;
552 
553 	NDINIT(&nd, LOOKUP, FOLLOW, UIO_SYSSPACE, "/dev/console", p);
554 	error = namei(&nd);
555 	if (error) {
556 		if (error == ENOENT)
557 			printf("warning: /dev/console does not exist\n");
558 		else
559 			printf("warning: /dev/console error %d\n", error);
560 	} else
561 		vrele(nd.ni_vp);
562 }
563 
564 /*
565  * Start the initial user process; try exec'ing each pathname in "initpaths".
566  * The program is invoked with one argument containing the boot flags.
567  */
568 void
569 start_init(void *arg)
570 {
571 	struct proc *p = arg;
572 	vaddr_t addr;
573 	struct sys_execve_args /* {
574 		syscallarg(const char *) path;
575 		syscallarg(char *const *) argp;
576 		syscallarg(char *const *) envp;
577 	} */ args;
578 	int options, error;
579 	long i;
580 	register_t retval[2];
581 	char flags[4], *flagsp;
582 	char **pathp, *path, *ucp, **uap, *arg0, *arg1 = NULL;
583 
584 	/*
585 	 * Now in process 1.
586 	 */
587 
588 	/*
589 	 * Wait for main() to tell us that it's safe to exec.
590 	 */
591 	while (start_init_exec == 0)
592 		(void) tsleep((void *)&start_init_exec, PWAIT, "initexec", 0);
593 
594 	check_console(p);
595 
596 	/*
597 	 * Need just enough stack to hold the faked-up "execve()" arguments.
598 	 */
599 #ifdef MACHINE_STACK_GROWS_UP
600 	addr = USRSTACK;
601 #else
602 	addr = USRSTACK - PAGE_SIZE;
603 #endif
604 	if (uvm_map(&p->p_vmspace->vm_map, &addr, PAGE_SIZE,
605 	    NULL, UVM_UNKNOWN_OFFSET, 0,
606 	    UVM_MAPFLAG(UVM_PROT_RW, UVM_PROT_ALL, UVM_INH_COPY,
607 	    UVM_ADV_NORMAL, UVM_FLAG_FIXED|UVM_FLAG_OVERLAY|UVM_FLAG_COPYONW)))
608 		panic("init: couldn't allocate argument space");
609 	p->p_vmspace->vm_maxsaddr = (caddr_t)addr;
610 
611 	for (pathp = &initpaths[0]; (path = *pathp) != NULL; pathp++) {
612 #ifdef MACHINE_STACK_GROWS_UP
613 		ucp = (char *)addr;
614 #else
615 		ucp = (char *)(addr + PAGE_SIZE);
616 #endif
617 		/*
618 		 * Construct the boot flag argument.
619 		 */
620 		flagsp = flags;
621 		*flagsp++ = '-';
622 		options = 0;
623 
624 		if (boothowto & RB_SINGLE) {
625 			*flagsp++ = 's';
626 			options = 1;
627 		}
628 #ifdef notyet
629 		if (boothowto & RB_FASTBOOT) {
630 			*flagsp++ = 'f';
631 			options = 1;
632 		}
633 #endif
634 
635 		/*
636 		 * Move out the flags (arg 1), if necessary.
637 		 */
638 		if (options != 0) {
639 			*flagsp++ = '\0';
640 			i = flagsp - flags;
641 #ifdef DEBUG
642 			printf("init: copying out flags `%s' %d\n", flags, i);
643 #endif
644 #ifdef MACHINE_STACK_GROWS_UP
645 			arg1 = ucp;
646 			(void)copyout((caddr_t)flags, (caddr_t)ucp, i);
647 			ucp += i;
648 #else
649 			(void)copyout((caddr_t)flags, (caddr_t)(ucp -= i), i);
650 			arg1 = ucp;
651 #endif
652 		}
653 
654 		/*
655 		 * Move out the file name (also arg 0).
656 		 */
657 		i = strlen(path) + 1;
658 #ifdef DEBUG
659 		printf("init: copying out path `%s' %d\n", path, i);
660 #endif
661 #ifdef MACHINE_STACK_GROWS_UP
662 		arg0 = ucp;
663 		(void)copyout((caddr_t)path, (caddr_t)ucp, i);
664 		ucp += i;
665 		ucp = (caddr_t)ALIGN((u_long)ucp);
666 		uap = (char **)ucp + 3;
667 #else
668 		(void)copyout((caddr_t)path, (caddr_t)(ucp -= i), i);
669 		arg0 = ucp;
670 		uap = (char **)((u_long)ucp & ~ALIGNBYTES);
671 #endif
672 
673 		/*
674 		 * Move out the arg pointers.
675 		 */
676 		i = 0;
677 		copyout(&i, (caddr_t)--uap, sizeof(register_t)); /* terminator */
678 		if (options != 0)
679 			copyout(&arg1, (caddr_t)--uap, sizeof(register_t));
680 		copyout(&arg0, (caddr_t)--uap, sizeof(register_t));
681 
682 		/*
683 		 * Point at the arguments.
684 		 */
685 		SCARG(&args, path) = arg0;
686 		SCARG(&args, argp) = uap;
687 		SCARG(&args, envp) = NULL;
688 
689 		/*
690 		 * Now try to exec the program.  If can't for any reason
691 		 * other than it doesn't exist, complain.
692 		 */
693 		if ((error = sys_execve(p, &args, retval)) == 0) {
694 			KERNEL_PROC_UNLOCK(p);
695 			return;
696 		}
697 		if (error != ENOENT)
698 			printf("exec %s: error %d\n", path, error);
699 	}
700 	printf("init: not found\n");
701 	panic("no init");
702 }
703 
704 void
705 start_update(void *arg)
706 {
707 	sched_sync(curproc);
708 	/* NOTREACHED */
709 }
710 
711 void
712 start_cleaner(void *arg)
713 {
714 	buf_daemon(curproc);
715 	/* NOTREACHED */
716 }
717 
718 void
719 start_reaper(void *arg)
720 {
721 	reaper();
722 	/* NOTREACHED */
723 }
724 
725 #ifdef CRYPTO
726 void
727 start_crypto(void *arg)
728 {
729 	crypto_thread();
730 	/* NOTREACHED */
731 }
732 #endif /* CRYPTO */
733