Skip to content

Commit 4faa0e5

Browse files
blitzIngo Molnar
authored andcommitted
x86/boot: Move kernel cmdline setup earlier in the boot process (again)
When split_lock_detect=off (or similar) is specified in CONFIG_CMDLINE, its effect is lost. The flow is currently this: setup_arch(): -> early_cpu_init() -> early_identify_cpu() -> sld_setup() -> sld_state_setup() -> Looks for split_lock_detect in boot_command_line -> e820__memory_setup() -> Assemble final command line: boot_command_line = builtin_cmdline + boot_cmdline -> parse_early_param() There were earlier attempts at fixing this in: 8d48bf8 ("x86/boot: Pull up cmdline preparation and early param parsing") later reverted in: fbe6183 ("Revert "x86/boot: Pull up cmdline preparation and early param parsing"") ... because parse_early_param() can't be called before e820__memory_setup(). In this patch, we just move the command line concatenation to the beginning of early_cpu_init(). This should fix sld_state_setup(), while not running in the same issues as the earlier attempt. The order is now: setup_arch(): -> Assemble final command line: boot_command_line = builtin_cmdline + boot_cmdline -> early_cpu_init() -> early_identify_cpu() -> sld_setup() -> sld_state_setup() -> Looks for split_lock_detect in boot_command_line -> e820__memory_setup() -> parse_early_param() Signed-off-by: Julian Stecklina <[email protected]> Signed-off-by: Ingo Molnar <[email protected]> Cc: Kees Cook <[email protected]> Cc: [email protected]
1 parent 1760837 commit 4faa0e5

File tree

1 file changed

+16
-16
lines changed

1 file changed

+16
-16
lines changed

arch/x86/kernel/setup.c

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -753,6 +753,22 @@ void __init setup_arch(char **cmdline_p)
753753
boot_cpu_data.x86_phys_bits = MAX_PHYSMEM_BITS;
754754
#endif
755755

756+
#ifdef CONFIG_CMDLINE_BOOL
757+
#ifdef CONFIG_CMDLINE_OVERRIDE
758+
strscpy(boot_command_line, builtin_cmdline, COMMAND_LINE_SIZE);
759+
#else
760+
if (builtin_cmdline[0]) {
761+
/* append boot loader cmdline to builtin */
762+
strlcat(builtin_cmdline, " ", COMMAND_LINE_SIZE);
763+
strlcat(builtin_cmdline, boot_command_line, COMMAND_LINE_SIZE);
764+
strscpy(boot_command_line, builtin_cmdline, COMMAND_LINE_SIZE);
765+
}
766+
#endif
767+
#endif
768+
769+
strscpy(command_line, boot_command_line, COMMAND_LINE_SIZE);
770+
*cmdline_p = command_line;
771+
756772
/*
757773
* If we have OLPC OFW, we might end up relocating the fixmap due to
758774
* reserve_top(), so do this before touching the ioremap area.
@@ -832,22 +848,6 @@ void __init setup_arch(char **cmdline_p)
832848
bss_resource.start = __pa_symbol(__bss_start);
833849
bss_resource.end = __pa_symbol(__bss_stop)-1;
834850

835-
#ifdef CONFIG_CMDLINE_BOOL
836-
#ifdef CONFIG_CMDLINE_OVERRIDE
837-
strscpy(boot_command_line, builtin_cmdline, COMMAND_LINE_SIZE);
838-
#else
839-
if (builtin_cmdline[0]) {
840-
/* append boot loader cmdline to builtin */
841-
strlcat(builtin_cmdline, " ", COMMAND_LINE_SIZE);
842-
strlcat(builtin_cmdline, boot_command_line, COMMAND_LINE_SIZE);
843-
strscpy(boot_command_line, builtin_cmdline, COMMAND_LINE_SIZE);
844-
}
845-
#endif
846-
#endif
847-
848-
strscpy(command_line, boot_command_line, COMMAND_LINE_SIZE);
849-
*cmdline_p = command_line;
850-
851851
/*
852852
* x86_configure_nx() is called before parse_early_param() to detect
853853
* whether hardware doesn't support NX (so that the early EHCI debug

0 commit comments

Comments
 (0)