[PATCH 3/5] boot: hand overrides on to nested boots and the bootm command
Ahmad Fatoum
a.fatoum at pengutronix.de
Fri Nov 13 00:52:43 PST 2026
Hello,
On 10/30/26 15:13, Sascha Hauer wrote:
> Overrides are stored in the boot entry they are given for and only
> applied by bootm_entry(). They get lost when a boot entry boots something
> else, like a boot script calling boot, or calling the bootm command.
>
> Keep track of the overrides of the boot entry being booted. Hand them on
> to boot entries booted from there, with the ones of the outer entry
> taking precedence, and apply them in the bootm command.
I think the current design grew out of compressed kernels inside FIT calling
bootm_boot from within bootm_boot. As this has been changed now, some
simplification may be possible.
> bootchooser no longer needs to merge the overrides into its targets itself.
That's a nice side effect.
>
> This is done in do_bootm() and not in bootm_boot(), which the Android
> image handler calls while a bootm is already running, so it would apply
> the overrides a second time.
1) That's not a pre-existng issue though, because there was no
global.boot.devboot yet, right?
2) Would an override with Android boot images even work with these changes?
It seems as if the overrides would not matter. I am not advocating for them
to work, but the commit message suggests they do. I am fine with them failing
with devboot enabled.
>
> Assisted-by: Claude:claude-opus-5-5
S-o-b missing.
> - ret = bootm_boot(&data);
> + ret = bootm_boot_overrides(&data, boot_get_active_overrides());
> if (ret) {
> printf("handler failed with: %pe\n", ERR_PTR(ret));
> goto err_out;
> diff --git a/common/boot.c b/common/boot.c
> index b993cabf65..271cfd3a29 100644
> --- a/common/boot.c
> +++ b/common/boot.c
> @@ -187,8 +187,23 @@ BAREBOX_MAGICVAR(global.boot.watchdog_timeout,
> BAREBOX_MAGICVAR(global.user,
> "Username used by the default environment to construct network boot paths");
>
> +/* The overrides of the boot entry currently being booted */
> +static const struct bootm_overrides *boot_active_overrides;
I am not a fan of this global. I think it makes it harder to reason about
things, which is unfortunate when we must avoid this development feature
introducing a backdoor to override a verified boot further down the line..
> int bootm_entry(struct bootentry *be, const struct bootm_data *bootm_data)
> {
> - struct image_data *data;
> - int ret;
> -
> - data = bootm_boot_prep(bootm_data);
> - if (IS_ERR(data))
> - return PTR_ERR(data);
> -
> - ret = bootm_apply_overrides(data, &be->overrides);
> - if (ret)
> - goto out;
> -
> - ret = bootm_boot_handler(data);
> -
> -out:
> - bootm_boot_cleanup(data);
> - return ret;
> + return bootm_boot_overrides(bootm_data, &be->overrides);
> }
I am wondering if FIT being booted by bootm instead of boot is the actual
problem here. Conceptually, a FIT should generate boot entries like blspec
and then one of them can be booted. If that were the case, bootm
would become really about booting the images that go into it and would
not extract loadables from images. If we had that, overrides could be cleanly
implemented by changing the loadables that go into bootm instead:
1) boot generates entries
2) overrides affect loadables
3) bootm processes loadables
I admit that will be a bigger rework though.
> diff --git a/common/bootm.c b/common/bootm.c
> index 2ad8c34bb4..2ed377da18 100644
> --- a/common/bootm.c
> +++ b/common/bootm.c
> @@ -785,7 +785,15 @@ void bootm_boot_cleanup(struct image_data *data)
> /*
> * bootm_boot - Boot an application image described by bootm_data
> */
Orphan comment
Thanks,
Ahmad
--
Pengutronix e.K. | |
Steuerwalder Str. 21 | http://www.pengutronix.de/ |
31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
More information about the barebox
mailing list