Re: [PATCH 2/3] init: use static buffers for bootconfig extra command line
From: Breno Leitao
Date: Fri Apr 17 2026 - 11:44:49 EST
On Fri, Apr 17, 2026 at 10:44:36AM +0900, Masami Hiramatsu wrote:
> On Wed, 15 Apr 2026 03:51:11 -0700
> Breno Leitao <leitao@xxxxxxxxxx> wrote:
>
> But if we can do it, should we continue using bootconfig? I mean
> it is easy to make a tool (or add a feature in tools/bootconfig)
> which converts bootconfig file to command line string and embeds
> it in the kernel. Hmm.
Sure, you are talking about a a tool that embeddeds it in the kernel binary,
something like:
0) Get a kernel and define CONFIG_BOOT_CONFIG_EMBED_FILE=".bootconfig"
1) Add an option in tools/bootconfig to convert bootconfig (.bootconfig)
to a cmdline string ($ bootconfig -C kernel .bootconfig).
Something like:
# tools/bootconfig/bootconfig -C kernel .bootconfig
mem=2G loglevel=7 debug nokaslr %
2) At kernel build time, run that tool on .bootconfig and embed the
resulting string into the kernel image as a .init.rodata symbol
(embedded_kernel_cmdline[]).
# gdb -batch -ex 'x/s &embedded_kernel_cmdline' vmlinux
0xffffffff87e108f8: "mem=2G loglevel=7 debug nokaslr "
3) At boot, the arch's setup_arch() prepends that symbol to
boot_command_line right before parse_early_param() — so early_param()
handlers (mem=, earlycon=, loglevel=, ...) actually see kernel.*
keys from the embedded bootconfig.
This needs to be architecture by architecture. Something like:
@@ -924,6 +925,13 @@ void __init setup_arch(char **cmdline_p)
builtin_cmdline_added = true;
#endif
+ /*
+ * Prepend kernel.* keys from the embedded bootconfig (rendered at
+ * build time by tools/bootconfig) so parse_early_param() below sees
+ * them. No-op when CONFIG_BOOT_CONFIG_EMBED=n.
+ */
+ xbc_prepend_embedded_cmdline(boot_command_line, COMMAND_LINE_SIZE);
+
strscpy(command_line, boot_command_line, COMMAND_LINE_SIZE);
*cmdline_p = command_line;
Am I describing your suggestion accordingly?
Thanks!
--breno