]> Git Repo - linux.git/blobdiff - arch/mips/kernel/setup.c
x86/kasan: Print original address on #GP
[linux.git] / arch / mips / kernel / setup.c
index 5eec13b8d222d3940dba7bbf022f52dbfc43fb5b..c3d4212b5f1d4d5732dc9a45fbbc71ede2bdf274 100644 (file)
@@ -67,7 +67,9 @@ static char __initdata command_line[COMMAND_LINE_SIZE];
 char __initdata arcs_cmdline[COMMAND_LINE_SIZE];
 
 #ifdef CONFIG_CMDLINE_BOOL
-static char __initdata builtin_cmdline[COMMAND_LINE_SIZE] = CONFIG_CMDLINE;
+static const char builtin_cmdline[] __initconst = CONFIG_CMDLINE;
+#else
+static const char builtin_cmdline[] __initconst = "";
 #endif
 
 /*
@@ -285,7 +287,7 @@ static unsigned long __init init_initrd(void)
  * Initialize the bootmem allocator. It also setup initrd related data
  * if needed.
  */
-#if defined(CONFIG_SGI_IP27) || (defined(CONFIG_CPU_LOONGSON3) && defined(CONFIG_NUMA))
+#if defined(CONFIG_SGI_IP27) || (defined(CONFIG_CPU_LOONGSON64) && defined(CONFIG_NUMA))
 
 static void __init bootmem_init(void)
 {
@@ -538,11 +540,94 @@ static void __init check_kernel_sections_mem(void)
        }
 }
 
-#define USE_PROM_CMDLINE       IS_ENABLED(CONFIG_MIPS_CMDLINE_FROM_BOOTLOADER)
-#define USE_DTB_CMDLINE                IS_ENABLED(CONFIG_MIPS_CMDLINE_FROM_DTB)
-#define EXTEND_WITH_PROM       IS_ENABLED(CONFIG_MIPS_CMDLINE_DTB_EXTEND)
-#define BUILTIN_EXTEND_WITH_PROM       \
-       IS_ENABLED(CONFIG_MIPS_CMDLINE_BUILTIN_EXTEND)
+static void __init bootcmdline_append(const char *s, size_t max)
+{
+       if (!s[0] || !max)
+               return;
+
+       if (boot_command_line[0])
+               strlcat(boot_command_line, " ", COMMAND_LINE_SIZE);
+
+       strlcat(boot_command_line, s, max);
+}
+
+#ifdef CONFIG_OF_EARLY_FLATTREE
+
+static int __init bootcmdline_scan_chosen(unsigned long node, const char *uname,
+                                         int depth, void *data)
+{
+       bool *dt_bootargs = data;
+       const char *p;
+       int l;
+
+       if (depth != 1 || !data ||
+           (strcmp(uname, "chosen") != 0 && strcmp(uname, "chosen@0") != 0))
+               return 0;
+
+       p = of_get_flat_dt_prop(node, "bootargs", &l);
+       if (p != NULL && l > 0) {
+               bootcmdline_append(p, min(l, COMMAND_LINE_SIZE));
+               *dt_bootargs = true;
+       }
+
+       return 1;
+}
+
+#endif /* CONFIG_OF_EARLY_FLATTREE */
+
+static void __init bootcmdline_init(char **cmdline_p)
+{
+       bool dt_bootargs = false;
+
+       /*
+        * If CMDLINE_OVERRIDE is enabled then initializing the command line is
+        * trivial - we simply use the built-in command line unconditionally &
+        * unmodified.
+        */
+       if (IS_ENABLED(CONFIG_CMDLINE_OVERRIDE)) {
+               strlcpy(boot_command_line, builtin_cmdline, COMMAND_LINE_SIZE);
+               return;
+       }
+
+       /*
+        * If the user specified a built-in command line &
+        * MIPS_CMDLINE_BUILTIN_EXTEND, then the built-in command line is
+        * prepended to arguments from the bootloader or DT so we'll copy them
+        * to the start of boot_command_line here. Otherwise, empty
+        * boot_command_line to undo anything early_init_dt_scan_chosen() did.
+        */
+       if (IS_ENABLED(CONFIG_MIPS_CMDLINE_BUILTIN_EXTEND))
+               strlcpy(boot_command_line, builtin_cmdline, COMMAND_LINE_SIZE);
+       else
+               boot_command_line[0] = 0;
+
+#ifdef CONFIG_OF_EARLY_FLATTREE
+       /*
+        * If we're configured to take boot arguments from DT, look for those
+        * now.
+        */
+       if (IS_ENABLED(CONFIG_MIPS_CMDLINE_FROM_DTB))
+               of_scan_flat_dt(bootcmdline_scan_chosen, &dt_bootargs);
+#endif
+
+       /*
+        * If we didn't get any arguments from DT (regardless of whether that's
+        * because we weren't configured to look for them, or because we looked
+        * & found none) then we'll take arguments from the bootloader.
+        * plat_mem_setup() should have filled arcs_cmdline with arguments from
+        * the bootloader.
+        */
+       if (IS_ENABLED(CONFIG_MIPS_CMDLINE_DTB_EXTEND) || !dt_bootargs)
+               bootcmdline_append(arcs_cmdline, COMMAND_LINE_SIZE);
+
+       /*
+        * If the user specified a built-in command line & we didn't already
+        * prepend it, we append it to boot_command_line here.
+        */
+       if (IS_ENABLED(CONFIG_CMDLINE_BOOL) &&
+           !IS_ENABLED(CONFIG_MIPS_CMDLINE_BUILTIN_EXTEND))
+               bootcmdline_append(builtin_cmdline, COMMAND_LINE_SIZE);
+}
 
 /*
  * arch_mem_init - initialize memory management subsystem
@@ -570,48 +655,12 @@ static void __init arch_mem_init(char **cmdline_p)
 {
        extern void plat_mem_setup(void);
 
-       /*
-        * Initialize boot_command_line to an innocuous but non-empty string in
-        * order to prevent early_init_dt_scan_chosen() from copying
-        * CONFIG_CMDLINE into it without our knowledge. We handle
-        * CONFIG_CMDLINE ourselves below & don't want to duplicate its
-        * content because repeating arguments can be problematic.
-        */
-       strlcpy(boot_command_line, " ", COMMAND_LINE_SIZE);
-
        /* call board setup routine */
        plat_mem_setup();
        memblock_set_bottom_up(true);
 
