blob: 576e1689a917fc9bbdd5a6e69d125b3d428f2e29 [file] [log] [blame]
l.yangb8fdece2024-10-10 14:56:17 +08001// SPDX-License-Identifier: GPL-2.0-only
2/*
3 * linux/init/main.c
4 *
5 * Copyright (C) 1991, 1992 Linus Torvalds
6 *
7 * GK 2/5/95 - Changed to support mounting root fs via NFS
8 * Added initrd & change_root: Werner Almesberger & Hans Lermen, Feb '96
9 * Moan early if gcc is old, avoiding bogus kernels - Paul Gortmaker, May '96
10 * Simplified starting of init: Michael A. Griffith <grif@acm.org>
11 */
12
13#define DEBUG /* Enable initcall_debug */
14
15#include <linux/types.h>
16#include <linux/extable.h>
17#include <linux/module.h>
18#include <linux/proc_fs.h>
19#include <linux/binfmts.h>
20#include <linux/kernel.h>
21#include <linux/syscalls.h>
22#include <linux/stackprotector.h>
23#include <linux/string.h>
24#include <linux/ctype.h>
25#include <linux/delay.h>
26#include <linux/ioport.h>
27#include <linux/init.h>
28#include <linux/initrd.h>
29#include <linux/memblock.h>
30#include <linux/acpi.h>
31#include <linux/bootconfig.h>
32#include <linux/console.h>
33#include <linux/nmi.h>
34#include <linux/percpu.h>
35#include <linux/kmod.h>
36#include <linux/kprobes.h>
37#include <linux/vmalloc.h>
38#include <linux/kernel_stat.h>
39#include <linux/start_kernel.h>
40#include <linux/security.h>
41#include <linux/smp.h>
42#include <linux/profile.h>
43#include <linux/rcupdate.h>
44#include <linux/moduleparam.h>
45#include <linux/kallsyms.h>
46#include <linux/writeback.h>
47#include <linux/cpu.h>
48#include <linux/cpuset.h>
49#include <linux/cgroup.h>
50#include <linux/efi.h>
51#include <linux/tick.h>
52#include <linux/sched/isolation.h>
53#include <linux/interrupt.h>
54#include <linux/taskstats_kern.h>
55#include <linux/delayacct.h>
56#include <linux/unistd.h>
57#include <linux/utsname.h>
58#include <linux/rmap.h>
59#include <linux/mempolicy.h>
60#include <linux/key.h>
61#include <linux/buffer_head.h>
62#include <linux/page_ext.h>
63#include <linux/debug_locks.h>
64#include <linux/debugobjects.h>
65#include <linux/lockdep.h>
66#include <linux/kmemleak.h>
67#include <linux/padata.h>
68#include <linux/pid_namespace.h>
69#include <linux/device/driver.h>
70#include <linux/kthread.h>
71#include <linux/sched.h>
72#include <linux/sched/init.h>
73#include <linux/signal.h>
74#include <linux/idr.h>
75#include <linux/kgdb.h>
76#include <linux/ftrace.h>
77#include <linux/async.h>
78#include <linux/sfi.h>
79#include <linux/shmem_fs.h>
80#include <linux/slab.h>
81#include <linux/perf_event.h>
82#include <linux/ptrace.h>
83#include <linux/pti.h>
84#include <linux/blkdev.h>
85#include <linux/elevator.h>
86#include <linux/sched/clock.h>
87#include <linux/sched/task.h>
88#include <linux/sched/task_stack.h>
89#include <linux/context_tracking.h>
90#include <linux/random.h>
91#include <linux/list.h>
92#include <linux/integrity.h>
93#include <linux/proc_ns.h>
94#include <linux/io.h>
95#include <linux/cache.h>
96#include <linux/rodata_test.h>
97#include <linux/jump_label.h>
98#include <linux/mem_encrypt.h>
99#include <linux/kcsan.h>
100#include <linux/init_syscalls.h>
101
102#include <asm/io.h>
103#include <asm/bugs.h>
104#include <asm/setup.h>
105#include <asm/sections.h>
106#include <asm/cacheflush.h>
107
108#define CREATE_TRACE_POINTS
109#include <trace/events/initcall.h>
110
111#include <kunit/test.h>
112
113#ifdef CONFIG_FLAGS_UTILS
114#include <linux/reboot.h>
115#include "pub_flags.h"
116#endif
117
118static int kernel_init(void *);
119
120extern void init_IRQ(void);
121extern void radix_tree_init(void);
122
123/*
124 * Debug helper: via this flag we know that we are in 'early bootup code'
125 * where only the boot processor is running with IRQ disabled. This means
126 * two things - IRQ must not be enabled before the flag is cleared and some
127 * operations which are not allowed with IRQ disabled are allowed while the
128 * flag is set.
129 */
130bool early_boot_irqs_disabled __read_mostly;
131
132enum system_states system_state __read_mostly;
133EXPORT_SYMBOL(system_state);
134
135/*
136 * Boot command-line arguments
137 */
138#define MAX_INIT_ARGS CONFIG_INIT_ENV_ARG_LIMIT
139#define MAX_INIT_ENVS CONFIG_INIT_ENV_ARG_LIMIT
140
141extern void time_init(void);
142/* Default late time init is NULL. archs can override this later. */
143void (*__initdata late_time_init)(void);
144
145/* Untouched command line saved by arch-specific code. */
146char __initdata boot_command_line[COMMAND_LINE_SIZE];
147/* Untouched saved command line (eg. for /proc) */
148char *saved_command_line;
149/* Command line for parameter parsing */
150static char *static_command_line;
151/* Untouched extra command line */
152static char *extra_command_line;
153/* Extra init arguments */
154static char *extra_init_args;
155
156#ifdef CONFIG_BOOT_CONFIG
157/* Is bootconfig on command line? */
158static bool bootconfig_found;
159static bool initargs_found;
160#else
161# define bootconfig_found false
162# define initargs_found false
163#endif
164
165static char *execute_command;
166static char *ramdisk_execute_command = "/init";
167
168/*
169 * Used to generate warnings if static_key manipulation functions are used
170 * before jump_label_init is called.
171 */
172bool static_key_initialized __read_mostly;
173EXPORT_SYMBOL_GPL(static_key_initialized);
174
175/*
176 * If set, this is an indication to the drivers that reset the underlying
177 * device before going ahead with the initialization otherwise driver might
178 * rely on the BIOS and skip the reset operation.
179 *
180 * This is useful if kernel is booting in an unreliable environment.
181 * For ex. kdump situation where previous kernel has crashed, BIOS has been
182 * skipped and devices will be in unknown state.
183 */
184unsigned int reset_devices;
185EXPORT_SYMBOL(reset_devices);
186
187static int __init set_reset_devices(char *str)
188{
189 reset_devices = 1;
190 return 1;
191}
192
193__setup("reset_devices", set_reset_devices);
194
195static const char *argv_init[MAX_INIT_ARGS+2] = { "init", NULL, };
196const char *envp_init[MAX_INIT_ENVS+2] = { "HOME=/", "TERM=linux", NULL, };
197static const char *panic_later, *panic_param;
198
199extern const struct obs_kernel_param __setup_start[], __setup_end[];
200
201static bool __init obsolete_checksetup(char *line)
202{
203 const struct obs_kernel_param *p;
204 bool had_early_param = false;
205
206 p = __setup_start;
207 do {
208 int n = strlen(p->str);
209 if (parameqn(line, p->str, n)) {
210 if (p->early) {
211 /* Already done in parse_early_param?
212 * (Needs exact match on param part).
213 * Keep iterating, as we can have early
214 * params and __setups of same names 8( */
215 if (line[n] == '\0' || line[n] == '=')
216 had_early_param = true;
217 } else if (!p->setup_func) {
218 pr_warn("Parameter %s is obsolete, ignored\n",
219 p->str);
220 return true;
221 } else if (p->setup_func(line + n))
222 return true;
223 }
224 p++;
225 } while (p < __setup_end);
226
227 return had_early_param;
228}
229
230/*
231 * This should be approx 2 Bo*oMips to start (note initial shift), and will
232 * still work even if initially too large, it will just take slightly longer
233 */
234unsigned long loops_per_jiffy = (1<<12);
235EXPORT_SYMBOL(loops_per_jiffy);
236
237static int __init debug_kernel(char *str)
238{
239 console_loglevel = CONSOLE_LOGLEVEL_DEBUG;
240 return 0;
241}
242
243static int __init quiet_kernel(char *str)
244{
245 console_loglevel = CONSOLE_LOGLEVEL_QUIET;
246 return 0;
247}
248
249early_param("debug", debug_kernel);
250early_param("quiet", quiet_kernel);
251
252static int __init loglevel(char *str)
253{
254 int newlevel;
255
256 /*
257 * Only update loglevel value when a correct setting was passed,
258 * to prevent blind crashes (when loglevel being set to 0) that
259 * are quite hard to debug
260 */
261 if (get_option(&str, &newlevel)) {
262 console_loglevel = newlevel;
263 return 0;
264 }
265
266 return -EINVAL;
267}
268
269early_param("loglevel", loglevel);
270
271#ifdef CONFIG_BLK_DEV_INITRD
272static void * __init get_boot_config_from_initrd(u32 *_size, u32 *_csum)
273{
274 u32 size, csum;
275 char *data;
276 u32 *hdr;
277 int i;
278
279 if (!initrd_end)
280 return NULL;
281
282 data = (char *)initrd_end - BOOTCONFIG_MAGIC_LEN;
283 /*
284 * Since Grub may align the size of initrd to 4, we must
285 * check the preceding 3 bytes as well.
286 */
287 for (i = 0; i < 4; i++) {
288 if (!memcmp(data, BOOTCONFIG_MAGIC, BOOTCONFIG_MAGIC_LEN))
289 goto found;
290 data--;
291 }
292 return NULL;
293
294found:
295 hdr = (u32 *)(data - 8);
296 size = le32_to_cpu(hdr[0]);
297 csum = le32_to_cpu(hdr[1]);
298
299 data = ((void *)hdr) - size;
300 if ((unsigned long)data < initrd_start) {
301 pr_err("bootconfig size %d is greater than initrd size %ld\n",
302 size, initrd_end - initrd_start);
303 return NULL;
304 }
305
306 /* Remove bootconfig from initramfs/initrd */
307 initrd_end = (unsigned long)data;
308 if (_size)
309 *_size = size;
310 if (_csum)
311 *_csum = csum;
312
313 return data;
314}
315#else
316static void * __init get_boot_config_from_initrd(u32 *_size, u32 *_csum)
317{
318 return NULL;
319}
320#endif
321
322#ifdef CONFIG_BOOT_CONFIG
323
324static char xbc_namebuf[XBC_KEYLEN_MAX] __initdata;
325
326#define rest(dst, end) ((end) > (dst) ? (end) - (dst) : 0)
327
328static int __init xbc_snprint_cmdline(char *buf, size_t size,
329 struct xbc_node *root)
330{
331 struct xbc_node *knode, *vnode;
332 char *end = buf + size;
333 const char *val;
334 int ret;
335
336 xbc_node_for_each_key_value(root, knode, val) {
337 ret = xbc_node_compose_key_after(root, knode,
338 xbc_namebuf, XBC_KEYLEN_MAX);
339 if (ret < 0)
340 return ret;
341
342 vnode = xbc_node_get_child(knode);
343 if (!vnode) {
344 ret = snprintf(buf, rest(buf, end), "%s ", xbc_namebuf);
345 if (ret < 0)
346 return ret;
347 buf += ret;
348 continue;
349 }
350 xbc_array_for_each_value(vnode, val) {
351 ret = snprintf(buf, rest(buf, end), "%s=\"%s\" ",
352 xbc_namebuf, val);
353 if (ret < 0)
354 return ret;
355 buf += ret;
356 }
357 }
358
359 return buf - (end - size);
360}
361#undef rest
362
363/* Make an extra command line under given key word */
364static char * __init xbc_make_cmdline(const char *key)
365{
366 struct xbc_node *root;
367 char *new_cmdline;
368 int ret, len = 0;
369
370 root = xbc_find_node(key);
371 if (!root)
372 return NULL;
373
374 /* Count required buffer size */
375 len = xbc_snprint_cmdline(NULL, 0, root);
376 if (len <= 0)
377 return NULL;
378
379 new_cmdline = memblock_alloc(len + 1, SMP_CACHE_BYTES);
380 if (!new_cmdline) {
381 pr_err("Failed to allocate memory for extra kernel cmdline.\n");
382 return NULL;
383 }
384
385 ret = xbc_snprint_cmdline(new_cmdline, len + 1, root);
386 if (ret < 0 || ret > len) {
387 pr_err("Failed to print extra kernel cmdline.\n");
388 memblock_free(__pa(new_cmdline), len + 1);
389 return NULL;
390 }
391
392 return new_cmdline;
393}
394
395static u32 boot_config_checksum(unsigned char *p, u32 size)
396{
397 u32 ret = 0;
398
399 while (size--)
400 ret += *p++;
401
402 return ret;
403}
404
405static int __init bootconfig_params(char *param, char *val,
406 const char *unused, void *arg)
407{
408 if (strcmp(param, "bootconfig") == 0) {
409 bootconfig_found = true;
410 }
411 return 0;
412}
413
414static void __init setup_boot_config(const char *cmdline)
415{
416 static char tmp_cmdline[COMMAND_LINE_SIZE] __initdata;
417 const char *msg;
418 int pos;
419 u32 size, csum;
420 char *data, *copy, *err;
421 int ret;
422
423 /* Cut out the bootconfig data even if we have no bootconfig option */
424 data = get_boot_config_from_initrd(&size, &csum);
425
426 strlcpy(tmp_cmdline, boot_command_line, COMMAND_LINE_SIZE);
427 err = parse_args("bootconfig", tmp_cmdline, NULL, 0, 0, 0, NULL,
428 bootconfig_params);
429
430 if (IS_ERR(err) || !bootconfig_found)
431 return;
432
433 /* parse_args() stops at '--' and returns an address */
434 if (err)
435 initargs_found = true;
436
437 if (!data) {
438 pr_err("'bootconfig' found on command line, but no bootconfig found\n");
439 return;
440 }
441
442 if (size >= XBC_DATA_MAX) {
443 pr_err("bootconfig size %d greater than max size %d\n",
444 size, XBC_DATA_MAX);
445 return;
446 }
447
448 if (boot_config_checksum((unsigned char *)data, size) != csum) {
449 pr_err("bootconfig checksum failed\n");
450 return;
451 }
452
453 copy = memblock_alloc(size + 1, SMP_CACHE_BYTES);
454 if (!copy) {
455 pr_err("Failed to allocate memory for bootconfig\n");
456 return;
457 }
458
459 memcpy(copy, data, size);
460 copy[size] = '\0';
461
462 ret = xbc_init(copy, &msg, &pos);
463 if (ret < 0) {
464 if (pos < 0)
465 pr_err("Failed to init bootconfig: %s.\n", msg);
466 else
467 pr_err("Failed to parse bootconfig: %s at %d.\n",
468 msg, pos);
469 } else {
470 pr_info("Load bootconfig: %d bytes %d nodes\n", size, ret);
471 /* keys starting with "kernel." are passed via cmdline */
472 extra_command_line = xbc_make_cmdline("kernel");
473 /* Also, "init." keys are init arguments */
474 extra_init_args = xbc_make_cmdline("init");
475 }
476 return;
477}
478
479#else
480
481static void __init setup_boot_config(const char *cmdline)
482{
483 /* Remove bootconfig data from initrd */
484 get_boot_config_from_initrd(NULL, NULL);
485}
486
487static int __init warn_bootconfig(char *str)
488{
489 pr_warn("WARNING: 'bootconfig' found on the kernel command line but CONFIG_BOOT_CONFIG is not set.\n");
490 return 0;
491}
492early_param("bootconfig", warn_bootconfig);
493
494#endif
495
496/* Change NUL term back to "=", to make "param" the whole string. */
497static void __init repair_env_string(char *param, char *val)
498{
499 if (val) {
500 /* param=val or param="val"? */
501 if (val == param+strlen(param)+1)
502 val[-1] = '=';
503 else if (val == param+strlen(param)+2) {
504 val[-2] = '=';
505 memmove(val-1, val, strlen(val)+1);
506 } else
507 BUG();
508 }
509}
510
511/* Anything after -- gets handed straight to init. */
512static int __init set_init_arg(char *param, char *val,
513 const char *unused, void *arg)
514{
515 unsigned int i;
516
517 if (panic_later)
518 return 0;
519
520 repair_env_string(param, val);
521
522 for (i = 0; argv_init[i]; i++) {
523 if (i == MAX_INIT_ARGS) {
524 panic_later = "init";
525 panic_param = param;
526 return 0;
527 }
528 }
529 argv_init[i] = param;
530 return 0;
531}
532
533/*
534 * Unknown boot options get handed to init, unless they look like
535 * unused parameters (modprobe will find them in /proc/cmdline).
536 */
537static int __init unknown_bootoption(char *param, char *val,
538 const char *unused, void *arg)
539{
540 size_t len = strlen(param);
541
542 repair_env_string(param, val);
543
544 /* Handle obsolete-style parameters */
545 if (obsolete_checksetup(param))
546 return 0;
547
548 /* Unused module parameter. */
549 if (strnchr(param, len, '.'))
550 return 0;
551
552 if (panic_later)
553 return 0;
554
555 if (val) {
556 /* Environment option */
557 unsigned int i;
558 for (i = 0; envp_init[i]; i++) {
559 if (i == MAX_INIT_ENVS) {
560 panic_later = "env";
561 panic_param = param;
562 }
563 if (!strncmp(param, envp_init[i], len+1))
564 break;
565 }
566 envp_init[i] = param;
567 } else {
568 /* Command line option */
569 unsigned int i;
570 for (i = 0; argv_init[i]; i++) {
571 if (i == MAX_INIT_ARGS) {
572 panic_later = "init";
573 panic_param = param;
574 }
575 }
576 argv_init[i] = param;
577 }
578 return 0;
579}
580
581static int __init init_setup(char *str)
582{
583 unsigned int i;
584
585 execute_command = str;
586 /*
587 * In case LILO is going to boot us with default command line,
588 * it prepends "auto" before the whole cmdline which makes
589 * the shell think it should execute a script with such name.
590 * So we ignore all arguments entered _before_ init=... [MJ]
591 */
592 for (i = 1; i < MAX_INIT_ARGS; i++)
593 argv_init[i] = NULL;
594 return 1;
595}
596__setup("init=", init_setup);
597
598static int __init rdinit_setup(char *str)
599{
600 unsigned int i;
601
602 ramdisk_execute_command = str;
603 /* See "auto" comment in init_setup */
604 for (i = 1; i < MAX_INIT_ARGS; i++)
605 argv_init[i] = NULL;
606 return 1;
607}
608__setup("rdinit=", rdinit_setup);
609
610#ifndef CONFIG_SMP
611static const unsigned int setup_max_cpus = NR_CPUS;
612static inline void setup_nr_cpu_ids(void) { }
613static inline void smp_prepare_cpus(unsigned int maxcpus) { }
614#endif
615
616/*
617 * We need to store the untouched command line for future reference.
618 * We also need to store the touched command line since the parameter
619 * parsing is performed in place, and we should allow a component to
620 * store reference of name/value for future reference.
621 */
622static void __init setup_command_line(char *command_line)
623{
624 size_t len, xlen = 0, ilen = 0;
625
626 if (extra_command_line)
627 xlen = strlen(extra_command_line);
628 if (extra_init_args)
629 ilen = strlen(extra_init_args) + 4; /* for " -- " */
630
631 len = xlen + strlen(boot_command_line) + 1;
632
633 saved_command_line = memblock_alloc(len + ilen, SMP_CACHE_BYTES);
634 if (!saved_command_line)
635 panic("%s: Failed to allocate %zu bytes\n", __func__, len + ilen);
636
637 static_command_line = memblock_alloc(len, SMP_CACHE_BYTES);
638 if (!static_command_line)
639 panic("%s: Failed to allocate %zu bytes\n", __func__, len);
640
641 if (xlen) {
642 /*
643 * We have to put extra_command_line before boot command
644 * lines because there could be dashes (separator of init
645 * command line) in the command lines.
646 */
647 strcpy(saved_command_line, extra_command_line);
648 strcpy(static_command_line, extra_command_line);
649 }
650 strcpy(saved_command_line + xlen, boot_command_line);
651 strcpy(static_command_line + xlen, command_line);
652
653 if (ilen) {
654 /*
655 * Append supplemental init boot args to saved_command_line
656 * so that user can check what command line options passed
657 * to init.
658 */
659 len = strlen(saved_command_line);
660 if (initargs_found) {
661 saved_command_line[len++] = ' ';
662 } else {
663 strcpy(saved_command_line + len, " -- ");
664 len += 4;
665 }
666
667 strcpy(saved_command_line + len, extra_init_args);
668 }
669}
670
671/*
672 * We need to finalize in a non-__init function or else race conditions
673 * between the root thread and the init thread may cause start_kernel to
674 * be reaped by free_initmem before the root thread has proceeded to
675 * cpu_idle.
676 *
677 * gcc-3.4 accidentally inlines this function, so use noinline.
678 */
679
680static __initdata DECLARE_COMPLETION(kthreadd_done);
681
682noinline void __ref rest_init(void)
683{
684 struct task_struct *tsk;
685 int pid;
686
687 rcu_scheduler_starting();
688 /*
689 * We need to spawn init first so that it obtains pid 1, however
690 * the init task will end up wanting to create kthreads, which, if
691 * we schedule it before we create kthreadd, will OOPS.
692 */
693 pid = kernel_thread(kernel_init, NULL, CLONE_FS);
694 /*
695 * Pin init on the boot CPU. Task migration is not properly working
696 * until sched_init_smp() has been run. It will set the allowed
697 * CPUs for init to the non isolated CPUs.
698 */
699 rcu_read_lock();
700 tsk = find_task_by_pid_ns(pid, &init_pid_ns);
701 set_cpus_allowed_ptr(tsk, cpumask_of(smp_processor_id()));
702 rcu_read_unlock();
703
704 numa_default_policy();
705 pid = kernel_thread(kthreadd, NULL, CLONE_FS | CLONE_FILES);
706 rcu_read_lock();
707 kthreadd_task = find_task_by_pid_ns(pid, &init_pid_ns);
708 rcu_read_unlock();
709
710 /*
711 * Enable might_sleep() and smp_processor_id() checks.
712 * They cannot be enabled earlier because with CONFIG_PREEMPTION=y
713 * kernel_thread() would trigger might_sleep() splats. With
714 * CONFIG_PREEMPT_VOLUNTARY=y the init task might have scheduled
715 * already, but it's stuck on the kthreadd_done completion.
716 */
717 system_state = SYSTEM_SCHEDULING;
718
719 complete(&kthreadd_done);
720
721 /*
722 * The boot idle thread must execute schedule()
723 * at least once to get things moving:
724 */
725 schedule_preempt_disabled();
726 /* Call into cpu_idle with preempt disabled */
727 cpu_startup_entry(CPUHP_ONLINE);
728}
729
730/* Check for early params. */
731static int __init do_early_param(char *param, char *val,
732 const char *unused, void *arg)
733{
734 const struct obs_kernel_param *p;
735
736 for (p = __setup_start; p < __setup_end; p++) {
737 if ((p->early && parameq(param, p->str)) ||
738 (strcmp(param, "console") == 0 &&
739 strcmp(p->str, "earlycon") == 0)
740 ) {
741 if (p->setup_func(val) != 0)
742 pr_warn("Malformed early option '%s'\n", param);
743 }
744 }
745 /* We accept everything at this stage. */
746 return 0;
747}
748
749void __init parse_early_options(char *cmdline)
750{
751 parse_args("early options", cmdline, NULL, 0, 0, 0, NULL,
752 do_early_param);
753}
754
755/* Arch code calls this early on, or if not, just before other parsing. */
756void __init parse_early_param(void)
757{
758 static int done __initdata;
759 static char tmp_cmdline[COMMAND_LINE_SIZE] __initdata;
760
761 if (done)
762 return;
763
764 /* All fall through to do_early_param. */
765 strlcpy(tmp_cmdline, boot_command_line, COMMAND_LINE_SIZE);
766 parse_early_options(tmp_cmdline);
767 done = 1;
768}
769
770void __init __weak arch_post_acpi_subsys_init(void) { }
771
772void __init __weak smp_setup_processor_id(void)
773{
774}
775
776# if THREAD_SIZE >= PAGE_SIZE
777void __init __weak thread_stack_cache_init(void)
778{
779}
780#endif
781
782void __init __weak mem_encrypt_init(void) { }
783
784void __init __weak poking_init(void) { }
785
786void __init __weak pgtable_cache_init(void) { }
787
788bool initcall_debug;
789core_param(initcall_debug, initcall_debug, bool, 0644);
790
791#ifdef TRACEPOINTS_ENABLED
792static void __init initcall_debug_enable(void);
793#else
794static inline void initcall_debug_enable(void)
795{
796}
797#endif
798
799/* Report memory auto-initialization states for this boot. */
800static void __init report_meminit(void)
801{
802 const char *stack;
803
804 if (IS_ENABLED(CONFIG_INIT_STACK_ALL_PATTERN))
805 stack = "all(pattern)";
806 else if (IS_ENABLED(CONFIG_INIT_STACK_ALL_ZERO))
807 stack = "all(zero)";
808 else if (IS_ENABLED(CONFIG_GCC_PLUGIN_STRUCTLEAK_BYREF_ALL))
809 stack = "byref_all(zero)";
810 else if (IS_ENABLED(CONFIG_GCC_PLUGIN_STRUCTLEAK_BYREF))
811 stack = "byref(zero)";
812 else if (IS_ENABLED(CONFIG_GCC_PLUGIN_STRUCTLEAK_USER))
813 stack = "__user(zero)";
814 else
815 stack = "off";
816
817 pr_info("mem auto-init: stack:%s, heap alloc:%s, heap free:%s\n",
818 stack, want_init_on_alloc(GFP_KERNEL) ? "on" : "off",
819 want_init_on_free() ? "on" : "off");
820 if (want_init_on_free())
821 pr_info("mem auto-init: clearing system memory may take some time...\n");
822}
823
824/*
825 * Set up kernel memory allocators
826 */
827static void __init mm_init(void)
828{
829 /*
830 * page_ext requires contiguous pages,
831 * bigger than MAX_ORDER unless SPARSEMEM.
832 */
833 page_ext_init_flatmem();
834 init_debug_pagealloc();
835 report_meminit();
836 mem_init();
837 kmem_cache_init();
838 kmemleak_init();
839 pgtable_init();
840 debug_objects_mem_init();
841 vmalloc_init();
842 ioremap_huge_init();
843 /* Should be run before the first non-init thread is created */
844 init_espfix_bsp();
845 /* Should be run after espfix64 is set up. */
846 pti_init();
847}
848
849void __init __weak arch_call_rest_init(void)
850{
851 rest_init();
852}
853
854void __weak early_drv_init(void) {}
l.yangafee7ee2024-10-10 15:01:10 +0800855void __weak early_debug_info_init(void){}
l.yangb8fdece2024-10-10 14:56:17 +0800856asmlinkage __visible void __init __no_sanitize_address start_kernel(void)
857{
858 char *command_line;
859 char *after_dashes;
860
861 set_task_stack_end_magic(&init_task);
862 smp_setup_processor_id();
863 debug_objects_early_init();
864
865 cgroup_init_early();
866
867 local_irq_disable();
868 early_boot_irqs_disabled = true;
869
870 /*
871 * Interrupts are still disabled. Do necessary setups, then
872 * enable them.
873 */
874 boot_cpu_init();
875 page_address_init();
876 pr_notice("%s", linux_banner);
877 early_security_init();
878 setup_arch(&command_line);
879 setup_boot_config(command_line);
880 setup_command_line(command_line);
881 setup_nr_cpu_ids();
882 setup_per_cpu_areas();
883 smp_prepare_boot_cpu(); /* arch-specific boot-cpu hooks */
884 boot_cpu_hotplug_init();
885
886 build_all_zonelists(NULL);
887 page_alloc_init();
888
889 pr_notice("Kernel command line: %s\n", saved_command_line);
890 /* parameters may set static keys */
891 jump_label_init();
892 parse_early_param();
893 after_dashes = parse_args("Booting kernel",
894 static_command_line, __start___param,
895 __stop___param - __start___param,
896 -1, -1, NULL, &unknown_bootoption);
897 if (!IS_ERR_OR_NULL(after_dashes))
898 parse_args("Setting init args", after_dashes, NULL, 0, -1, -1,
899 NULL, set_init_arg);
900 if (extra_init_args)
901 parse_args("Setting extra init args", extra_init_args,
902 NULL, 0, -1, -1, NULL, set_init_arg);
903
904 /*
905 * These use large bootmem allocations and must precede
906 * kmem_cache_init()
907 */
908 setup_log_buf(0);
909 vfs_caches_init_early();
910 sort_main_extable();
911 trap_init();
912 mm_init();
913
914 ftrace_init();
915
916 /* trace_printk can be enabled here */
917 early_trace_init();
918
919 /*
920 * Set up the scheduler prior starting any interrupts (such as the
921 * timer interrupt). Full topology setup happens at smp_init()
922 * time - but meanwhile we still have a functioning scheduler.
923 */
924 sched_init();
925
926 if (WARN(!irqs_disabled(),
927 "Interrupts were enabled *very* early, fixing it\n"))
928 local_irq_disable();
929 radix_tree_init();
930
931 /*
932 * Set up housekeeping before setting up workqueues to allow the unbound
933 * workqueue to take non-housekeeping into account.
934 */
935 housekeeping_init();
936
937 /*
938 * Allow workqueue creation and work item queueing/cancelling
939 * early. Work item execution depends on kthreads and starts after
940 * workqueue_init().
941 */
942 workqueue_init_early();
943
944 rcu_init();
945
946 /* Trace events are available after this */
947 trace_init();
948
949 if (initcall_debug)
950 initcall_debug_enable();
951
952 context_tracking_init();
l.yangafee7ee2024-10-10 15:01:10 +0800953 early_debug_info_init();
l.yangb8fdece2024-10-10 14:56:17 +0800954 early_drv_init();
955
956 /* init some links before init_ISA_irqs() */
957 early_irq_init();
958 init_IRQ();
959 tick_init();
960 rcu_init_nohz();
961 init_timers();
962 hrtimers_init();
963 softirq_init();
964 timekeeping_init();
965 time_init();
966
967 /*
968 * For best initial stack canary entropy, prepare it after:
969 * - setup_arch() for any UEFI RNG entropy and boot cmdline access
970 * - timekeeping_init() for ktime entropy used in random_init()
971 * - time_init() for making random_get_entropy() work on some platforms
972 * - random_init() to initialize the RNG from from early entropy sources
973 */
974 random_init(command_line);
975 boot_init_stack_canary();
976
977 perf_event_init();
978 profile_init();
979 call_function_init();
980 WARN(!irqs_disabled(), "Interrupts were enabled early\n");
981
982 early_boot_irqs_disabled = false;
983 local_irq_enable();
984
985 kmem_cache_init_late();
986
987 /*
988 * HACK ALERT! This is early. We're enabling the console before
989 * we've done PCI setups etc, and console_init() must be aware of
990 * this. But we do want output early, in case something goes wrong.
991 */
992 console_init();
993 if (panic_later)
994 panic("Too many boot %s vars at `%s'", panic_later,
995 panic_param);
996
997 lockdep_init();
998
999 /*
1000 * Need to run this when irqs are enabled, because it wants
1001 * to self-test [hard/soft]-irqs on/off lock inversion bugs
1002 * too:
1003 */
1004 locking_selftest();
1005
1006 /*
1007 * This needs to be called before any devices perform DMA
1008 * operations that might use the SWIOTLB bounce buffers. It will
1009 * mark the bounce buffers as decrypted so that their usage will
1010 * not cause "plain-text" data to be decrypted when accessed.
1011 */
1012 mem_encrypt_init();
1013
1014#ifdef CONFIG_BLK_DEV_INITRD
1015 if (initrd_start && !initrd_below_start_ok &&
1016 page_to_pfn(virt_to_page((void *)initrd_start)) < min_low_pfn) {
1017 pr_crit("initrd overwritten (0x%08lx < 0x%08lx) - disabling it.\n",
1018 page_to_pfn(virt_to_page((void *)initrd_start)),
1019 min_low_pfn);
1020 initrd_start = 0;
1021 }
1022#endif
1023 setup_per_cpu_pageset();
1024 numa_policy_init();
1025 acpi_early_init();
1026 if (late_time_init)
1027 late_time_init();
1028 sched_clock_init();
1029 calibrate_delay();
1030 pid_idr_init();
1031 anon_vma_init();
1032#ifdef CONFIG_X86
1033 if (efi_enabled(EFI_RUNTIME_SERVICES))
1034 efi_enter_virtual_mode();
1035#endif
1036 thread_stack_cache_init();
1037 cred_init();
1038 fork_init();
1039 proc_caches_init();
1040 uts_ns_init();
1041 buffer_init();
1042 key_init();
1043 security_init();
1044 dbg_late_init();
1045 vfs_caches_init();
1046 pagecache_init();
1047 signals_init();
1048 seq_file_init();
1049 proc_root_init();
1050 nsfs_init();
1051 cpuset_init();
1052 cgroup_init();
1053 taskstats_init_early();
1054 delayacct_init();
1055
1056 poking_init();
1057 check_bugs();
1058
1059 acpi_subsystem_init();
1060 arch_post_acpi_subsys_init();
1061 sfi_init_late();
1062 kcsan_init();
1063
1064 /* Do the rest non-__init'ed, we're now alive */
1065 arch_call_rest_init();
1066
1067 prevent_tail_call_optimization();
1068}
1069
1070/* Call all constructor functions linked into the kernel. */
1071static void __init do_ctors(void)
1072{
1073#ifdef CONFIG_CONSTRUCTORS
1074 ctor_fn_t *fn = (ctor_fn_t *) __ctors_start;
1075
1076 for (; fn < (ctor_fn_t *) __ctors_end; fn++)
1077 (*fn)();
1078#endif
1079}
1080
1081#ifdef CONFIG_KALLSYMS
1082struct blacklist_entry {
1083 struct list_head next;
1084 char *buf;
1085};
1086
1087static __initdata_or_module LIST_HEAD(blacklisted_initcalls);
1088
1089static int __init initcall_blacklist(char *str)
1090{
1091 char *str_entry;
1092 struct blacklist_entry *entry;
1093
1094 /* str argument is a comma-separated list of functions */
1095 do {
1096 str_entry = strsep(&str, ",");
1097 if (str_entry) {
1098 pr_debug("blacklisting initcall %s\n", str_entry);
1099 entry = memblock_alloc(sizeof(*entry),
1100 SMP_CACHE_BYTES);
1101 if (!entry)
1102 panic("%s: Failed to allocate %zu bytes\n",
1103 __func__, sizeof(*entry));
1104 entry->buf = memblock_alloc(strlen(str_entry) + 1,
1105 SMP_CACHE_BYTES);
1106 if (!entry->buf)
1107 panic("%s: Failed to allocate %zu bytes\n",
1108 __func__, strlen(str_entry) + 1);
1109 strcpy(entry->buf, str_entry);
1110 list_add(&entry->next, &blacklisted_initcalls);
1111 }
1112 } while (str_entry);
1113
1114 return 1;
1115}
1116
1117static bool __init_or_module initcall_blacklisted(initcall_t fn)
1118{
1119 struct blacklist_entry *entry;
1120 char fn_name[KSYM_SYMBOL_LEN];
1121 unsigned long addr;
1122
1123 if (list_empty(&blacklisted_initcalls))
1124 return false;
1125
1126 addr = (unsigned long) dereference_function_descriptor(fn);
1127 sprint_symbol_no_offset(fn_name, addr);
1128
1129 /*
1130 * fn will be "function_name [module_name]" where [module_name] is not
1131 * displayed for built-in init functions. Strip off the [module_name].
1132 */
1133 strreplace(fn_name, ' ', '\0');
1134
1135 list_for_each_entry(entry, &blacklisted_initcalls, next) {
1136 if (!strcmp(fn_name, entry->buf)) {
1137 pr_debug("initcall %s blacklisted\n", fn_name);
1138 return true;
1139 }
1140 }
1141
1142 return false;
1143}
1144#else
1145static int __init initcall_blacklist(char *str)
1146{
1147 pr_warn("initcall_blacklist requires CONFIG_KALLSYMS\n");
1148 return 0;
1149}
1150
1151static bool __init_or_module initcall_blacklisted(initcall_t fn)
1152{
1153 return false;
1154}
1155#endif
1156__setup("initcall_blacklist=", initcall_blacklist);
1157
1158static __init_or_module void
1159trace_initcall_start_cb(void *data, initcall_t fn)
1160{
1161 ktime_t *calltime = (ktime_t *)data;
1162
1163 printk(KERN_DEBUG "calling %pS @ %i\n", fn, task_pid_nr(current));
1164 *calltime = ktime_get();
1165}
1166
1167static __init_or_module void
1168trace_initcall_finish_cb(void *data, initcall_t fn, int ret)
1169{
1170 ktime_t *calltime = (ktime_t *)data;
1171 ktime_t delta, rettime;
1172 unsigned long long duration;
1173
1174 rettime = ktime_get();
1175 delta = ktime_sub(rettime, *calltime);
1176 duration = (unsigned long long) ktime_to_ns(delta) >> 10;
1177 printk(KERN_DEBUG "initcall %pS returned %d after %lld usecs\n",
1178 fn, ret, duration);
1179}
1180
1181static ktime_t initcall_calltime;
1182
1183#ifdef TRACEPOINTS_ENABLED
1184static void __init initcall_debug_enable(void)
1185{
1186 int ret;
1187
1188 ret = register_trace_initcall_start(trace_initcall_start_cb,
1189 &initcall_calltime);
1190 ret |= register_trace_initcall_finish(trace_initcall_finish_cb,
1191 &initcall_calltime);
1192 WARN(ret, "Failed to register initcall tracepoints\n");
1193}
1194# define do_trace_initcall_start trace_initcall_start
1195# define do_trace_initcall_finish trace_initcall_finish
1196#else
1197static inline void do_trace_initcall_start(initcall_t fn)
1198{
1199 if (!initcall_debug)
1200 return;
1201 trace_initcall_start_cb(&initcall_calltime, fn);
1202}
1203static inline void do_trace_initcall_finish(initcall_t fn, int ret)
1204{
1205 if (!initcall_debug)
1206 return;
1207 trace_initcall_finish_cb(&initcall_calltime, fn, ret);
1208}
1209#endif /* !TRACEPOINTS_ENABLED */
1210
1211int __init_or_module do_one_initcall(initcall_t fn)
1212{
1213 int count = preempt_count();
1214 char msgbuf[64];
1215 int ret;
1216
1217 if (initcall_blacklisted(fn))
1218 return -EPERM;
1219
1220 do_trace_initcall_start(fn);
1221 ret = fn();
1222 do_trace_initcall_finish(fn, ret);
1223
1224 msgbuf[0] = 0;
1225
1226 if (preempt_count() != count) {
1227 sprintf(msgbuf, "preemption imbalance ");
1228 preempt_count_set(count);
1229 }
1230 if (irqs_disabled()) {
1231 strlcat(msgbuf, "disabled interrupts ", sizeof(msgbuf));
1232 local_irq_enable();
1233 }
1234 WARN(msgbuf[0], "initcall %pS returned with %s\n", fn, msgbuf);
1235
1236 add_latent_entropy();
1237 return ret;
1238}
1239
1240
1241extern initcall_entry_t __initcall_start[];
1242extern initcall_entry_t __initcall0_start[];
1243extern initcall_entry_t __initcall1_start[];
1244extern initcall_entry_t __initcall2_start[];
1245extern initcall_entry_t __initcall3_start[];
1246extern initcall_entry_t __initcall4_start[];
1247extern initcall_entry_t __initcall5_start[];
1248extern initcall_entry_t __initcall6_start[];
1249extern initcall_entry_t __initcall7_start[];
1250extern initcall_entry_t __initcall_end[];
1251
1252static initcall_entry_t *initcall_levels[] __initdata = {
1253 __initcall0_start,
1254 __initcall1_start,
1255 __initcall2_start,
1256 __initcall3_start,
1257 __initcall4_start,
1258 __initcall5_start,
1259 __initcall6_start,
1260 __initcall7_start,
1261 __initcall_end,
1262};
1263
1264/* Keep these in sync with initcalls in include/linux/init.h */
1265static const char *initcall_level_names[] __initdata = {
1266 "pure",
1267 "core",
1268 "postcore",
1269 "arch",
1270 "subsys",
1271 "fs",
1272 "device",
1273 "late",
1274};
1275
1276static int __init ignore_unknown_bootoption(char *param, char *val,
1277 const char *unused, void *arg)
1278{
1279 return 0;
1280}
1281
1282static void __init do_initcall_level(int level, char *command_line)
1283{
1284 initcall_entry_t *fn;
1285
1286 parse_args(initcall_level_names[level],
1287 command_line, __start___param,
1288 __stop___param - __start___param,
1289 level, level,
1290 NULL, ignore_unknown_bootoption);
1291
1292 trace_initcall_level(initcall_level_names[level]);
1293 for (fn = initcall_levels[level]; fn < initcall_levels[level+1]; fn++)
1294 do_one_initcall(initcall_from_entry(fn));
1295}
1296
1297static void __init do_initcalls(void)
1298{
1299 int level;
1300 size_t len = strlen(saved_command_line) + 1;
1301 char *command_line;
1302
1303 command_line = kzalloc(len, GFP_KERNEL);
1304 if (!command_line)
1305 panic("%s: Failed to allocate %zu bytes\n", __func__, len);
1306
1307 for (level = 0; level < ARRAY_SIZE(initcall_levels) - 1; level++) {
1308 /* Parser modifies command_line, restore it each time */
1309 strcpy(command_line, saved_command_line);
1310 do_initcall_level(level, command_line);
1311 }
1312
1313 kfree(command_line);
1314}
1315
1316/*
1317 * Ok, the machine is now initialized. None of the devices
1318 * have been touched yet, but the CPU subsystem is up and
1319 * running, and memory and process management works.
1320 *
1321 * Now we can finally start doing some real work..
1322 */
1323static void __init do_basic_setup(void)
1324{
1325 cpuset_init_smp();
1326 driver_init();
1327 init_irq_proc();
1328 do_ctors();
1329 usermodehelper_enable();
1330 do_initcalls();
1331}
1332
1333static void __init do_pre_smp_initcalls(void)
1334{
1335 initcall_entry_t *fn;
1336
1337 trace_initcall_level("early");
1338 for (fn = __initcall_start; fn < __initcall0_start; fn++)
1339 do_one_initcall(initcall_from_entry(fn));
1340}
1341
1342static int run_init_process(const char *init_filename)
1343{
1344 const char *const *p;
1345
1346 argv_init[0] = init_filename;
1347 pr_info("Run %s as init process\n", init_filename);
1348 pr_debug(" with arguments:\n");
1349 for (p = argv_init; *p; p++)
1350 pr_debug(" %s\n", *p);
1351 pr_debug(" with environment:\n");
1352 for (p = envp_init; *p; p++)
1353 pr_debug(" %s\n", *p);
1354 return kernel_execve(init_filename, argv_init, envp_init);
1355}
1356
1357static int try_to_run_init_process(const char *init_filename)
1358{
1359 int ret;
1360
1361 ret = run_init_process(init_filename);
1362
1363 if (ret && ret != -ENOENT) {
1364 pr_err("Starting init: %s exists but couldn't execute it (error %d)\n",
1365 init_filename, ret);
1366 }
1367
1368 return ret;
1369}
1370
1371static noinline void __init kernel_init_freeable(void);
1372
1373#if defined(CONFIG_STRICT_KERNEL_RWX) || defined(CONFIG_STRICT_MODULE_RWX)
1374bool rodata_enabled __ro_after_init = true;
1375static int __init set_debug_rodata(char *str)
1376{
1377 if (strtobool(str, &rodata_enabled))
1378 pr_warn("Invalid option string for rodata: '%s'\n", str);
1379 return 1;
1380}
1381__setup("rodata=", set_debug_rodata);
1382#endif
1383
1384#ifdef CONFIG_STRICT_KERNEL_RWX
1385static void mark_readonly(void)
1386{
1387 if (rodata_enabled) {
1388 /*
1389 * load_module() results in W+X mappings, which are cleaned
1390 * up with call_rcu(). Let's make sure that queued work is
1391 * flushed so that we don't hit false positives looking for
1392 * insecure pages which are W+X.
1393 */
1394 rcu_barrier();
1395 mark_rodata_ro();
1396 rodata_test();
1397 } else
1398 pr_info("Kernel memory protection disabled.\n");
1399}
1400#elif defined(CONFIG_ARCH_HAS_STRICT_KERNEL_RWX)
1401static inline void mark_readonly(void)
1402{
1403 pr_warn("Kernel memory protection not selected by kernel config.\n");
1404}
1405#else
1406static inline void mark_readonly(void)
1407{
1408 pr_warn("This architecture does not have kernel memory protection.\n");
1409}
1410#endif
1411
1412void __weak free_initmem(void)
1413{
1414 free_initmem_default(POISON_FREE_INITMEM);
1415}
1416
1417static int __ref kernel_init(void *unused)
1418{
1419 int ret;
1420
1421 kernel_init_freeable();
1422 /* need to finish all async __init code before freeing the memory */
1423 async_synchronize_full();
1424 kprobe_free_init_mem();
1425 ftrace_free_init_mem();
1426 kgdb_free_init_mem();
1427 free_initmem();
1428 mark_readonly();
1429
1430 /*
1431 * Kernel mappings are now finalized - update the userspace page-table
1432 * to finalize PTI.
1433 */
1434 pti_finalize();
1435
1436 system_state = SYSTEM_RUNNING;
1437 numa_default_policy();
1438
1439 rcu_end_inkernel_boot();
1440
1441 do_sysctl_args();
1442
1443 if (ramdisk_execute_command) {
1444 ret = run_init_process(ramdisk_execute_command);
1445 if (!ret)
1446 return 0;
1447 pr_err("Failed to execute %s (error %d)\n",
1448 ramdisk_execute_command, ret);
1449 }
1450
1451 /*
1452 * We try each of these until one succeeds.
1453 *
1454 * The Bourne shell can be used instead of init if we are
1455 * trying to recover a really broken machine.
1456 */
1457 if (execute_command) {
1458 ret = run_init_process(execute_command);
1459 if (!ret)
1460 return 0;
1461 panic("Requested init %s failed (error %d).",
1462 execute_command, ret);
1463 }
1464
1465 if (CONFIG_DEFAULT_INIT[0] != '\0') {
1466 ret = run_init_process(CONFIG_DEFAULT_INIT);
1467 if (ret)
1468 pr_err("Default init %s failed (error %d)\n",
1469 CONFIG_DEFAULT_INIT, ret);
1470 else
1471 return 0;
1472 }
1473
1474 if (!try_to_run_init_process("/sbin/init") ||
1475 !try_to_run_init_process("/etc/init") ||
1476 !try_to_run_init_process("/bin/init") ||
1477 !try_to_run_init_process("/bin/sh"))
1478 return 0;
1479#ifdef CONFIG_FLAGS_UTILS
1480{
1481 extern int flags_sys_switch(void);
1482 int ret;
1483 printk(KERN_EMERG "No working init found. Try passing init= option to kernel. "
1484 "See Linux Documentation/admin-guide/init.rst for guidance.");
1485 ret = flags_sys_switch();
1486 if (ret < 0)
1487 panic("VFS: flags_sys_switch fail");
1488 else
1489 kernel_restart("VFS: Switch to another system, please reset machine");
1490}
1491#endif
1492 panic("No working init found. Try passing init= option to kernel. "
1493 "See Linux Documentation/admin-guide/init.rst for guidance.");
1494}
1495
1496/* Open /dev/console, for stdin/stdout/stderr, this should never fail */
1497void __init console_on_rootfs(void)
1498{
1499 struct file *file = filp_open("/dev/console", O_RDWR, 0);
1500
1501 if (IS_ERR(file)) {
1502 pr_err("Warning: unable to open an initial console.\n");
1503 return;
1504 }
1505 init_dup(file);
1506 init_dup(file);
1507 init_dup(file);
1508 fput(file);
1509}
1510
1511static noinline void __init kernel_init_freeable(void)
1512{
1513 /*
1514 * Wait until kthreadd is all set-up.
1515 */
1516 wait_for_completion(&kthreadd_done);
1517
1518 /* Now the scheduler is fully set up and can do blocking allocations */
1519 gfp_allowed_mask = __GFP_BITS_MASK;
1520
1521 /*
1522 * init can allocate pages on any node
1523 */
1524 set_mems_allowed(node_states[N_MEMORY]);
1525
1526 cad_pid = get_pid(task_pid(current));
1527
1528 smp_prepare_cpus(setup_max_cpus);
1529
1530 workqueue_init();
1531
1532 init_mm_internals();
1533
1534 rcu_init_tasks_generic();
1535 do_pre_smp_initcalls();
1536 lockup_detector_init();
1537
1538 smp_init();
1539 sched_init_smp();
1540
1541 padata_init();
1542 page_alloc_init_late();
1543 /* Initialize page ext after all struct pages are initialized. */
1544 page_ext_init();
1545
1546 do_basic_setup();
1547
1548 kunit_run_all_tests();
1549
1550 console_on_rootfs();
1551
1552 /*
1553 * check if there is an early userspace init. If yes, let it do all
1554 * the work
1555 */
1556 if (init_eaccess(ramdisk_execute_command) != 0) {
1557 ramdisk_execute_command = NULL;
1558 prepare_namespace();
1559 }
1560
1561 /*
1562 * Ok, we have completed the initial bootup, and
1563 * we're essentially up and running. Get rid of the
1564 * initmem segments and start the user-mode stuff..
1565 *
1566 * rootfs is available now, try loading the public keys
1567 * and default modules
1568 */
1569
1570 integrity_load_keys();
1571}