summaryrefslogtreecommitdiff
path: root/init
diff options
context:
space:
mode:
authorBreno Leitao <leitao@debian.org>2026-07-02 21:15:46 +0900
committerMasami Hiramatsu (Google) <mhiramat@kernel.org>2026-07-02 21:15:46 +0900
commit378517ca3be0477e0da056f9e13df1aa37b88702 (patch)
tree949c5684f4a8b57f2070d41990628bb08fa5879d /init
parentbfdf7ec54f1a5e4759a5550ceed3edf738f36c5f (diff)
downloadlinux-next-378517ca3be0477e0da056f9e13df1aa37b88702.tar.gz
linux-next-378517ca3be0477e0da056f9e13df1aa37b88702.zip
bootconfig: skip runtime kernel.* render once prepended early
setup_boot_config() folds the embedded bootconfig "kernel" subtree into the command line via xbc_make_cmdline("kernel"). A subsequent patch lets an architecture prepend the build-time-rendered embedded "kernel" keys to boot_command_line early in setup_arch(); rendering them again here would then duplicate every key in saved_command_line and make accumulating handlers (console=, earlycon=, ...) re-register the same value. Track whether the bootconfig data came from the embedded source (from_embedded) and skip the runtime render only when the early prepend actually happened, as reported by xbc_embedded_cmdline_applied(). On architectures that do not select ARCH_SUPPORTS_CMDLINE_FROM_BOOTCONFIG that helper is a stub returning false, so this path is unchanged and the embedded "kernel" keys still reach the cmdline via the runtime parser exactly as before. Link: https://lore.kernel.org/all/20260626-bootconfig_using_tools-v7-8-24ab72139c29@debian.org/ Signed-off-by: Breno Leitao <leitao@debian.org> Signed-off-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>
Diffstat (limited to 'init')
-rw-r--r--init/main.c25
1 files changed, 22 insertions, 3 deletions
diff --git a/init/main.c b/init/main.c
index e363232b428b..260bd5242f94 100644
--- a/init/main.c
+++ b/init/main.c
@@ -378,12 +378,15 @@ static void __init setup_boot_config(void)
int pos, ret;
size_t size;
char *err;
+ bool from_embedded = false;
/* Cut out the bootconfig data even if we have no bootconfig option */
data = get_boot_config_from_initrd(&size);
/* If there is no bootconfig in initrd, try embedded one. */
- if (!data)
+ if (!data) {
data = xbc_get_embedded_bootconfig(&size);
+ from_embedded = true;
+ }
strscpy(tmp_cmdline, boot_command_line, COMMAND_LINE_SIZE);
err = parse_args("bootconfig", tmp_cmdline, NULL, 0, 0, 0, NULL,
@@ -421,8 +424,24 @@ static void __init setup_boot_config(void)
} else {
xbc_get_info(&ret, NULL);
pr_info("Load bootconfig: %ld bytes %d nodes\n", (long)size, ret);
- /* keys starting with "kernel." are passed via cmdline */
- extra_command_line = xbc_make_cmdline("kernel");
+ /*
+ * keys starting with "kernel." are passed via cmdline. When
+ * this bootconfig came from the embedded source and
+ * setup_arch() already prepended the rendered "kernel" subtree
+ * to boot_command_line, rendering again here would duplicate
+ * the keys in saved_command_line and make accumulating handlers
+ * (console=, earlycon=, ...) re-register the same value. Skip
+ * only when the prepend really happened.
+ *
+ * On arches that do not select ARCH_SUPPORTS_CMDLINE_FROM_BOOTCONFIG,
+ * CONFIG_CMDLINE_FROM_BOOTCONFIG is unselectable and
+ * xbc_embedded_cmdline_applied() collapses to a stub returning
+ * false, so this path still runs and the embedded "kernel"
+ * keys reach the cmdline via the runtime parser exactly as
+ * before this series.
+ */
+ if (!from_embedded || !xbc_embedded_cmdline_applied())
+ extra_command_line = xbc_make_cmdline("kernel");
/* Also, "init." keys are init arguments */
extra_init_args = xbc_make_cmdline("init");
}