-#if defined(CONFIG_CMDLINE_BOOL) && defined(CONFIG_CMDLINE_OVERRIDE)
-       strlcpy(boot_command_line, builtin_cmdline, COMMAND_LINE_SIZE);
-#else
-       if ((USE_PROM_CMDLINE && arcs_cmdline[0]) ||
-           (USE_DTB_CMDLINE && !boot_command_line[0]))
-               strlcpy(boot_command_line, arcs_cmdline, COMMAND_LINE_SIZE);
-
-       if (EXTEND_WITH_PROM && arcs_cmdline[0]) {
-               if (boot_command_line[0])
-                       strlcat(boot_command_line, " ", COMMAND_LINE_SIZE);
-               strlcat(boot_command_line, arcs_cmdline, COMMAND_LINE_SIZE);
-       }
-
-#if defined(CONFIG_CMDLINE_BOOL)
-       if (builtin_cmdline[0]) {
-               if (boot_command_line[0])
-                       strlcat(boot_command_line, " ", COMMAND_LINE_SIZE);
-               strlcat(boot_command_line, builtin_cmdline, COMMAND_LINE_SIZE);
-       }
-
-       if (BUILTIN_EXTEND_WITH_PROM && arcs_cmdline[0]) {
-               if (boot_command_line[0])
-                       strlcat(boot_command_line, " ", COMMAND_LINE_SIZE);
-               strlcat(boot_command_line, arcs_cmdline, COMMAND_LINE_SIZE);
-       }
-#endif
-#endif
+       bootcmdline_init(cmdline_p);
        strlcpy(command_line, boot_command_line, COMMAND_LINE_SIZE);
-
        *cmdline_p = command_line;
 
        parse_early_param();
This page took 0.040316 seconds and 4 git commands to generate.