* [PATCH v2] bootconfig: Apply early options from embedded config @ 2026-03-25 10:05 Breno Leitao 2026-03-25 14:22 ` Masami Hiramatsu 0 siblings, 1 reply; 8+ messages in thread From: Breno Leitao @ 2026-03-25 10:05 UTC (permalink / raw) To: Masami Hiramatsu, Jonathan Corbet, Shuah Khan Cc: linux-kernel, linux-trace-kernel, linux-doc, oss, paulmck, rostedt, kernel-team, Breno Leitao Bootconfig currently cannot be used to configure early kernel parameters. For example, the "mitigations=" parameter must be passed through traditional boot methods because bootconfig parsing happens after these early parameters need to be processed. This patch allows early options such as: kernel.mitigations = off to be placed in the embedded bootconfig and take effect, without requiring them to be on the kernel command line. Add bootconfig_apply_early_params() which walks all kernel.* keys in the parsed XBC tree and calls do_early_param() for each one. It is called from setup_boot_config() immediately after a successful xbc_init() on the embedded data, which happens before parse_early_param() runs in start_kernel(). Early options in initrd bootconfig are still silently ignored, as the initrd is only available after the early param window has closed. Document this behaviour in both Kconfig and the admin guide. Signed-off-by: Breno Leitao <leitao@debian.org> --- Changes in v2: - Made val_buf static __initdata to keep 2KB off the stack - Removed dead !val branch — xbc_node_find_next_key_value() returns "" for boolean keys, never NULL - Added pr_warn + continue when strscpy truncates the value - Link to v1: https://patch.msgid.link/20260324-early_bootconfig-v1-1-1c0e625aff06@debian.org --- Documentation/admin-guide/bootconfig.rst | 4 ++ init/Kconfig | 6 +++ init/main.c | 68 +++++++++++++++++++++++++++++++- 3 files changed, 77 insertions(+), 1 deletion(-) diff --git a/Documentation/admin-guide/bootconfig.rst b/Documentation/admin-guide/bootconfig.rst index f712758472d5c..e820f33d3ad16 100644 --- a/Documentation/admin-guide/bootconfig.rst +++ b/Documentation/admin-guide/bootconfig.rst @@ -169,6 +169,10 @@ Boot Kernel With a Boot Config There are two options to boot the kernel with bootconfig: attaching the bootconfig to the initrd image or embedding it in the kernel itself. +Early options (those registered with ``early_param()``) may only be +specified in the embedded bootconfig, because the initrd is not yet +available when early parameters are processed. + Attaching a Boot Config to Initrd --------------------------------- diff --git a/init/Kconfig b/init/Kconfig index 938fbe6a91e15..5e8057e73fe06 100644 --- a/init/Kconfig +++ b/init/Kconfig @@ -1534,6 +1534,12 @@ config BOOT_CONFIG_EMBED image. But if the system doesn't support initrd, this option will help you by embedding a bootconfig file while building the kernel. + Unlike bootconfig attached to initrd, the embedded bootconfig also + supports early options (those registered with early_param()). Any + kernel.* key in the embedded bootconfig is applied before + parse_early_param() runs. Early options in initrd bootconfig will + not be applied. + If unsure, say N. config BOOT_CONFIG_EMBED_FILE diff --git a/init/main.c b/init/main.c index 453ac9dff2da0..14a04c283fa48 100644 --- a/init/main.c +++ b/init/main.c @@ -416,9 +416,64 @@ static int __init warn_bootconfig(char *str) return 0; } +/* + * do_early_param() is defined later in this file but called from + * bootconfig_apply_early_params() below, so we need a forward declaration. + */ +static int __init do_early_param(char *param, char *val, + const char *unused, void *arg); + +/* + * bootconfig_apply_early_params - dispatch kernel.* keys from the embedded + * bootconfig as early_param() calls. + * + * early_param() handlers must run before most of the kernel initialises + * (e.g. before the GIC driver reads irqchip.gicv3_pseudo_nmi). A bootconfig + * attached to the initrd arrives too late for this because the initrd is not + * mapped yet when early params are processed. The embedded bootconfig lives + * in the kernel image itself (.init.data), so it is always reachable. + * + * This function is called from setup_boot_config() which runs in + * start_kernel() before parse_early_param(), making the timing correct. + */ +static void __init bootconfig_apply_early_params(void) +{ + static char val_buf[COMMAND_LINE_SIZE] __initdata; + struct xbc_node *knode, *root; + const char *val; + ssize_t ret; + + root = xbc_find_node("kernel"); + if (!root) + return; + + /* + * Keys that do not match any early_param() handler are silently + * ignored — do_early_param() always returns 0. + */ + xbc_node_for_each_key_value(root, knode, val) { + if (xbc_node_compose_key_after(root, knode, xbc_namebuf, XBC_KEYLEN_MAX) < 0) + continue; + + /* + * We need to copy const char *val to a char pointer, + * which is what do_early_param() need, given it might + * call strsep(), strtok() later. + */ + ret = strscpy(val_buf, val, sizeof(val_buf)); + if (ret < 0) { + pr_warn("ignoring bootconfig value '%s', too long\n", + xbc_namebuf); + continue; + } + do_early_param(xbc_namebuf, val_buf, NULL, NULL); + } +} + static void __init setup_boot_config(void) { static char tmp_cmdline[COMMAND_LINE_SIZE] __initdata; + bool using_embedded = false; const char *msg, *data; int pos, ret; size_t size; @@ -427,8 +482,17 @@ static void __init setup_boot_config(void) /* 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); + /* + * Record that we are using the embedded config so that + * bootconfig_apply_early_params() is called below. + * When CONFIG_BOOT_CONFIG_EMBED is not set, + * xbc_get_embedded_bootconfig() is a stub returning NULL, so + * data is always NULL here and using_embedded stays false. + */ + using_embedded = data; + } strscpy(tmp_cmdline, boot_command_line, COMMAND_LINE_SIZE); err = parse_args("bootconfig", tmp_cmdline, NULL, 0, 0, 0, NULL, @@ -466,6 +530,8 @@ 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); + if (using_embedded) + bootconfig_apply_early_params(); /* keys starting with "kernel." are passed via cmdline */ extra_command_line = xbc_make_cmdline("kernel"); /* Also, "init." keys are init arguments */ --- base-commit: 785f0eb2f85decbe7c1ef9ae922931f0194ffc2e change-id: 20260323-early_bootconfig-2efc4509af3d Best regards, -- Breno Leitao <leitao@debian.org> ^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH v2] bootconfig: Apply early options from embedded config 2026-03-25 10:05 [PATCH v2] bootconfig: Apply early options from embedded config Breno Leitao @ 2026-03-25 14:22 ` Masami Hiramatsu 2026-03-26 14:30 ` Masami Hiramatsu 2026-03-27 10:06 ` Breno Leitao 0 siblings, 2 replies; 8+ messages in thread From: Masami Hiramatsu @ 2026-03-25 14:22 UTC (permalink / raw) To: Breno Leitao Cc: Jonathan Corbet, Shuah Khan, linux-kernel, linux-trace-kernel, linux-doc, oss, paulmck, rostedt, kernel-team Hi Breno, On Wed, 25 Mar 2026 03:05:38 -0700 Breno Leitao <leitao@debian.org> wrote: > Bootconfig currently cannot be used to configure early kernel > parameters. For example, the "mitigations=" parameter must be passed > through traditional boot methods because bootconfig parsing happens > after these early parameters need to be processed. > > This patch allows early options such as: > > kernel.mitigations = off > > to be placed in the embedded bootconfig and take effect, without > requiring them to be on the kernel command line. > > Add bootconfig_apply_early_params() which walks all kernel.* keys in the > parsed XBC tree and calls do_early_param() for each one. It is called > from setup_boot_config() immediately after a successful xbc_init() on > the embedded data, which happens before parse_early_param() runs in > start_kernel(). > > Early options in initrd bootconfig are still silently ignored, as the > initrd is only available after the early param window has closed. > > Document this behaviour in both Kconfig and the admin guide. AI review made some comments. Some of the review comments seem reasonable. https://sashiko.dev/#/patchset/20260325-early_bootconfig-v2-1-6b05a36fbfb5%40debian.org [..] > > diff --git a/init/main.c b/init/main.c > index 453ac9dff2da0..14a04c283fa48 100644 > --- a/init/main.c > +++ b/init/main.c > @@ -416,9 +416,64 @@ static int __init warn_bootconfig(char *str) > return 0; > } > > +/* > + * do_early_param() is defined later in this file but called from > + * bootconfig_apply_early_params() below, so we need a forward declaration. > + */ > +static int __init do_early_param(char *param, char *val, > + const char *unused, void *arg); > + > +/* > + * bootconfig_apply_early_params - dispatch kernel.* keys from the embedded > + * bootconfig as early_param() calls. > + * > + * early_param() handlers must run before most of the kernel initialises > + * (e.g. before the GIC driver reads irqchip.gicv3_pseudo_nmi). A bootconfig > + * attached to the initrd arrives too late for this because the initrd is not > + * mapped yet when early params are processed. The embedded bootconfig lives > + * in the kernel image itself (.init.data), so it is always reachable. > + * > + * This function is called from setup_boot_config() which runs in > + * start_kernel() before parse_early_param(), making the timing correct. > + */ > +static void __init bootconfig_apply_early_params(void) [sashiko comment] | Does this run early enough for architectural parameters? | While setup_boot_config() runs before parse_early_param() in start_kernel(), | it runs after setup_arch(). setup_boot_config() relies on xbc_init() which | uses the memblock allocator, requiring setup_arch() to have already | initialized it. | However, the kernel expects many early parameters (like mem=, earlycon, | noapic, and iommu) to be parsed during setup_arch() via the architecture's | call to parse_early_param(). Since setup_arch() completes before | setup_boot_config() runs, will these architectural early parameters be | silently ignored because the decisions they influence were already | finalized? This is the major reason that I did not support early parameter in bootconfig. Some archs initialize kernel_cmdline in setup_arch() and setup early parameters in it. To fix this, we need to change setup_arch() for each architecture so that it calls this bootconfig_apply_early_params(). > +{ > + static char val_buf[COMMAND_LINE_SIZE] __initdata; [sashiko comment] | Can using a single shared static buffer cause data corruption for handlers | that save the argument pointer? | Several early_param handlers assume the passed string pointer is persistent | (like the boot_command_line) and retain it internally. For example, | setup_earlycon() calls register_earlycon(), which sets | early_console_dev.con->options = options, where options is a pointer | directly into the passed buffer. | Because val_buf is overwritten on every loop iteration, the stored pointer | will point to the value of the last bootconfig key processed. Ah, good catch. Since we don't have any standard way to handle the parameters, some of them does not copy the value but try to keep reference to the given string. > + struct xbc_node *knode, *root; > + const char *val; > + ssize_t ret; > + > + root = xbc_find_node("kernel"); > + if (!root) > + return; > + > + /* > + * Keys that do not match any early_param() handler are silently > + * ignored — do_early_param() always returns 0. > + */ > + xbc_node_for_each_key_value(root, knode, val) { [sashiko comment] | Does this loop handle array values correctly? | xbc_node_for_each_key_value() only assigns the first value of an array to | the val pointer before advancing to the next key. It does not iterate over | the child nodes of the array. | If the bootconfig contains a multi-value key like | kernel.console = "ttyS0", "tty0", will the subsequent values in the array | be silently dropped instead of passed to the early_param handlers? Also, good catch :) we need to use xbc_node_for_each_array_value() for inner loop. > + if (xbc_node_compose_key_after(root, knode, xbc_namebuf, XBC_KEYLEN_MAX) < 0) > + continue; > + > + /* > + * We need to copy const char *val to a char pointer, > + * which is what do_early_param() need, given it might > + * call strsep(), strtok() later. > + */ > + ret = strscpy(val_buf, val, sizeof(val_buf)); > + if (ret < 0) { > + pr_warn("ignoring bootconfig value '%s', too long\n", > + xbc_namebuf); > + continue; > + } > + do_early_param(xbc_namebuf, val_buf, NULL, NULL); [sashiko comment] | How does this handle valueless parameters (boolean flags)? | When parsing the standard kernel command line, parse_args() passes a NULL | value to the setup function for flags that lack an = sign (e.g., ro or | earlycon). | However, the bootconfig parser returns a zero-length string for valueless | keys, which gets copied into val_buf as "" and passed to do_early_param(). | This semantic deviation breaks handlers that explicitly check if (!val). | For instance, param_setup_earlycon() and parse_lapic() check for a NULL | argument to enable features. Will passing "" instead of NULL prevent these | handlers from working correctly? See fs/proc/bootconfig.c. You can check whether the key has a value or not by checking xbc_node_get_child(knode) != NULL. Thank you, > + } > +} > + > static void __init setup_boot_config(void) > { > static char tmp_cmdline[COMMAND_LINE_SIZE] __initdata; > + bool using_embedded = false; > const char *msg, *data; > int pos, ret; > size_t size; > @@ -427,8 +482,17 @@ static void __init setup_boot_config(void) > /* 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); > + /* > + * Record that we are using the embedded config so that > + * bootconfig_apply_early_params() is called below. > + * When CONFIG_BOOT_CONFIG_EMBED is not set, > + * xbc_get_embedded_bootconfig() is a stub returning NULL, so > + * data is always NULL here and using_embedded stays false. > + */ > + using_embedded = data; > + } > > strscpy(tmp_cmdline, boot_command_line, COMMAND_LINE_SIZE); > err = parse_args("bootconfig", tmp_cmdline, NULL, 0, 0, 0, NULL, > @@ -466,6 +530,8 @@ 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); > + if (using_embedded) > + bootconfig_apply_early_params(); > /* keys starting with "kernel." are passed via cmdline */ > extra_command_line = xbc_make_cmdline("kernel"); > /* Also, "init." keys are init arguments */ > > --- > base-commit: 785f0eb2f85decbe7c1ef9ae922931f0194ffc2e > change-id: 20260323-early_bootconfig-2efc4509af3d > > Best regards, > -- > Breno Leitao <leitao@debian.org> > -- Masami Hiramatsu (Google) <mhiramat@kernel.org> ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v2] bootconfig: Apply early options from embedded config 2026-03-25 14:22 ` Masami Hiramatsu @ 2026-03-26 14:30 ` Masami Hiramatsu 2026-03-27 10:18 ` Breno Leitao 2026-03-27 10:06 ` Breno Leitao 1 sibling, 1 reply; 8+ messages in thread From: Masami Hiramatsu @ 2026-03-26 14:30 UTC (permalink / raw) To: Masami Hiramatsu Cc: Breno Leitao, Jonathan Corbet, Shuah Khan, linux-kernel, linux-trace-kernel, linux-doc, oss, paulmck, rostedt, kernel-team On Wed, 25 Mar 2026 23:22:04 +0900 Masami Hiramatsu (Google) <mhiramat@kernel.org> wrote: > > + /* > > + * Keys that do not match any early_param() handler are silently > > + * ignored — do_early_param() always returns 0. > > + */ > > + xbc_node_for_each_key_value(root, knode, val) { > > [sashiko comment] > | Does this loop handle array values correctly? > | xbc_node_for_each_key_value() only assigns the first value of an array to > | the val pointer before advancing to the next key. It does not iterate over > | the child nodes of the array. > | If the bootconfig contains a multi-value key like > | kernel.console = "ttyS0", "tty0", will the subsequent values in the array > | be silently dropped instead of passed to the early_param handlers? > > Also, good catch :) we need to use xbc_node_for_each_array_value() > for inner loop. FYI, xbc_snprint_cmdline() translates the arraied parameter as multiple parameters. For example, foo = bar, buz; will be converted to foo=bar foo=buz Thus, I think we should do the same thing below; > > > + if (xbc_node_compose_key_after(root, knode, xbc_namebuf, XBC_KEYLEN_MAX) < 0) > > + continue; > > + > > + /* > > + * We need to copy const char *val to a char pointer, > > + * which is what do_early_param() need, given it might > > + * call strsep(), strtok() later. > > + */ > > + ret = strscpy(val_buf, val, sizeof(val_buf)); > > + if (ret < 0) { > > + pr_warn("ignoring bootconfig value '%s', too long\n", > > + xbc_namebuf); > > + continue; > > + } > > + do_early_param(xbc_namebuf, val_buf, NULL, NULL); So instead of this; xbc_array_for_each_value(vnode, val) { do_early_param(xbc_namebuf, val, NULL, NULL); } Maybe it is a good timing to recondier unifying kernel cmdline and bootconfig from API viewpoint. Thanks, -- Masami Hiramatsu (Google) <mhiramat@kernel.org> ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v2] bootconfig: Apply early options from embedded config 2026-03-26 14:30 ` Masami Hiramatsu @ 2026-03-27 10:18 ` Breno Leitao 2026-03-27 14:16 ` Masami Hiramatsu 0 siblings, 1 reply; 8+ messages in thread From: Breno Leitao @ 2026-03-27 10:18 UTC (permalink / raw) To: Masami Hiramatsu Cc: Jonathan Corbet, Shuah Khan, linux-kernel, linux-trace-kernel, linux-doc, oss, paulmck, rostedt, kernel-team On Thu, Mar 26, 2026 at 11:30:42PM +0900, Masami Hiramatsu wrote: > On Wed, 25 Mar 2026 23:22:04 +0900 > Masami Hiramatsu (Google) <mhiramat@kernel.org> wrote: > > > > + /* > > > + * Keys that do not match any early_param() handler are silently > > > + * ignored — do_early_param() always returns 0. > > > + */ > > > + xbc_node_for_each_key_value(root, knode, val) { > > > > [sashiko comment] > > | Does this loop handle array values correctly? > > | xbc_node_for_each_key_value() only assigns the first value of an array to > > | the val pointer before advancing to the next key. It does not iterate over > > | the child nodes of the array. > > | If the bootconfig contains a multi-value key like > > | kernel.console = "ttyS0", "tty0", will the subsequent values in the array > > | be silently dropped instead of passed to the early_param handlers? > > > > Also, good catch :) we need to use xbc_node_for_each_array_value() > > for inner loop. > > FYI, xbc_snprint_cmdline() translates the arraied parameter as > multiple parameters. For example, > > foo = bar, buz; > > will be converted to > > foo=bar foo=buz > > Thus, I think we should do the same thing below; > > > > > > + if (xbc_node_compose_key_after(root, knode, xbc_namebuf, XBC_KEYLEN_MAX) < 0) > > > + continue; > > > + > > > + /* > > > + * We need to copy const char *val to a char pointer, > > > + * which is what do_early_param() need, given it might > > > + * call strsep(), strtok() later. > > > + */ > > > + ret = strscpy(val_buf, val, sizeof(val_buf)); > > > + if (ret < 0) { > > > + pr_warn("ignoring bootconfig value '%s', too long\n", > > > + xbc_namebuf); > > > + continue; > > > + } > > > + do_early_param(xbc_namebuf, val_buf, NULL, NULL); > > So instead of this; > > xbc_array_for_each_value(vnode, val) { > do_early_param(xbc_namebuf, val, NULL, NULL); > } > > Maybe it is a good timing to recondier unifying kernel cmdline and bootconfig > from API viewpoint. I'm not familiar with the history on this topic. Has unifying the APIs been previously considered and set aside? Given all the feedback on this series, I see three types of issues to address: 1) Minor patch improvements 2) Architecture-specific super early parameters being parsed before bootconfig is available 3) Unifying kernel cmdline and bootconfig interfaces Which of these areas would you recommend I prioritize? Thanks for the guidance, --breno ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v2] bootconfig: Apply early options from embedded config 2026-03-27 10:18 ` Breno Leitao @ 2026-03-27 14:16 ` Masami Hiramatsu 2026-03-27 16:11 ` Breno Leitao 0 siblings, 1 reply; 8+ messages in thread From: Masami Hiramatsu @ 2026-03-27 14:16 UTC (permalink / raw) To: Breno Leitao Cc: Jonathan Corbet, Shuah Khan, linux-kernel, linux-trace-kernel, linux-doc, oss, paulmck, rostedt, kernel-team On Fri, 27 Mar 2026 03:18:31 -0700 Breno Leitao <leitao@debian.org> wrote: > On Thu, Mar 26, 2026 at 11:30:42PM +0900, Masami Hiramatsu wrote: > > On Wed, 25 Mar 2026 23:22:04 +0900 > > Masami Hiramatsu (Google) <mhiramat@kernel.org> wrote: > > > > > > + /* > > > > + * Keys that do not match any early_param() handler are silently > > > > + * ignored — do_early_param() always returns 0. > > > > + */ > > > > + xbc_node_for_each_key_value(root, knode, val) { > > > > > > [sashiko comment] > > > | Does this loop handle array values correctly? > > > | xbc_node_for_each_key_value() only assigns the first value of an array to > > > | the val pointer before advancing to the next key. It does not iterate over > > > | the child nodes of the array. > > > | If the bootconfig contains a multi-value key like > > > | kernel.console = "ttyS0", "tty0", will the subsequent values in the array > > > | be silently dropped instead of passed to the early_param handlers? > > > > > > Also, good catch :) we need to use xbc_node_for_each_array_value() > > > for inner loop. > > > > FYI, xbc_snprint_cmdline() translates the arraied parameter as > > multiple parameters. For example, > > > > foo = bar, buz; > > > > will be converted to > > > > foo=bar foo=buz > > > > Thus, I think we should do the same thing below; > > > > > > > > > + if (xbc_node_compose_key_after(root, knode, xbc_namebuf, XBC_KEYLEN_MAX) < 0) > > > > + continue; > > > > + > > > > + /* > > > > + * We need to copy const char *val to a char pointer, > > > > + * which is what do_early_param() need, given it might > > > > + * call strsep(), strtok() later. > > > > + */ > > > > + ret = strscpy(val_buf, val, sizeof(val_buf)); > > > > + if (ret < 0) { > > > > + pr_warn("ignoring bootconfig value '%s', too long\n", > > > > + xbc_namebuf); > > > > + continue; > > > > + } > > > > + do_early_param(xbc_namebuf, val_buf, NULL, NULL); > > > > So instead of this; > > > > xbc_array_for_each_value(vnode, val) { > > do_early_param(xbc_namebuf, val, NULL, NULL); > > } > > > > Maybe it is a good timing to recondier unifying kernel cmdline and bootconfig > > from API viewpoint. > > I'm not familiar with the history on this topic. Has unifying the APIs been > previously considered and set aside? Previously I considered but I found some early parameters must be composed by bootloaders, and they does not support bootconfig. Thus, I introduced setup_boot_config() to compose kernel.* parameters into cmdline buffer. > > Given all the feedback on this series, I see three types of issues to address: > > 1) Minor patch improvements > 2) Architecture-specific super early parameters being parsed before bootconfig > is available > 3) Unifying kernel cmdline and bootconfig interfaces I think we can start with 1) for embedded bootconfig for this series with using bootconfig in parse_early_param(). For 2), I think it needs to check which parameters are expected to be passed by bootloaders, which does not care bootconfig currently. For 3), eventually it may be need to change how kernel handle the parameters. I think I need to introduce CONFIG_BOOT_CONFIG_EXPOSED option which keeps the xbc_*() API and parsed data accessible after boot (Remove __init) and exposed to modules, so that all modules can use xbc_* to get parameters from bootconfig directly. Thanks, > > Which of these areas would you recommend I prioritize? > > Thanks for the guidance, > --breno -- Masami Hiramatsu (Google) <mhiramat@kernel.org> ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v2] bootconfig: Apply early options from embedded config 2026-03-27 14:16 ` Masami Hiramatsu @ 2026-03-27 16:11 ` Breno Leitao 0 siblings, 0 replies; 8+ messages in thread From: Breno Leitao @ 2026-03-27 16:11 UTC (permalink / raw) To: Masami Hiramatsu Cc: Jonathan Corbet, Shuah Khan, linux-kernel, linux-trace-kernel, linux-doc, oss, paulmck, rostedt, kernel-team On Fri, Mar 27, 2026 at 11:16:30PM +0900, Masami Hiramatsu wrote: > > Given all the feedback on this series, I see three types of issues to address: > > > > 1) Minor patch improvements > > 2) Architecture-specific super early parameters being parsed before bootconfig > > is available > > 3) Unifying kernel cmdline and bootconfig interfaces > > I think we can start with 1) for embedded bootconfig for this series > with using bootconfig in parse_early_param(). Thanks for the clear direction. I'll work on integrating bootconfig into parse_early_param() to see what can be achieved and identify any potential blockers. I should be back soon with more fun. Thanks so far, --breno ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v2] bootconfig: Apply early options from embedded config 2026-03-25 14:22 ` Masami Hiramatsu 2026-03-26 14:30 ` Masami Hiramatsu @ 2026-03-27 10:06 ` Breno Leitao 2026-03-27 13:37 ` Masami Hiramatsu 1 sibling, 1 reply; 8+ messages in thread From: Breno Leitao @ 2026-03-27 10:06 UTC (permalink / raw) To: Masami Hiramatsu Cc: Jonathan Corbet, Shuah Khan, linux-kernel, linux-trace-kernel, linux-doc, oss, paulmck, rostedt, kernel-team Hi Masami, On Wed, Mar 25, 2026 at 11:22:04PM +0900, Masami Hiramatsu wrote: > On Wed, 25 Mar 2026 03:05:38 -0700 > Breno Leitao <leitao@debian.org> wrote: > > +/* > > + * bootconfig_apply_early_params - dispatch kernel.* keys from the embedded > > + * bootconfig as early_param() calls. > > + * > > + * early_param() handlers must run before most of the kernel initialises > > + * (e.g. before the GIC driver reads irqchip.gicv3_pseudo_nmi). A bootconfig > > + * attached to the initrd arrives too late for this because the initrd is not > > + * mapped yet when early params are processed. The embedded bootconfig lives > > + * in the kernel image itself (.init.data), so it is always reachable. > > + * > > + * This function is called from setup_boot_config() which runs in > > + * start_kernel() before parse_early_param(), making the timing correct. > > + */ > > +static void __init bootconfig_apply_early_params(void) > > [sashiko comment] > | Does this run early enough for architectural parameters? > | While setup_boot_config() runs before parse_early_param() in start_kernel(), > | it runs after setup_arch(). setup_boot_config() relies on xbc_init() which > | uses the memblock allocator, requiring setup_arch() to have already > | initialized it. > | However, the kernel expects many early parameters (like mem=, earlycon, > | noapic, and iommu) to be parsed during setup_arch() via the architecture's > | call to parse_early_param(). Since setup_arch() completes before > | setup_boot_config() runs, will these architectural early parameters be > | silently ignored because the decisions they influence were already > | finalized? > > This is the major reason that I did not support early parameter > in bootconfig. Some archs initialize kernel_cmdline in setup_arch() > and setup early parameters in it. Would it be feasible to document which parameters are architecture-specific and must be processed during setup_arch()? We could potentially introduce a third parameter category alongside the existing early_param() and __setup(): * early_param() * __setup() * early_arch_param() (New) This would allow bootconfig to support __setup() and early_param() while explicitly excluding early_arch_param() from bootconfig processing. This would move break down the early parameters in those that can be easily handled. > To fix this, we need to change setup_arch() for each architecture so > that it calls this bootconfig_apply_early_params(). Could we instead integrate this into parse_early_param() itself? That approach would avoid the need to modify each architecture individually. Thanks for looking at it, --breno ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v2] bootconfig: Apply early options from embedded config 2026-03-27 10:06 ` Breno Leitao @ 2026-03-27 13:37 ` Masami Hiramatsu 0 siblings, 0 replies; 8+ messages in thread From: Masami Hiramatsu @ 2026-03-27 13:37 UTC (permalink / raw) To: Breno Leitao Cc: Jonathan Corbet, Shuah Khan, linux-kernel, linux-trace-kernel, linux-doc, oss, paulmck, rostedt, kernel-team On Fri, 27 Mar 2026 03:06:41 -0700 Breno Leitao <leitao@debian.org> wrote: > Hi Masami, > > On Wed, Mar 25, 2026 at 11:22:04PM +0900, Masami Hiramatsu wrote: > > On Wed, 25 Mar 2026 03:05:38 -0700 > > Breno Leitao <leitao@debian.org> wrote: > > > > +/* > > > + * bootconfig_apply_early_params - dispatch kernel.* keys from the embedded > > > + * bootconfig as early_param() calls. > > > + * > > > + * early_param() handlers must run before most of the kernel initialises > > > + * (e.g. before the GIC driver reads irqchip.gicv3_pseudo_nmi). A bootconfig > > > + * attached to the initrd arrives too late for this because the initrd is not > > > + * mapped yet when early params are processed. The embedded bootconfig lives > > > + * in the kernel image itself (.init.data), so it is always reachable. > > > + * > > > + * This function is called from setup_boot_config() which runs in > > > + * start_kernel() before parse_early_param(), making the timing correct. > > > + */ > > > +static void __init bootconfig_apply_early_params(void) > > > > [sashiko comment] > > | Does this run early enough for architectural parameters? > > | While setup_boot_config() runs before parse_early_param() in start_kernel(), > > | it runs after setup_arch(). setup_boot_config() relies on xbc_init() which > > | uses the memblock allocator, requiring setup_arch() to have already > > | initialized it. > > | However, the kernel expects many early parameters (like mem=, earlycon, > > | noapic, and iommu) to be parsed during setup_arch() via the architecture's > > | call to parse_early_param(). Since setup_arch() completes before > > | setup_boot_config() runs, will these architectural early parameters be > > | silently ignored because the decisions they influence were already > > | finalized? > > > > This is the major reason that I did not support early parameter > > in bootconfig. Some archs initialize kernel_cmdline in setup_arch() > > and setup early parameters in it. > > Would it be feasible to document which parameters are architecture-specific > and must be processed during setup_arch()? Yeah, at least we can mark what is not available in bootconfig. Or, maybe we can export this function to setup_arch() for each architecture. Anyway, some cmdline options are not possible to be passed via bootconfig. IIRC, for example, the initrd image address is passed via cmdline (via devicetree) on arm64 from bootloader. > > We could potentially introduce a third parameter category alongside the > existing early_param() and __setup(): > > * early_param() > * __setup() > * early_arch_param() (New) > > This would allow bootconfig to support __setup() and early_param() while > explicitly excluding early_arch_param() from bootconfig processing. Yeah, that maybe possible. > > This would move break down the early parameters in those that can be > easily handled. > > > To fix this, we need to change setup_arch() for each architecture so > > that it calls this bootconfig_apply_early_params(). > > Could we instead integrate this into parse_early_param() itself? That > approach would avoid the need to modify each architecture individually. Ah, indeed. Thanks! > > Thanks for looking at it, > --breno -- Masami Hiramatsu (Google) <mhiramat@kernel.org> ^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2026-03-27 16:11 UTC | newest] Thread overview: 8+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2026-03-25 10:05 [PATCH v2] bootconfig: Apply early options from embedded config Breno Leitao 2026-03-25 14:22 ` Masami Hiramatsu 2026-03-26 14:30 ` Masami Hiramatsu 2026-03-27 10:18 ` Breno Leitao 2026-03-27 14:16 ` Masami Hiramatsu 2026-03-27 16:11 ` Breno Leitao 2026-03-27 10:06 ` Breno Leitao 2026-03-27 13:37 ` Masami Hiramatsu
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox