bootconfig: Apply early options from embedded config
Subsystems (3)
PATCH v2 1/1 bootconfig: Apply early options from embedded config
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.
---
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/[email protected]
--- Documentation/admin-guide/bootconfig.rst | 4 ++ init/Kconfig | 6 +++ init/main.c | 68 +++++++++++++++++++++++++++++++- 3 files changed, 77 insertions(+), 1 deletion(-)
Documentation/admin-guide/bootconfig.rst +4 -0
@@ -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 ---------------------------------
init/Kconfig +6 -0
@@ -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
init/main.c +67 -1
90 lines not on this page · raw message
---
base-commit: 785f0eb2f85decbe7c1ef9ae922931f0194ffc2e
change-id: 20260323-early_bootconfig-2efc4509af3d
Best regards,
Signature · 1 line
Breno Leitao <[email protected]>
Masami Hiramatsu (Google)
maintainerHi Breno,
Quoted 18 lines · On Wed, 25 Mar 2026 03:05:38 -0700 Breno Leitao <[email protected]> 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 callsdo_early_param()for each one. It is called fromsetup_boot_config()immediately after a successfulxbc_init()on the embedded data, which happens beforeparse_early_param()runs instart_kernel().
Quoted 4 lines
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
Kconfigand 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
[..]
Quoted 20 lines
init/main.c +11
-0@@ -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. +*
init/main.c static int __init warn_bootconfig(char *str) · line 439
Quoted 10 lines
init/main.c +10
-0+* 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().
init/main.c static int __init warn_bootconfig(char *str) · line 441
Quoted 2 lines
init/main.c +2
-0+{ +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.
init/main.c static int __init warn_bootconfig(char *str) · line 454
Quoted 13 lines
init/main.c +13
-0+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.
Quoted 5 lines
init/main.c +5
-0+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,
init/main.c static int __init warn_bootconfig(char *str) · line 469
Quoted 10 lines
init/main.c +10
-0+* 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,
Quoted 47 lines
init/main.c +16
-2+ } +} +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-2efc4509af3dBest regards,
Signature · 1 line
Breno Leitao <[email protected]>
Signature · 1 line
Masami Hiramatsu (Google) <[email protected]>
Masami Hiramatsu (Google)
maintainerQuoted 15 lines · On Wed, 25 Mar 2026 23:22:04 +0900 Masami Hiramatsu (Google)…
init/main.c static int __init warn_bootconfig(char *str) · line 454
Quoted 5 lines
init/main.c +5
-0+/* +* 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?
Quoted 2 lines
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;
Quoted 16 lines
Quoted 6 lines
init/main.c +5
-0+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, init/main.c static int __init warn_bootconfig(char *str) · line 469
Quoted 10 lines
init/main.c +10
-0+* 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,
Signature · 1 line
Masami Hiramatsu (Google) <[email protected]>
Quoted 51 lines · Masami Hiramatsu
Quoted 15 lines · On Wed, 25 Mar 2026 23:22:04 +0900 Masami Hiramatsu (Google)…
init/main.c static int __init warn_bootconfig(char *str) · line 454
Quoted 5 lines
init/main.c +5
-0+/* +* 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?Quoted 2 lines
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;
Quoted 16 lines
Quoted 6 lines
init/main.c +5
-0+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, init/main.c static int __init warn_bootconfig(char *str) · line 469
Quoted 10 lines
init/main.c +10
-0+* 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;
Quoted 6 lines
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
Masami Hiramatsu (Google)
maintainerQuoted 56 lines · On Fri, 27 Mar 2026 03:18:31 -0700 Breno Leitao <[email protected]> wrote:
Quoted 55 lines · Masami Hiramatsu
Quoted 15 lines · On Wed, 25 Mar 2026 23:22:04 +0900 Masami Hiramatsu (Google)…
init/main.c static int __init warn_bootconfig(char *str) · line 454
Quoted 5 lines
init/main.c +5
-0+/* +* 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?Quoted 2 lines
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;
Quoted 16 lines
Quoted 6 lines
init/main.c +5
-0+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, init/main.c static int __init warn_bootconfig(char *str) · line 469
Quoted 10 lines
init/main.c +10
-0+* 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); }
Quoted 5 lines
Quoted 2 lines
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.
Quoted 7 lines
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,
Quoted 5 lines
Which of these areas would you recommend I prioritize?
Thanks for the guidance,
--breno
Signature · 1 line
Masami Hiramatsu (Google) <[email protected]>
Quoted 9 lines · Masami Hiramatsu
Quoted 6 lines
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 interfacesI 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
Hi Masami,
Quoted 31 lines · Masami Hiramatsu
Quoted 4 lines · On Wed, 25 Mar 2026 03:05:38 -0700 Breno Leitao <[email protected]> wrote:
init/main.c +4
-0+/* +* bootconfig_apply_early_params - dispatch kernel.* keys from the embedded +* bootconfig as early_param() calls. +* init/main.c static int __init warn_bootconfig(char *str) · line 439
Quoted 10 lines
init/main.c +10
-0+* 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?
Quoted 3 lines
This is the major reason that I did not support early parameter in bootconfig. Some archs initialize
kernel_cmdlineinsetup_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.
Quoted 2 lines
To fix this, we need to change
setup_arch()for each architecture so that it calls thisbootconfig_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
Masami Hiramatsu (Google)
maintainerQuoted 34 lines · On Fri, 27 Mar 2026 03:06:41 -0700 Breno Leitao <[email protected]> wrote:
Hi Masami,
Quoted 31 lines · Masami Hiramatsu
Quoted 4 lines · On Wed, 25 Mar 2026 03:05:38 -0700 Breno Leitao <[email protected]> wrote:
init/main.c +4
-0+/* +* bootconfig_apply_early_params - dispatch kernel.* keys from the embedded +* bootconfig as early_param() calls. +* init/main.c static int __init warn_bootconfig(char *str) · line 439
Quoted 10 lines
init/main.c +10
-0+* 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?
Quoted 6 lines
Quoted 3 lines
This is the major reason that I did not support early parameter in bootconfig. Some archs initialize
kernel_cmdlineinsetup_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.
Quoted 10 lines
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()andearly_param()while explicitly excludingearly_arch_param()from bootconfig processing.
Yeah, that maybe possible.
Quoted 9 lines
This would move break down the early parameters in those that can be easily handled.
Quoted 2 lines
To fix this, we need to change
setup_arch()for each architecture so that it calls thisbootconfig_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!
Quoted 3 lines
Thanks for looking at it,
--breno
Signature · 1 line
Masami Hiramatsu (Google) <[email protected]>
Quoted 10 lines · Masami Hiramatsu
Quoted 5 lines · On Fri, 27 Mar 2026 03:06:41 -0700 Breno Leitao <[email protected]> wrote:
Quoted 2 lines
To fix this, we need to change
setup_arch()for each architecture so that it calls thisbootconfig_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.
I investigated integrating bootconfig into parse_early_param() and hit a
blocker: xbc_init() and xbc_make_cmdline() depend on memblock_alloc(), but on most architectures (x86, arm64, arm, s390, riscv) parse_early_param() is called from setup_arch() _before_ memblock is initialized.
So, bootconfig will not be available as early as parse_early_param().
An alternative is replace memblock allocations in lib/bootconfig.c with static __initdata buffers, similar to Petr's approach in 2023:
https://lore.kernel.org/all/[email protected]/
But, there was concerns about the allocation size:
Petr Malat <[email protected]> wrote:
> To allow handling of early options, it's necessary to eliminate allocations > from embedded bootconfig handling
"Hm, my concern is that this can introduce some sort of overhead to parse the bootconfig."
Quoted 10 lines · Breno Leitao
Quoted 9 lines · Masami Hiramatsu
Quoted 5 lines · On Fri, 27 Mar 2026 03:06:41 -0700 Breno Leitao <[email protected]> wrote:
Quoted 2 lines
To fix this, we need to change
setup_arch()for each architecture so that it calls thisbootconfig_apply_early_params().Could we instead integrate this into
parse_early_param()itself? That approach would avoid the need to modify each architecture individually.
Quoted 6 lines
Quoted 1 line
Ah, indeed.
I investigated integrating bootconfig into
parse_early_param()and hit a
blocker:xbc_init()andxbc_make_cmdline()depend onmemblock_alloc(), but on most architectures (x86, arm64, arm, s390, riscv)parse_early_param()is called fromsetup_arch()_before_ memblock is initialized.
That said, I'd like to propose a simpler approach as a first step:
1) Keep calling bootconfig_apply_early_params() from setup_boot_config(). This is the least intrusive approach and expands bootconfig support to additional early boot parameters.
2) Document that architecture-specific early parameters might be ignored. If a parameter is consumed early enough (during setup_arch()), it will not see the bootconfig value.
3) Ensure that early bootconfig parameters don't overwrite the boot command line. For example, if the boot command line has foo=bar and bootconfig later has foo=baz, the command line value should take precedence. This prevents early boot code (in setup_arch()) from seeing a parameter value that will be changed later.
If that is OK, that is what I have right now:
commit dd6e00e41c381e5fef9d22dda02b104aa8f83101
Author: Breno Leitao <[email protected]> Date: Mon Mar 30 06:50:28 2026 -0700
bootconfig: Apply early options from embedded config
Bootconfig currently cannot apply 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.
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().
This allows early options such as:
kernel.mitigations = off
to be placed in the embedded bootconfig and take effect, without requiring them on the kernel command line.
If the same parameter appears on both the kernel command line and in the embedded bootconfig, the command-line value takes precedence:
bootconfig_apply_early_params() checks boot_command_line and skips any parameter already present there.
Known limitations are documented:
- Early options in initrd bootconfig are still silently ignored, as the initrd is only available after the early param window has closed.
- Arch-specific early params consumed during setup_arch() (e.g. mem=, earlycon, noapic) may not take effect from bootconfig.
Documentation/admin-guide/bootconfig.rst +9 -0
@@ -169,6 +169,15 @@ 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. + +Note that embedded bootconfig is parsed after ``setup_arch()``, so +early options that are consumed during architecture initialization +(e.g., ``mem=``, ``memmap=``, ``earlycon``, ``noapic``, ``nolapic``, +``acpi=``, ``numa=``, ``iommu=``) may not take effect from bootconfig. + Attaching a Boot Config to Initrd ---------------------------------
init/Kconfig +10 -0
@@ -1525,6 +1525,16 @@ 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. Early options consumed during setup_arch() (e.g. + mem=, memmap=, earlycon, noapic, acpi=, numa=, iommu=) may not + take effect. If the same early option + appears in both bootconfig and the kernel command line, the + command line value takes precedence. + If unsure, say N. config BOOT_CONFIG_EMBED_FILE
init/main.c +108 -1
132 lines not on this page · raw message
Masami Hiramatsu (Google)
maintainerQuoted 20 lines · On Mon, 30 Mar 2026 08:04:23 -0700 Breno Leitao <[email protected]> wrote:
Quoted 10 lines · Breno Leitao
Quoted 9 lines · Masami Hiramatsu
Quoted 5 lines · On Fri, 27 Mar 2026 03:06:41 -0700 Breno Leitao <[email protected]> wrote:
Quoted 2 lines
To fix this, we need to change
setup_arch()for each architecture so that it calls thisbootconfig_apply_early_params().Could we instead integrate this into
parse_early_param()itself? That approach would avoid the need to modify each architecture individually.Quoted 6 lines
Quoted 1 line
Ah, indeed.
I investigated integrating bootconfig into
parse_early_param()and hit a
blocker:xbc_init()andxbc_make_cmdline()depend onmemblock_alloc(), but on most architectures (x86, arm64, arm, s390, riscv)parse_early_param()is called fromsetup_arch()_before_ memblock is initialized.That said, I'd like to propose a simpler approach as a first step:
Quoted 7 lines
1) Keep calling
bootconfig_apply_early_params()fromsetup_boot_config(). This is the least intrusive approach and expands bootconfig support to additional early boot parameters.2) Document that architecture-specific early parameters might be ignored. If a parameter is consumed early enough (during
setup_arch()), it will not see the bootconfig value.
We have to carefully do this because what parameter is arch specific or not depends on architecture and undocumented.
How about introducing a new Kconfig, which supports early params by embedded bootconfig?
Quoted 6 lines
3) Ensure that early bootconfig parameters don't overwrite the boot command line. For example, if the boot command line has foo=bar and bootconfig later has foo=baz, the command line value should take precedence. This prevents early boot code (in
setup_arch()) from seeing a parameter value that will be changed later.
OK, this also needs to be considered. Currently we just pass the bootconfig parameters right before bootloader given parameters as "extra_command_line" if "bootconfig" in cmdline or CONFIG_BOOT_CONFIG_FORCE=y.
[boot_config(.kernel)]<command_line>[ -- [boot_config(.init)][init_command_line]]
This is currently expected behavior. The bootconfig parameters are expected to be overridden by command_line or command_line are appended.
If we change this for early params, we also should change the expected output of /proc/cmdline too. I think we have 2 options;
- As before, we expect the parameters provided by the boot configuration to be processed first and then overridden later by the command line.
Or,
- ignore all parameters which is given from the command line, this also updates existing setup_boot_config() (means xbc_snprint_cmdline() ).
Anyway, this behavior change will also be a bit critical... We have to announce it.
Quoted 3 lines
If that is OK, that is what I have right now:
Let me comment on it.
Quoted 7 lines
Documentation/admin-guide/bootconfig.rst +0
-0@@ -169,6 +169,15 @@ 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.
Documentation/admin-guide/bootconfig.rst Boot Kernel With a Boot Config · line 180
Quoted 10 lines
Documentation/admin-guide/bootconfig.rst +9
-0+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. + +Note that embedded bootconfig is parsed after ``setup_arch()``, so +early options that are consumed during architecture initialization +(e.g., ``mem=``, ``memmap=``, ``earlycon``, ``noapic``, ``nolapic``, +``acpi=``, ``numa=``, ``iommu=``) may not take effect from bootconfig. +
This is easy to explain, but it's quite troublesome for users to determine which parameters are unavailable. Currently we can identify it by git grep early_param -- arch/${ARCH}. But it is setup in setup_arch() we need to track the source code. (Or ask AI :))
Quoted 11 lines
Documentation/admin-guide/bootconfig.rst +0
-0Attaching a Boot Config to Initrd ---------------------------------init/Kconfig +0
-0@@ -1525,6 +1525,16 @@ 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.
init/Kconfig config BOOT_CONFIG_EMBED · line 1537
Quoted 10 lines
init/Kconfig +10
-0+ 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. Early options consumed during setup_arch() (e.g. + mem=, memmap=, earlycon, noapic, acpi=, numa=, iommu=) may not + take effect. If the same early option + appears in both bootconfig and the kernel command line, the + command line value takes precedence. +
As a compromise, how about making this a separate Kconfig?
config BOOT_CONFIG_EMBED_EARLY_PARAM
bool "Support early_params in embedded bootconfig"
and afterwards, we can introduce
depends on ARCH_BOOT_CONFIG_EMBED_EARLY_PARAM
Thank you,
Signature · 1 line
Masami Hiramatsu (Google) <[email protected]>
hello Masami,
Quoted 6 lines · Masami Hiramatsu
Quoted 5 lines
3) Ensure that early bootconfig parameters don't overwrite the boot command line. For example, if the boot command line has foo=bar and bootconfig later has foo=baz, the command line value should take precedence. This prevents early boot code (in
setup_arch()) from seeing a parameter value that will be changed later.
Quoted 8 lines
OK, this also needs to be considered. Currently we just pass the bootconfig parameters right before bootloader given parameters as "
extra_command_line" if "bootconfig" in cmdline orCONFIG_BOOT_CONFIG_FORCE=y.[boot_config(.kernel)]<command_line>[ -- [boot_config(.init)][init_command_line]]
This is currently expected behavior. The bootconfig parameters are expected to be overridden by
command_lineorcommand_lineare appended.
That's correct, and I have no intention of changing this behavior. Here's the current approach:
1) Early parameters from the bootloader are parsed first in setup_arch()
2) Subsequently, bootconfig_apply_early_params() is invoked. Any early parameter that was already parsed from the bootloader (in setup_arch()) will be skipped at this stage.
Quoted 6 lines
If we change this for early params, we also should change the expected output of
/proc/cmdlinetoo. I think we have 2 options;- As before, we expect the parameters provided by the boot configuration to be processed first and then overridden later by the command line.
Quoted 7 lines
Or,
- ignore all parameters which is given from the command line, this also updates existing
setup_boot_config()(meansxbc_snprint_cmdline()).Anyway, this behavior change will also be a bit critical... We have to announce it.
As mentioned above, I don't anticipate any changes to existing behavior. Bootconfig parsing remains unchanged. The only modification is that bootconfig_apply_early_params() will skip any early config parameter that's already present in the bootloader command line.
Quoted 8 lines
Documentation/admin-guide/bootconfig.rst Boot Kernel With a Boot Config · line 180
Quoted 5 lines
Documentation/admin-guide/bootconfig.rst +5
-0+Note that embedded bootconfig is parsed after ``setup_arch()``, so +early options that are consumed during architecture initialization +(e.g., ``mem=``, ``memmap=``, ``earlycon``, ``noapic``, ``nolapic``, +``acpi=``, ``numa=``, ``iommu=``) may not take effect from bootconfig. +This is easy to explain, but it's quite troublesome for users to determine which parameters are unavailable.
Agreed. This turned out to be significantly more complex than I initially anticipated.
I'm uncertain whether we can accomplish this without examining every early_parameter() implementation in depth.
Quoted 3 lines
Currently we can identify
it bygit grep early_param -- arch/${ARCH}. But it is setup insetup_arch()we need to track the source code. (Or ask AI :))
The challenge extends beyond that. There are numerous early_parameter() definitions scattered throughout the kernel that may or may not be utilized by setup_arch().
For example, consider early_param("mitigations", ..) in ./kernel/cpu.c. This modifies the cpu_mitigations global variable, which is referenced in various locations across different architectures.
It's worth noting that we have over 300 early_parameter() instances in the kernel.
Given this, analyzing all these early parameters and examining each one individually represents a substantial amount of work.
Are there alternative approaches? At this point, I'm leaning toward breaking bootconfig's dependency on memblock, allowing us to invoke it before setup_arch(). Is this the only practical solution available?!
Thanks,
--breno
Masami Hiramatsu (Google)
maintainerHi Breno,
Quoted 19 lines · On Tue, 31 Mar 2026 08:27:59 -0700 Breno Leitao <[email protected]> wrote:
hello Masami,
Quoted 6 lines · Masami Hiramatsu
Quoted 5 lines
3) Ensure that early bootconfig parameters don't overwrite the boot command line. For example, if the boot command line has foo=bar and bootconfig later has foo=baz, the command line value should take precedence. This prevents early boot code (in
setup_arch()) from seeing a parameter value that will be changed later.Quoted 8 lines
OK, this also needs to be considered. Currently we just pass the bootconfig parameters right before bootloader given parameters as "
extra_command_line" if "bootconfig" in cmdline orCONFIG_BOOT_CONFIG_FORCE=y.[boot_config(.kernel)]<command_line>[ -- [boot_config(.init)][init_command_line]]
This is currently expected behavior. The bootconfig parameters are expected to be overridden by
command_lineorcommand_lineare appended.
Quoted 8 lines
That's correct, and I have no intention of changing this behavior. Here's the current approach:
1) Early parameters from the bootloader are parsed first in
setup_arch()2) Subsequently,
bootconfig_apply_early_params()is invoked. Any early parameter that was already parsed from the bootloader (insetup_arch()) will be skipped at this stage.
Ah, I meant if we skip these parameters, we should not show it in the command line via extra_command_line. This is still a minor issue at this point. It should find early parameters in kernel.* parameters and do not show it in extra_command_line, because those parameters are ignored. So it is better to make a separated patch to fix that.
For example, if we pass
kernel.mem=1G
via bootconfig, it will be shown in the /proc/cmdline, but it is not applied. This can confuse user.
Quoted 12 lines
Quoted 12 lines
If we change this for early params, we also should change the expected output of
/proc/cmdlinetoo. I think we have 2 options;- As before, we expect the parameters provided by the boot configuration to be processed first and then overridden later by the command line.
Or,
- ignore all parameters which is given from the command line, this also updates existing
setup_boot_config()(meansxbc_snprint_cmdline()).
Quoted 7 lines
Quoted 2 lines
Anyway, this behavior change will also be a bit critical... We have to announce it.
As mentioned above, I don't anticipate any changes to existing behavior. Bootconfig parsing remains unchanged. The only modification is that
bootconfig_apply_early_params()will skip any early config parameter that's already present in the bootloader command line.
Yes, but it is just different from existing one.
Suppose that if we have "early" and "normal" keys in the kernel, those are handled by early_param() and __setup() respectively.
If we use bootconfig, like
kernel {
early = bconf_val
normal = bconf_val
}
And passes "early=foo normal=bar" via cmdline.
In this case, the /proc/cmdline eventually has
"early=bconf_val normal=bconf_val early=foo normal=bar"
And the "normal" callback called with "bconf_val" and "bar" twice. However, "early" callback will be called with "foo" only once.
That can confuse users too.
I believe it's important for the system to behave in a way that is as close as possible to the user's mind model.
Because the behavior is inconsistent when multiple parameters with the same name are specified on the kernel command line, it is necessary to ensure that users can later look at it and infer what happened.
I mean, if a parameter is skipped, it should not be printed at /proc/cmdline, because it can mislead user (and maybe bug reporter) when a problem happens.
Quoted 10 lines
Quoted 9 lines
Documentation/admin-guide/bootconfig.rst Boot Kernel With a Boot Config · line 180
Quoted 6 lines
Documentation/admin-guide/bootconfig.rst +5
-0+Note that embedded bootconfig is parsed after ``setup_arch()``, so +early options that are consumed during architecture initialization +(e.g., ``mem=``, ``memmap=``, ``earlycon``, ``noapic``, ``nolapic``, +``acpi=``, ``numa=``, ``iommu=``) may not take effect from bootconfig. +This is easy to explain, but it's quite troublesome for users to determine which parameters are unavailable.
Quoted 2 lines
Agreed. This turned out to be significantly more complex than I initially anticipated.
Yeah, that's complicated.
Quoted 3 lines
I'm uncertain whether we can accomplish this without examining every
early_parameter()implementation in depth.
Agreed. My proposal is something like a divide and conquer approach. Since these are implemented architecture by architecture, you need to check the implementation for each architecture, and I think it's best to implement them one by one using Kconfig.
Quoted 13 lines
Quoted 4 lines
Currently we can identify
it bygit grep early_param -- arch/${ARCH}. But it is setup insetup_arch()we need to track the source code. (Or ask AI :))The challenge extends beyond that. There are numerous
early_parameter()definitions scattered throughout the kernel that may or may not be utilized bysetup_arch().For example, consider
early_param("mitigations", ..)in./kernel/cpu.c. This modifies thecpu_mitigationsglobal variable, which is referenced in various locations across different architectures.
Quoted 5 lines
It's worth noting that we have over 300
early_parameter()instances in the kernel.Given this, analyzing all these early parameters and examining each one individually represents a substantial amount of work.
Yes, that may require a substantial amount of work. But to improve the kernel framework around the parameter handling, eventually we need to examine each early parameter.
Quoted 4 lines
Are there alternative approaches? At this point, I'm leaning toward breaking bootconfig's dependency on memblock, allowing us to invoke it before
setup_arch(). Is this the only practical solution available?!
Basically, the memblock dependency comes from allocating copy of data. Only for the embedded bootconfig, we can just pass copy memory block to the xbc_init(). Something like;
xbc_init() {
xbc_data = memblock_alloc();
memcpy(xbc_data, data);
__xbc_init(xbc_data);
}
embedded_xbc_init() {
__xbc_init(embedded_bootconfig_data);
}
Afterwards, we can pass mixture of embedded bootcofnigt and initrd bootconfig data to parser again.
(But in this case, we must be careful not to override the early
parameters that we have already applied.)
Thank you,
Signature · 1 line
Masami Hiramatsu (Google) <[email protected]>
Quoted 11 lines · Masami Hiramatsu
Quoted 11 lines
The challenge extends beyond that. There are numerous
early_parameter()definitions scattered throughout the kernel that may or may not be utilized bysetup_arch().For example, consider
early_param("mitigations", ..)in./kernel/cpu.c. This modifies thecpu_mitigationsglobal variable, which is referenced in various locations across different architectures.It's worth noting that we have over 300
early_parameter()instances in the kernel.
Quoted 6 lines
Quoted 2 lines
Given this, analyzing all these early parameters and examining each one individually represents a substantial amount of work.
Yes, that may require a substantial amount of work. But to improve the kernel framework around the parameter handling, eventually we need to examine each early parameter.
I'm still uncertain about this approach. The goal is to identify and categorize the early parameters that are parsed prior to bootconfig initialization.
Moreover, this work could become obsolete if bootconfig's initialization point shifts earlier or later in the boot sequence, necessitating another comprehensive analysis.
Conversely, if we successfully move bootconfig initialization earlier by breaking the dependency of memblock (assuming this is feasible), the vast majority of early parameters would execute after bootconfig is configured, eliminating the need for this extensive categorization work.
Please, feel free to tell what approach might be better for the project.
Quoted 18 lines
Quoted 3 lines
Are there alternative approaches? At this point, I'm leaning toward breaking bootconfig's dependency on memblock, allowing us to invoke it before
setup_arch(). Is this the only practical solution available?!Basically, the memblock dependency comes from allocating copy of data. Only for the embedded bootconfig, we can just pass copy memory block to the
xbc_init(). Something like;
xbc_init(){
xbc_data=memblock_alloc();
memcpy(xbc_data, data);
__xbc_init(xbc_data);
}
embedded_xbc_init(){
__xbc_init(embedded_bootconfig_data);
}
Quoted 5 lines
Afterwards, we can pass mixture of embedded bootcofnigt and initrd bootconfig data to parser again.
(But in this case, we must be careful not to override the early
parameters that we have already applied.)
Do you have any additional recommendations if I proceed with this approach?
Thank you for your detailed responses and insights. --breno
Masami Hiramatsu (Google)
maintainerQuoted 16 lines · On Wed, 1 Apr 2026 08:01:48 -0700 Breno Leitao <[email protected]> wrote:
Quoted 14 lines · Masami Hiramatsu
Quoted 13 lines
The challenge extends beyond that. There are numerous
early_parameter()definitions scattered throughout the kernel that may or may not be utilized bysetup_arch().For example, consider
early_param("mitigations", ..)in./kernel/cpu.c. This modifies thecpu_mitigationsglobal variable, which is referenced in various locations across different architectures.It's worth noting that we have over 300
early_parameter()instances in the kernel.Given this, analyzing all these early parameters and examining each one individually represents a substantial amount of work.
Quoted 7 lines
Quoted 3 lines
Yes, that may require a substantial amount of work. But to improve the kernel framework around the parameter handling, eventually we need to examine each early parameter.
I'm still uncertain about this approach. The goal is to identify and categorize the early parameters that are parsed prior to bootconfig initialization.
Yes, if we support early parameters in bootconfig, we need to clarify which parameters are inherently unsupportable, and document it. Currently it is easy to say that it does not support the parameter defined with "early_param()". Similary, maybe we should introduce "arch_param()" or something like it (or support all of them).
Quoted 4 lines
Moreover, this work could become obsolete if bootconfig's initialization point shifts earlier or later in the boot sequence, necessitating another comprehensive analysis.
If we can init it before calling setup_arch(), yes, we don't need to check it. So that is another option. Do you think it is feasible to support all of them? (Of course, theologically we can do, but the question is the use case and requirements.)
Quoted 4 lines
Conversely, if we successfully move bootconfig initialization earlier by breaking the dependency of memblock (assuming this is feasible), the vast majority of early parameters would execute after bootconfig is configured, eliminating the need for this extensive categorization work.
OK, I agreed.
Quoted 21 lines
Please, feel free to tell what approach might be better for the project.
Quoted 18 lines
Quoted 3 lines
Are there alternative approaches? At this point, I'm leaning toward breaking bootconfig's dependency on memblock, allowing us to invoke it before
setup_arch(). Is this the only practical solution available?!Basically, the memblock dependency comes from allocating copy of data. Only for the embedded bootconfig, we can just pass copy memory block to the
xbc_init(). Something like;
xbc_init(){
xbc_data=memblock_alloc();
memcpy(xbc_data, data);
__xbc_init(xbc_data);
}
embedded_xbc_init(){
__xbc_init(embedded_bootconfig_data);
}
Quoted 8 lines
Quoted 5 lines
Afterwards, we can pass mixture of embedded bootcofnigt and initrd bootconfig data to parser again.
(But in this case, we must be careful not to override the early
parameters that we have already applied.)Do you have any additional recommendations if I proceed with this approach?
OK,
First of all, even if we enable early parameter support in bootconfig, this is only possible if bootconfig is embedded. In that case, we can pass memory that has been pre-allocated at compile time to bootconfig as a working area. However, this will consume a lot of memory, so it needs to be selectable in Kconfig.
If you're going to embed this, as Kiryl pointed out[1], it might be better to pass pre-normalized (or compiled) data and avoid using a parser. Compilation itself is relatively easy if you utilize the tools/bootconfig. (However, in this case, there doesn't seem to be much point in using
bootconfig in the first place because we also can use embed kernel cmdline.)
[1] https://lore.kernel.org/all/acueCFv4neO7zQGI@thinkstation/
Can you clarify the main reason of requesting this feature and examples?
Thank you,
Quoted 3 lines
Thank you for your detailed responses and insights. --breno
Signature · 1 line
Masami Hiramatsu (Google) <[email protected]>
Quoted 11 lines · Masami Hiramatsu
Quoted 3 lines
I'm still uncertain about this approach. The goal is to identify and categorize the early parameters that are parsed prior to bootconfig initialization.
Yes, if we support early parameters in bootconfig, we need to clarify which parameters are inherently unsupportable, and document it. Currently it is easy to say that it does not support the parameter defined with "
early_param()". Similary, maybe we should introduce "arch_param()" or something like it (or support all of them).Quoted 1 line
Quoted 8 lines
Quoted 3 lines
Moreover, this work could become obsolete if bootconfig's initialization point shifts earlier or later in the boot sequence, necessitating another comprehensive analysis.
If we can init it before calling
setup_arch(), yes, we don't need to check it. So that is another option. Do you think it is feasible to support all of them? (Of course, theologically we can do, but the question is the use case and requirements.)
I don't believe all early parameters can be supported by bootconfig. Some are inherently incompatible as far as I understand, while others depend on bootconfig's initialization point in the boot sequence.
Regarding documenting arch_param(), I need clarification: should we document parameters that are currently called before bootconfig (as of today), or those that fundamentally cannot be called by bootconfig regardless of its location?
Quoted 18 lines
Quoted 2 lines
Do you have any additional recommendations if I proceed with this approach?
OK,
First of all, even if we enable early parameter support in bootconfig, this is only possible if bootconfig is embedded. In that case, we can pass memory that has been pre-allocated at compile time to bootconfig as a working area. However, this will consume a lot of memory, so it needs to be selectable in
Kconfig.If you're going to embed this, as Kiryl pointed out[1], it might be better to pass pre-normalized (or compiled) data and avoid using a parser. Compilation itself is relatively easy if you utilize the
tools/bootconfig. (However, in this case, there doesn't seem to be much point in using
bootconfig in the first place because we also can use embed kernel cmdline.)
Quoted 4 lines
[1] https://lore.kernel.org/all/acueCFv4neO7zQGI@thinkstation/
Can you clarify the main reason of requesting this feature and examples?
My primary objective is to enable early configuration of irqchip.gicv3_pseudo_nmi, allowing the kernel to support pseudo NMI on arm64 by default.
Quoted 16 lines · Breno Leitao
Quoted 15 lines · Masami Hiramatsu
Quoted 3 lines
I'm still uncertain about this approach. The goal is to identify and categorize the early parameters that are parsed prior to bootconfig initialization.
Yes, if we support early parameters in bootconfig, we need to clarify which parameters are inherently unsupportable, and document it. Currently it is easy to say that it does not support the parameter defined with "
early_param()". Similary, maybe we should introduce "arch_param()" or something like it (or support all of them).Quoted 4 lines
Moreover, this work could become obsolete if bootconfig's initialization point shifts earlier or later in the boot sequence, necessitating another comprehensive analysis.
Quoted 8 lines
Quoted 4 lines
If we can init it before calling
setup_arch(), yes, we don't need to check it. So that is another option. Do you think it is feasible to support all of them? (Of course, theologically we can do, but the question is the use case and requirements.)I don't believe all early parameters can be supported by bootconfig. Some are inherently incompatible as far as I understand, while others depend on bootconfig's initialization point in the boot sequence.
I've developed a patch series that relocates bootconfig initialization to occur before setup_arch().
Adopting this approach would streamline the categorization considerably, as only a small subset of kernel parameters are parsed before setup_arch() is called.
This enables a clearer distinction: parameters processed *before* setup_arch() versus those handled afterward, rather than classifying based on what occurs before bootconfig initialization.
Just to close the look and link both discussion together, the proposed patch series is available at:
Masami Hiramatsu (Google)
maintainerQuoted 33 lines · On Wed, 15 Apr 2026 04:15:57 -0700 Breno Leitao <[email protected]> wrote:
Quoted 16 lines · Breno Leitao
Quoted 15 lines · Masami Hiramatsu
Quoted 3 lines
I'm still uncertain about this approach. The goal is to identify and categorize the early parameters that are parsed prior to bootconfig initialization.
Yes, if we support early parameters in bootconfig, we need to clarify which parameters are inherently unsupportable, and document it. Currently it is easy to say that it does not support the parameter defined with "
early_param()". Similary, maybe we should introduce "arch_param()" or something like it (or support all of them).Quoted 4 lines
Moreover, this work could become obsolete if bootconfig's initialization point shifts earlier or later in the boot sequence, necessitating another comprehensive analysis.
Quoted 8 lines
Quoted 4 lines
If we can init it before calling
setup_arch(), yes, we don't need to check it. So that is another option. Do you think it is feasible to support all of them? (Of course, theologically we can do, but the question is the use case and requirements.)I don't believe all early parameters can be supported by bootconfig. Some are inherently incompatible as far as I understand, while others depend on bootconfig's initialization point in the boot sequence.
I've developed a patch series that relocates bootconfig initialization to occur before
setup_arch().Adopting this approach would streamline the categorization considerably, as only a small subset of kernel parameters are parsed before
setup_arch()is called.
Quoted 8 lines
This enables a clearer distinction: parameters processed *before*
setup_arch()versus those handled afterward, rather than classifying based on what occurs before bootconfig initialization.Just to close the look and link both discussion together, the proposed patch series is available at:
Thanks for working on this series!! Let me review the series.
BTW, I found that the current __setup(), early_param(), module_param() are a bit complicated, for example, __setup() and early_param() are stored in the different array of module_param(), and those can use the same parameter (e.g. console).
And as you found some of early_param() options are only applied via command line. Maybe we can introduce another special macro which is only for command line.
Thanks,
Signature · 1 line
Masami Hiramatsu (Google) <[email protected]>
Masami Hiramatsu (Google)
maintainerQuoted 10 lines · On Mon, 30 Mar 2026 06:15:17 -0700 Breno Leitao <[email protected]> wrote:
Quoted 9 lines · Masami Hiramatsu
Quoted 5 lines · On Fri, 27 Mar 2026 03:06:41 -0700 Breno Leitao <[email protected]> wrote:
Quoted 2 lines
To fix this, we need to change
setup_arch()for each architecture so that it calls thisbootconfig_apply_early_params().Could we instead integrate this into
parse_early_param()itself? That approach would avoid the need to modify each architecture individually.
Quoted 6 lines
Quoted 1 line
Ah, indeed.
I investigated integrating bootconfig into
parse_early_param()and hit a
blocker:xbc_init()andxbc_make_cmdline()depend onmemblock_alloc(), but on most architectures (x86, arm64, arm, s390, riscv)parse_early_param()is called fromsetup_arch()_before_ memblock is initialized.
Yeah, that's right.
Quoted 8 lines
So, bootconfig will not be available as early as
parse_early_param().An alternative is replace memblock allocations in
lib/bootconfig.cwith static__initdatabuffers, similar to Petr's approach in 2023:https://lore.kernel.org/all/[email protected]/
Quoted 8 lines
But, there was concerns about the allocation size:
Petr Malat <[email protected]> wrote:
> To allow handling of early options, it's necessary to eliminate allocations > from embedded bootconfig handling"Hm, my concern is that this can introduce some sort of overhead to parse the bootconfig."
As far as we can correctly handle the early params and it is limited only with the embedded bootconfig, I think it is OK to allocate it statically.
Thank you,
Signature · 1 line
Masami Hiramatsu (Google) <[email protected]>
Quoted 43 lines · Masami Hiramatsu
Quoted 19 lines
init/main.c +11
-0@@ -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. +* init/main.c static int __init warn_bootconfig(char *str) · line 439
Quoted 10 lines
init/main.c +10
-0+* 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?
Quoted 5 lines
This is the major reason that I did not support early parameter in bootconfig. Some archs initialize
kernel_cmdlineinsetup_arch()and setup early parameters in it.
To fix this, we need to changesetup_arch()for each architecture so that it calls thisbootconfig_apply_early_params().
Hi Masami,
I have a question about bootconfig design. Is it necessary to parse the bootconfig at boot time?
We could avoid a lot of complexity if we flattened the bootconfig into a simple key-value list before embedding it in the kernel image or attaching it to the initrd. That would eliminate the need for memory allocations and allow the config to be used earlier during boot.
What am I missing?
Signature · 1 line
Kiryl Shutsemau / Kirill A. Shutemov
Masami Hiramatsu (Google)
maintainerQuoted 52 lines · On Tue, 31 Mar 2026 11:18:33 +0100 Kiryl Shutsemau <[email protected]> wrote:
Quoted 43 lines · Masami Hiramatsu
Quoted 19 lines
init/main.c +11
-0@@ -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. +* init/main.c static int __init warn_bootconfig(char *str) · line 439
Quoted 10 lines
init/main.c +10
-0+* 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?Quoted 5 lines
This is the major reason that I did not support early parameter in bootconfig. Some archs initialize
kernel_cmdlineinsetup_arch()and setup early parameters in it.
To fix this, we need to changesetup_arch()for each architecture so that it calls thisbootconfig_apply_early_params().Hi Masami,
Quoted 7 lines
I have a question about bootconfig design. Is it necessary to parse the bootconfig at boot time?
We could avoid a lot of complexity if we flattened the bootconfig into a simple key-value list before embedding it in the kernel image or attaching it to the initrd. That would eliminate the need for memory allocations and allow the config to be used earlier during boot.
Hi Kiryl,
Thanks for a good question.
If it is embedded in the kernel, yes, we can compile it. But if it is attached to initrd, the kernel needs to verify it. So anyway we have to parse the key-value. Of course we can make it a binary data structure, but it still needs verification. Moreover, memory allocation is not required by design (the first design uses a statically allocated data).
Even if it is normalized as key-value, we can not trust the contents without outer verification system, like verified boot. Therefore, our basic strategy is to parse the text.
However, if the content can be verified externally, for example, if a verified boot program verifies the compiled boot configuration, then it would be possible to use that directly.
Thank you,
Quoted 5 lines
What am I missing?
Signature · 1 line
Kiryl Shutsemau / Kirill A. Shutemov
Signature · 1 line
Masami Hiramatsu (Google) <[email protected]>
Quoted 73 lines · Masami Hiramatsu
Quoted 52 lines · On Tue, 31 Mar 2026 11:18:33 +0100 Kiryl Shutsemau <[email protected]> wrote:
Quoted 43 lines · Masami Hiramatsu
Quoted 19 lines
init/main.c +11
-0@@ -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. +* init/main.c static int __init warn_bootconfig(char *str) · line 439
Quoted 10 lines
init/main.c +10
-0+* 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?Quoted 5 lines
This is the major reason that I did not support early parameter in bootconfig. Some archs initialize
kernel_cmdlineinsetup_arch()and setup early parameters in it.
To fix this, we need to changesetup_arch()for each architecture so that it calls thisbootconfig_apply_early_params().Hi Masami,
Quoted 7 lines
I have a question about bootconfig design. Is it necessary to parse the bootconfig at boot time?
We could avoid a lot of complexity if we flattened the bootconfig into a simple key-value list before embedding it in the kernel image or attaching it to the initrd. That would eliminate the need for memory allocations and allow the config to be used earlier during boot.
Hi Kiryl,
Thanks for a good question.
If it is embedded in the kernel, yes, we can compile it. But if it is attached to initrd, the kernel needs to verify it. So anyway we have to parse the key-value. Of course we can make it a binary data structure, but it still needs verification. Moreover, memory allocation is not required by design (the first design uses a statically allocated data).
Quoted 3 lines
Even if it is normalized as key-value, we can not trust the contents without outer verification system, like verified boot. Therefore, our basic strategy is to parse the text.
Hm. I am not sure what issues verification aims to solve. Could you elaborate.
With normalized key-value structure, we should be able to extract the needed value in the same way as with normal kernel command line, no?
Signature · 1 line
Kiryl Shutsemau / Kirill A. Shutemov