Merge tag 'printk-for-5.2' of git://git.kernel.org/pub/scm/linux/kernel/git/pmladek...
[linux-2.6-block.git] / init / main.c
index 3192c6cc53827e93dd0e2e19ed02699e3c4be09f..efe6d62e3846955c2501d980a6d17a4bd93634a4 100644 (file)
@@ -373,12 +373,20 @@ static inline void smp_prepare_cpus(unsigned int maxcpus) { }
  */
 static void __init setup_command_line(char *command_line)
 {
-       saved_command_line =
-               memblock_alloc(strlen(boot_command_line) + 1, SMP_CACHE_BYTES);
-       initcall_command_line =
-               memblock_alloc(strlen(boot_command_line) + 1, SMP_CACHE_BYTES);
-       static_command_line = memblock_alloc(strlen(command_line) + 1,
-                                            SMP_CACHE_BYTES);
+       size_t len = strlen(boot_command_line) + 1;
+
+       saved_command_line = memblock_alloc(len, SMP_CACHE_BYTES);
+       if (!saved_command_line)
+               panic("%s: Failed to allocate %zu bytes\n", __func__, len);
+
+       initcall_command_line = memblock_alloc(len, SMP_CACHE_BYTES);
+       if (!initcall_command_line)
+               panic("%s: Failed to allocate %zu bytes\n", __func__, len);
+
+       static_command_line = memblock_alloc(len, SMP_CACHE_BYTES);
+       if (!static_command_line)
+               panic("%s: Failed to allocate %zu bytes\n", __func__, len);
+
        strcpy(saved_command_line, boot_command_line);
        strcpy(static_command_line, command_line);
 }
@@ -496,6 +504,10 @@ void __init __weak thread_stack_cache_init(void)
 
 void __init __weak mem_encrypt_init(void) { }
 
+void __init __weak poking_init(void) { }
+
+void __init __weak pgd_cache_init(void) { }
+
 bool initcall_debug;
 core_param(initcall_debug, initcall_debug, bool, 0644);
 
@@ -527,6 +539,7 @@ static void __init mm_init(void)
        init_espfix_bsp();
        /* Should be run after espfix64 is set up. */
        pti_init();
+       pgd_cache_init();
 }
 
 void __init __weak arch_call_rest_init(void)
@@ -574,6 +587,8 @@ asmlinkage __visible void __init start_kernel(void)
        page_alloc_init();
 
        pr_notice("Kernel command line: %s\n", boot_command_line);
+       /* parameters may set static keys */
+       jump_label_init();
        parse_early_param();
        after_dashes = parse_args("Booting kernel",
                                  static_command_line, __start___param,
@@ -583,8 +598,6 @@ asmlinkage __visible void __init start_kernel(void)
                parse_args("Setting init args", after_dashes, NULL, 0, -1, -1,
                           NULL, set_init_arg);
 
-       jump_label_init();
-
        /*
         * These use large bootmem allocations and must precede
         * kmem_cache_init()
@@ -729,6 +742,7 @@ asmlinkage __visible void __init start_kernel(void)
        taskstats_init_early();
        delayacct_init();
 
+       poking_init();
        check_bugs();
 
        acpi_subsystem_init();
@@ -770,8 +784,14 @@ static int __init initcall_blacklist(char *str)
                        pr_debug("blacklisting initcall %s\n", str_entry);
                        entry = memblock_alloc(sizeof(*entry),
                                               SMP_CACHE_BYTES);
+                       if (!entry)
+                               panic("%s: Failed to allocate %zu bytes\n",
+                                     __func__, sizeof(*entry));
                        entry->buf = memblock_alloc(strlen(str_entry) + 1,
                                                    SMP_CACHE_BYTES);
+                       if (!entry->buf)
+                               panic("%s: Failed to allocate %zu bytes\n",
+                                     __func__, strlen(str_entry) + 1);
                        strcpy(entry->buf, str_entry);
                        list_add(&entry->next, &blacklisted_initcalls);
                }