All of lore.kernel.org
 help / color / mirror / Atom feed
* [tip: x86/boot] x86/boot: Move kernel cmdline setup earlier in the boot process (again)
@ 2024-03-29  7:51 tip-bot2 for Julian Stecklina
  2024-04-08 18:17 ` Borislav Petkov
  0 siblings, 1 reply; 5+ messages in thread
From: tip-bot2 for Julian Stecklina @ 2024-03-29  7:51 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: Julian Stecklina, Ingo Molnar, Kees Cook, linux-kernel, x86

The following commit has been merged into the x86/boot branch of tip:

Commit-ID:     4faa0e5d6d79fc4c6e1943e8b62a65744d8439a0
Gitweb:        https://git.kernel.org/tip/4faa0e5d6d79fc4c6e1943e8b62a65744d8439a0
Author:        Julian Stecklina <julian.stecklina@cyberus-technology.de>
AuthorDate:    Thu, 28 Mar 2024 16:42:12 +01:00
Committer:     Ingo Molnar <mingo@kernel.org>
CommitterDate: Fri, 29 Mar 2024 08:19:12 +01:00

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:

  8d48bf8206f7 ("x86/boot: Pull up cmdline preparation and early param parsing")

later reverted in:

  fbe618399854 ("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 <julian.stecklina@cyberus-technology.de>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Cc: Kees Cook <keescook@chromium.org>
Cc: linux-kernel@vger.kernel.org
---
 arch/x86/kernel/setup.c | 32 ++++++++++++++++----------------
 1 file changed, 16 insertions(+), 16 deletions(-)

diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c
index 3e1e96e..4c35f1b 100644
--- a/arch/x86/kernel/setup.c
+++ b/arch/x86/kernel/setup.c
@@ -753,6 +753,22 @@ void __init setup_arch(char **cmdline_p)
 	boot_cpu_data.x86_phys_bits = MAX_PHYSMEM_BITS;
 #endif
 
+#ifdef CONFIG_CMDLINE_BOOL
+#ifdef CONFIG_CMDLINE_OVERRIDE
+	strscpy(boot_command_line, builtin_cmdline, COMMAND_LINE_SIZE);
+#else
+	if (builtin_cmdline[0]) {
+		/* append boot loader cmdline to builtin */
+		strlcat(builtin_cmdline, " ", COMMAND_LINE_SIZE);
+		strlcat(builtin_cmdline, boot_command_line, COMMAND_LINE_SIZE);
+		strscpy(boot_command_line, builtin_cmdline, COMMAND_LINE_SIZE);
+	}
+#endif
+#endif
+
+	strscpy(command_line, boot_command_line, COMMAND_LINE_SIZE);
+	*cmdline_p = command_line;
+
 	/*
 	 * If we have OLPC OFW, we might end up relocating the fixmap due to
 	 * reserve_top(), so do this before touching the ioremap area.
@@ -832,22 +848,6 @@ void __init setup_arch(char **cmdline_p)
 	bss_resource.start = __pa_symbol(__bss_start);
 	bss_resource.end = __pa_symbol(__bss_stop)-1;
 
-#ifdef CONFIG_CMDLINE_BOOL
-#ifdef CONFIG_CMDLINE_OVERRIDE
-	strscpy(boot_command_line, builtin_cmdline, COMMAND_LINE_SIZE);
-#else
-	if (builtin_cmdline[0]) {
-		/* append boot loader cmdline to builtin */
-		strlcat(builtin_cmdline, " ", COMMAND_LINE_SIZE);
-		strlcat(builtin_cmdline, boot_command_line, COMMAND_LINE_SIZE);
-		strscpy(boot_command_line, builtin_cmdline, COMMAND_LINE_SIZE);
-	}
-#endif
-#endif
-
-	strscpy(command_line, boot_command_line, COMMAND_LINE_SIZE);
-	*cmdline_p = command_line;
-
 	/*
 	 * x86_configure_nx() is called before parse_early_param() to detect
 	 * whether hardware doesn't support NX (so that the early EHCI debug

^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2024-05-27 17:32 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-03-29  7:51 [tip: x86/boot] x86/boot: Move kernel cmdline setup earlier in the boot process (again) tip-bot2 for Julian Stecklina
2024-04-08 18:17 ` Borislav Petkov
2024-04-08 18:27   ` Ingo Molnar
2024-04-09 15:25     ` [PATCH] x86/setup: Warn when option parsing is done too early Borislav Petkov
2024-05-27 17:32       ` [tip: x86/boot] " tip-bot2 for Borislav Petkov (AMD)

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.