bootconfig: Rename xbc_node_find_child() to xbc_node_find_subkey()
[linux-2.6-microblaze.git] / init / main.c
index f88d896..d08caed 100644 (file)
 #include <linux/profile.h>
 #include <linux/kfence.h>
 #include <linux/rcupdate.h>
+#include <linux/srcu.h>
 #include <linux/moduleparam.h>
 #include <linux/kallsyms.h>
+#include <linux/buildid.h>
 #include <linux/writeback.h>
 #include <linux/cpu.h>
 #include <linux/cpuset.h>
@@ -151,10 +153,10 @@ static char *extra_init_args;
 #ifdef CONFIG_BOOT_CONFIG
 /* Is bootconfig on command line? */
 static bool bootconfig_found;
-static bool initargs_found;
+static size_t initargs_offs;
 #else
 # define bootconfig_found false
-# define initargs_found false
+# define initargs_offs 0
 #endif
 
 static char *execute_command;
@@ -386,16 +388,6 @@ static char * __init xbc_make_cmdline(const char *key)
        return new_cmdline;
 }
 
-static u32 boot_config_checksum(unsigned char *p, u32 size)
-{
-       u32 ret = 0;
-
-       while (size--)
-               ret += *p++;
-
-       return ret;
-}
-
 static int __init bootconfig_params(char *param, char *val,
                                    const char *unused, void *arg)
 {
@@ -405,6 +397,12 @@ static int __init bootconfig_params(char *param, char *val,
        return 0;
 }
 
+static int __init warn_bootconfig(char *str)
+{
+       /* The 'bootconfig' has been handled by bootconfig_params(). */
+       return 0;
+}
+
 static void __init setup_boot_config(void)
 {
        static char tmp_cmdline[COMMAND_LINE_SIZE] __initdata;
@@ -424,9 +422,9 @@ static void __init setup_boot_config(void)
        if (IS_ERR(err) || !bootconfig_found)
                return;
 
-       /* parse_args() stops at '--' and returns an address */
+       /* parse_args() stops at the next param of '--' and returns an address */
        if (err)
-               initargs_found = true;
+               initargs_offs = err - tmp_cmdline;
 
        if (!data) {
                pr_err("'bootconfig' found on command line, but no bootconfig found\n");
@@ -439,7 +437,7 @@ static void __init setup_boot_config(void)
                return;
        }
 
-       if (boot_config_checksum((unsigned char *)data, size) != csum) {
+       if (xbc_calc_checksum(data, size) != csum) {
                pr_err("bootconfig checksum failed\n");
                return;
        }
@@ -470,7 +468,12 @@ static void __init setup_boot_config(void)
        return;
 }
 
-#else
+static void __init exit_boot_config(void)
+{
+       xbc_destroy_all();
+}
+
+#else  /* !CONFIG_BOOT_CONFIG */
 
 static void __init setup_boot_config(void)
 {
@@ -483,9 +486,12 @@ static int __init warn_bootconfig(char *str)
        pr_warn("WARNING: 'bootconfig' found on the kernel command line but CONFIG_BOOT_CONFIG is not set.\n");
        return 0;
 }
-early_param("bootconfig", warn_bootconfig);
 
-#endif
+#define exit_boot_config()     do {} while (0)
+
+#endif /* CONFIG_BOOT_CONFIG */
+
+early_param("bootconfig", warn_bootconfig);
 
 /* Change NUL term back to "=", to make "param" the whole string. */
 static void __init repair_env_string(char *param, char *val)
@@ -649,16 +655,21 @@ static void __init setup_command_line(char *command_line)
                 * Append supplemental init boot args to saved_command_line
                 * so that user can check what command line options passed
                 * to init.
+                * The order should always be
+                * " -- "[bootconfig init-param][cmdline init-param]
                 */
-               len = strlen(saved_command_line);
-               if (initargs_found) {
-                       saved_command_line[len++] = ' ';
+               if (initargs_offs) {
+                       len = xlen + initargs_offs;
+                       strcpy(saved_command_line + len, extra_init_args);
+                       len += ilen - 4;        /* strlen(extra_init_args) */
+                       strcpy(saved_command_line + len,
+                               boot_command_line + initargs_offs - 1);
                } else {
+                       len = strlen(saved_command_line);
                        strcpy(saved_command_line + len, " -- ");
                        len += 4;
+                       strcpy(saved_command_line + len, extra_init_args);
                }
-
-               strcpy(saved_command_line + len, extra_init_args);
        }
 }
 
@@ -922,6 +933,7 @@ asmlinkage __visible void __init __no_sanitize_address start_kernel(void)
        set_task_stack_end_magic(&init_task);
        smp_setup_processor_id();
        debug_objects_early_init();
+       init_vmlinux_build_id();
 
        cgroup_init_early();
 
@@ -1018,6 +1030,7 @@ asmlinkage __visible void __init __no_sanitize_address start_kernel(void)
        tick_init();
        rcu_init_nohz();
        init_timers();
+       srcu_init();
        hrtimers_init();
        softirq_init();
        timekeeping_init();
@@ -1494,6 +1507,7 @@ static int __ref kernel_init(void *unused)
        kprobe_free_init_mem();
        ftrace_free_init_mem();
        kgdb_free_init_mem();
+       exit_boot_config();
        free_initmem();
        mark_readonly();