xref: /openbsd-src/sys/kern/init_main.c (revision 11efff7f3ac2b3cfeff0c0cddc14294d9b3aca4f)
1 /*	$OpenBSD: init_main.c,v 1.122 2004/12/26 21:22:13 miod 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-2004 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(framep)
182 	void *framep;				/* XXX should go away */
183 {
184 	struct proc *p;
185 	struct pdevinit *pdev;
186 	struct timeval rtv;
187 	quad_t lim;
188 	int s, i;
189 	extern struct pdevinit pdevinit[];
190 	extern void scheduler_start(void);
191 	extern void disk_init(void);
192 	extern void endtsleep(void *);
193 	extern void realitexpire(void *);
194 
195 	/*
196 	 * Initialize the current process pointer (curproc) before
197 	 * any possible traps/probes to simplify trap processing.
198 	 */
199 	curproc = p = &proc0;
200 #ifdef __HAVE_CPUINFO
201 	p->p_cpu = curcpu();
202 #endif
203 
204 	/*
205 	 * Initialize timeouts.
206 	 */
207 	timeout_startup();
208 
209 	/*
210 	 * Attempt to find console and initialize
211 	 * in case of early panic or other messages.
212 	 */
213 	config_init();		/* init autoconfiguration data structures */
214 	consinit();
215 
216 	printf("%s\n", copyright);
217 
218 	KERNEL_LOCK_INIT();
219 
220 	uvm_init();
221 	disk_init();		/* must come before autoconfiguration */
222 	tty_init();		/* initialise tty's */
223 	cpu_startup();
224 
225 	/*
226 	 * Initialize mbuf's.  Do this now because we might attempt to
227 	 * allocate mbufs or mbuf clusters during autoconfiguration.
228 	 */
229 	mbinit();
230 
231 	/* Initalize sockets. */
232 	soinit();
233 
234 	/* Initialize sysctls (must be done before any processes run) */
235 	sysctl_init();
236 
237 	/*
238 	 * Initialize process and pgrp structures.
239 	 */
240 	procinit();
241 
242 	/* Initialize file locking. */
243 	lf_init();
244 
245 	/*
246 	 * Initialize filedescriptors.
247 	 */
248 	filedesc_init();
249 
250 	/*
251 	 * Initialize pipes.
252 	 */
253 	pipe_init();
254 
255 	/*
256 	 * Initialize kqueues.
257 	 */
258 	kqueue_init();
259 
260 	/*
261 	 * Create process 0 (the swapper).
262 	 */
263 	LIST_INSERT_HEAD(&allproc, p, p_list);
264 	p->p_pgrp = &pgrp0;
265 	LIST_INSERT_HEAD(PIDHASH(0), p, p_hash);
266 	LIST_INSERT_HEAD(PGRPHASH(0), &pgrp0, pg_hash);
267 	LIST_INIT(&pgrp0.pg_members);
268 	LIST_INSERT_HEAD(&pgrp0.pg_members, p, p_pglist);
269 
270 	pgrp0.pg_session = &session0;
271 	session0.s_count = 1;
272 	session0.s_leader = p;
273 
274 	p->p_flag = P_INMEM | P_SYSTEM | P_NOCLDWAIT;
275 	p->p_stat = SONPROC;
276 	p->p_nice = NZERO;
277 	p->p_emul = &emul_native;
278 	bcopy("swapper", p->p_comm, sizeof ("swapper"));
279 
280 	/* Init timeouts. */
281 	timeout_set(&p->p_sleep_to, endtsleep, p);
282 	timeout_set(&p->p_realit_to, realitexpire, p);
283 
284 	/* Create credentials. */
285 	cred0.p_refcnt = 1;
286 	p->p_cred = &cred0;
287 	p->p_ucred = crget();
288 	p->p_ucred->cr_ngroups = 1;	/* group 0 */
289 
290 	/* Initialize signal state for process 0. */
291 	signal_init();
292 	p->p_sigacts = &sigacts0;
293 	siginit(p);
294 
295 	/* Create the file descriptor table. */
296 	p->p_fd = fdinit(NULL);
297 
298 	/* Create the limits structures. */
299 	p->p_limit = &limit0;
300 	for (i = 0; i < sizeof(p->p_rlimit)/sizeof(p->p_rlimit[0]); i++)
301 		limit0.pl_rlimit[i].rlim_cur =
302 		    limit0.pl_rlimit[i].rlim_max = RLIM_INFINITY;
303 	limit0.pl_rlimit[RLIMIT_NOFILE].rlim_cur = NOFILE;
304 	limit0.pl_rlimit[RLIMIT_NOFILE].rlim_max = MIN(NOFILE_MAX,
305 	    (maxfiles - NOFILE > NOFILE) ?  maxfiles - NOFILE : NOFILE);
306 	limit0.pl_rlimit[RLIMIT_NPROC].rlim_cur = MAXUPRC;
307 	lim = ptoa(uvmexp.free);
308 	limit0.pl_rlimit[RLIMIT_RSS].rlim_max = lim;
309 	limit0.pl_rlimit[RLIMIT_MEMLOCK].rlim_max = lim;
310 	limit0.pl_rlimit[RLIMIT_MEMLOCK].rlim_cur = lim / 3;
311 	limit0.p_refcnt = 1;
312 
313 	/* Allocate a prototype map so we have something to fork. */
314 	uvmspace_init(&vmspace0, pmap_kernel(), round_page(VM_MIN_ADDRESS),
315 	    trunc_page(VM_MAX_ADDRESS), TRUE);
316 	p->p_vmspace = &vmspace0;
317 
318 	p->p_addr = proc0paddr;				/* XXX */
319 
320 	/*
321 	 * We continue to place resource usage info in the
322 	 * user struct so they're pageable.
323 	 */
324 	p->p_stats = &p->p_addr->u_stats;
325 
326 	/*
327 	 * Charge root for one process.
328 	 */
329 	(void)chgproccnt(0, 1);
330 
331 	/* Initialize run queues */
332 	rqinit();
333 
334 	/* Configure the devices */
335 	cpu_configure();
336 
337 	/* Configure virtual memory system, set vm rlimits. */
338 	uvm_init_limits(p);
339 
340 	/* Initialize the file systems. */
341 #if defined(NFSSERVER) || defined(NFSCLIENT)
342 	nfs_init();			/* initialize server/shared data */
343 #endif
344 	vfsinit();
345 
346 	/* Start real time and statistics clocks. */
347 	initclocks();
348 
349 	/* Lock the kernel on behalf of proc0. */
350 	KERNEL_PROC_LOCK(p);
351 
352 #ifdef SYSVSHM
353 	/* Initialize System V style shared memory. */
354 	shminit();
355 #endif
356 
357 #ifdef SYSVSEM
358 	/* Initialize System V style semaphores. */
359 	seminit();
360 #endif
361 
362 #ifdef SYSVMSG
363 	/* Initialize System V style message queues. */
364 	msginit();
365 #endif
366 
367 	/* Attach pseudo-devices. */
368 	randomattach();
369 	for (pdev = pdevinit; pdev->pdev_attach != NULL; pdev++)
370 		if (pdev->pdev_count > 0)
371 			(*pdev->pdev_attach)(pdev->pdev_count);
372 
373 #ifdef CRYPTO
374 	swcr_init();
375 #endif /* CRYPTO */
376 
377 	/*
378 	 * Initialize protocols.  Block reception of incoming packets
379 	 * until everything is ready.
380 	 */
381 	s = splimp();
382 	ifinit();
383 	domaininit();
384 	if_attachdomain();
385 	splx(s);
386 
387 #ifdef GPROF
388 	/* Initialize kernel profiling. */
389 	kmstartup();
390 #endif
391 
392 #if !defined(NO_PROPOLICE)
393 	arc4random_bytes(__guard, sizeof(__guard));
394 #endif
395 
396 	/* init exec and emul */
397 	init_exec();
398 
399 	/* Start the scheduler */
400 	scheduler_start();
401 
402 	/*
403 	 * Create process 1 (init(8)).  We do this now, as Unix has
404 	 * historically had init be process 1, and changing this would
405 	 * probably upset a lot of people.
406 	 *
407 	 * Note that process 1 won't immediately exec init(8), but will
408 	 * wait for us to inform it that the root file system has been
409 	 * mounted.
410 	 */
411 	if (fork1(p, SIGCHLD, FORK_FORK, NULL, 0, start_init, NULL, NULL,
412 	    &initproc))
413 		panic("fork init");
414 
415 	/*
416 	 * Create any kernel threads who's creation was deferred because
417 	 * initproc had not yet been created.
418 	 */
419 	kthread_run_deferred_queue();
420 
421 	/*
422 	 * Now that device driver threads have been created, wait for
423 	 * them to finish any deferred autoconfiguration.  Note we don't
424 	 * need to lock this semaphore, since we haven't booted any
425 	 * secondary processors, yet.
426 	 */
427 	while (config_pending)
428 		(void) tsleep((void *)&config_pending, PWAIT, "cfpend", 0);
429 
430 	dostartuphooks();
431 
432 	/* Configure root/swap devices */
433 	if (md_diskconf)
434 		(*md_diskconf)();
435 
436 	/* Mount the root file system. */
437 	if (vfs_mountroot())
438 		panic("cannot mount root");
439 	CIRCLEQ_FIRST(&mountlist)->mnt_flag |= MNT_ROOTFS;
440 
441 	/* Get the vnode for '/'.  Set p->p_fd->fd_cdir to reference it. */
442 	if (VFS_ROOT(CIRCLEQ_FIRST(&mountlist), &rootvnode))
443 		panic("cannot find root vnode");
444 	p->p_fd->fd_cdir = rootvnode;
445 	VREF(p->p_fd->fd_cdir);
446 	VOP_UNLOCK(rootvnode, 0, p);
447 	p->p_fd->fd_rdir = NULL;
448 
449 	/*
450 	 * Now that root is mounted, we can fixup initproc's CWD
451 	 * info.  All other processes are kthreads, which merely
452 	 * share proc0's CWD info.
453 	 */
454 	initproc->p_fd->fd_cdir = rootvnode;
455 	VREF(initproc->p_fd->fd_cdir);
456 	initproc->p_fd->fd_rdir = NULL;
457 
458 	/*
459 	 * Now can look at time, having had a chance to verify the time
460 	 * from the file system.  Reset p->p_rtime as it may have been
461 	 * munched in mi_switch() after the time got set.
462 	 */
463 #ifdef __HAVE_TIMECOUNTER
464 	microtime(&boottime);
465 #else
466 	boottime = mono_time = time;
467 #endif
468 #ifndef __HAVE_CPUINFO
469 	microuptime(&runtime);
470 #endif
471 	LIST_FOREACH(p, &allproc, p_list) {
472 		p->p_stats->p_start = boottime;
473 #ifdef __HAVE_CPUINFO
474 		microuptime(&p->p_cpu->ci_schedstate.spc_runtime);
475 #endif
476 		p->p_rtime.tv_sec = p->p_rtime.tv_usec = 0;
477 	}
478 
479 	uvm_swap_init();
480 
481 	/* Create the pageout daemon kernel thread. */
482 	if (kthread_create(uvm_pageout, NULL, NULL, "pagedaemon"))
483 		panic("fork pagedaemon");
484 
485 	/* Create the reaper daemon kernel thread. */
486 	if (kthread_create(start_reaper, NULL, NULL, "reaper"))
487 		panic("fork reaper");
488 
489 	/* Create the cleaner daemon kernel thread. */
490 	if (kthread_create(start_cleaner, NULL, NULL, "cleaner"))
491 		panic("fork cleaner");
492 
493 	/* Create the update daemon kernel thread. */
494 	if (kthread_create(start_update, NULL, NULL, "update"))
495 		panic("fork update");
496 
497 	/* Create the aiodone daemon kernel thread. */
498 	if (kthread_create(uvm_aiodone_daemon, NULL, NULL, "aiodoned"))
499 		panic("fork aiodoned");
500 
501 #ifdef CRYPTO
502 	/* Create the crypto kernel thread. */
503 	if (kthread_create(start_crypto, NULL, NULL, "crypto"))
504 		panic("crypto thread");
505 #endif /* CRYPTO */
506 
507 	microtime(&rtv);
508 	srandom((u_long)(rtv.tv_sec ^ rtv.tv_usec));
509 
510 	randompid = 1;
511 
512 #if defined(MULTIPROCESSOR)
513 	/* Boot the secondary processors. */
514 	cpu_boot_secondary_processors();
515 #endif
516 
517 	domountroothooks();
518 
519 	/*
520 	 * Okay, now we can let init(8) exec!  It's off to userland!
521 	 */
522 	start_init_exec = 1;
523 	wakeup((void *)&start_init_exec);
524 
525 	/* The scheduler is an infinite loop. */
526 	uvm_scheduler();
527 	/* NOTREACHED */
528 }
529 
530 /*
531  * List of paths to try when searching for "init".
532  */
533 static char *initpaths[] = {
534 	"/sbin/init",
535 	"/sbin/oinit",
536 	"/sbin/init.bak",
537 	NULL,
538 };
539 
540 void
541 check_console(p)
542 	struct proc *p;
543 {
544 	struct nameidata nd;
545 	int error;
546 
547 	NDINIT(&nd, LOOKUP, FOLLOW, UIO_SYSSPACE, "/dev/console", p);
548 	error = namei(&nd);
549 	if (error) {
550 		if (error == ENOENT)
551 			printf("warning: /dev/console does not exist\n");
552 		else
553 			printf("warning: /dev/console error %d\n", error);
554 	} else
555 		vrele(nd.ni_vp);
556 }
557 
558 /*
559  * Start the initial user process; try exec'ing each pathname in "initpaths".
560  * The program is invoked with one argument containing the boot flags.
561  */
562 void
563 start_init(arg)
564 	void *arg;
565 {
566 	struct proc *p = arg;
567 	vaddr_t addr;
568 	struct sys_execve_args /* {
569 		syscallarg(const char *) path;
570 		syscallarg(char *const *) argp;
571 		syscallarg(char *const *) envp;
572 	} */ args;
573 	int options, error;
574 	long i;
575 	register_t retval[2];
576 	char flags[4], *flagsp;
577 	char **pathp, *path, *ucp, **uap, *arg0, *arg1 = NULL;
578 
579 	/*
580 	 * Now in process 1.
581 	 */
582 
583 	/*
584 	 * Wait for main() to tell us that it's safe to exec.
585 	 */
586 	while (start_init_exec == 0)
587 		(void) tsleep((void *)&start_init_exec, PWAIT, "initexec", 0);
588 
589 	check_console(p);
590 
591 	/*
592 	 * Need just enough stack to hold the faked-up "execve()" arguments.
593 	 */
594 #ifdef MACHINE_STACK_GROWS_UP
595 	addr = USRSTACK;
596 #else
597 	addr = USRSTACK - PAGE_SIZE;
598 #endif
599 	if (uvm_map(&p->p_vmspace->vm_map, &addr, PAGE_SIZE,
600 	    NULL, UVM_UNKNOWN_OFFSET, 0,
601 	    UVM_MAPFLAG(UVM_PROT_RW, UVM_PROT_ALL, UVM_INH_COPY,
602 	    UVM_ADV_NORMAL, UVM_FLAG_FIXED|UVM_FLAG_OVERLAY|UVM_FLAG_COPYONW)))
603 		panic("init: couldn't allocate argument space");
604 	p->p_vmspace->vm_maxsaddr = (caddr_t)addr;
605 
606 	for (pathp = &initpaths[0]; (path = *pathp) != NULL; pathp++) {
607 #ifdef MACHINE_STACK_GROWS_UP
608 		ucp = (char *)addr;
609 #else
610 		ucp = (char *)(addr + PAGE_SIZE);
611 #endif
612 		/*
613 		 * Construct the boot flag argument.
614 		 */
615 		flagsp = flags;
616 		*flagsp++ = '-';
617 		options = 0;
618 
619 		if (boothowto & RB_SINGLE) {
620 			*flagsp++ = 's';
621 			options = 1;
622 		}
623 #ifdef notyet
624 		if (boothowto & RB_FASTBOOT) {
625 			*flagsp++ = 'f';
626 			options = 1;
627 		}
628 #endif
629 
630 		/*
631 		 * Move out the flags (arg 1), if necessary.
632 		 */
633 		if (options != 0) {
634 			*flagsp++ = '\0';
635 			i = flagsp - flags;
636 #ifdef DEBUG
637 			printf("init: copying out flags `%s' %d\n", flags, i);
638 #endif
639 #ifdef MACHINE_STACK_GROWS_UP
640 			arg1 = ucp;
641 			(void)copyout((caddr_t)flags, (caddr_t)ucp, i);
642 			ucp += i;
643 #else
644 			(void)copyout((caddr_t)flags, (caddr_t)(ucp -= i), i);
645 			arg1 = ucp;
646 #endif
647 		}
648 
649 		/*
650 		 * Move out the file name (also arg 0).
651 		 */
652 		i = strlen(path) + 1;
653 #ifdef DEBUG
654 		printf("init: copying out path `%s' %d\n", path, i);
655 #endif
656 #ifdef MACHINE_STACK_GROWS_UP
657 		arg0 = ucp;
658 		(void)copyout((caddr_t)path, (caddr_t)ucp, i);
659 		ucp += i;
660 		ucp = (caddr_t)ALIGN((u_long)ucp);
661 		uap = (char **)ucp + 3;
662 #else
663 		(void)copyout((caddr_t)path, (caddr_t)(ucp -= i), i);
664 		arg0 = ucp;
665 		uap = (char **)((u_long)ucp & ~ALIGNBYTES);
666 #endif
667 
668 		/*
669 		 * Move out the arg pointers.
670 		 */
671 		i = 0;
672 		copyout(&i, (caddr_t)--uap, sizeof(register_t)); /* terminator */
673 		if (options != 0)
674 			copyout(&arg1, (caddr_t)--uap, sizeof(register_t));
675 		copyout(&arg0, (caddr_t)--uap, sizeof(register_t));
676 
677 		/*
678 		 * Point at the arguments.
679 		 */
680 		SCARG(&args, path) = arg0;
681 		SCARG(&args, argp) = uap;
682 		SCARG(&args, envp) = NULL;
683 
684 		/*
685 		 * Now try to exec the program.  If can't for any reason
686 		 * other than it doesn't exist, complain.
687 		 */
688 		if ((error = sys_execve(p, &args, retval)) == 0) {
689 			KERNEL_PROC_UNLOCK(p);
690 			return;
691 		}
692 		if (error != ENOENT)
693 			printf("exec %s: error %d\n", path, error);
694 	}
695 	printf("init: not found\n");
696 	panic("no init");
697 }
698 
699 void
700 start_update(arg)
701 	void *arg;
702 {
703 	sched_sync(curproc);
704 	/* NOTREACHED */
705 }
706 
707 void
708 start_cleaner(arg)
709 	void *arg;
710 {
711 	buf_daemon(curproc);
712 	/* NOTREACHED */
713 }
714 
715 void
716 start_reaper(arg)
717 	void *arg;
718 {
719 	reaper();
720 	/* NOTREACHED */
721 }
722 
723 #ifdef CRYPTO
724 void
725 start_crypto(arg)
726 	void *arg;
727 {
728 	crypto_thread();
729 	/* NOTREACHED */
730 }
731 #endif /* CRYPTO */
732