From: Daniel Golle <daniel@makrotopia.org>
To: Simon Glass <sjg@chromium.org>
Cc: "Tom Rini" <trini@konsulko.com>,
"Quentin Schulz" <quentin.schulz@cherry.de>,
"Kory Maincent" <kory.maincent@bootlin.com>,
"Mattijs Korpershoek" <mkorpershoek@kernel.org>,
"Martin Schwan" <m.schwan@phytec.de>,
"Anshul Dalal" <anshuld@ti.com>,
"Ilias Apalodimas" <ilias.apalodimas@linaro.org>,
"Sughosh Ganu" <sughosh.ganu@arm.com>,
"Aristo Chen" <jj251510319013@gmail.com>,
"牛 志宏" <Zone.Niuzh@hotmail.com>,
"Marek Vasut" <marek.vasut+renesas@mailbox.org>,
"Heinrich Schuchardt" <xypron.glpk@gmx.de>,
"Wolfgang Wallner" <wolfgang.wallner@at.abb.com>,
"Frank Wunderlich" <frank-w@public-files.de>,
"David Lechner" <dlechner@baylibre.com>,
"Osama Abdelkader" <osama.abdelkader@gmail.com>,
"Mikhail Kshevetskiy" <mikhail.kshevetskiy@iopsys.eu>,
"Michael Trimarchi" <michael@amarulasolutions.com>,
"Miquel Raynal" <miquel.raynal@bootlin.com>,
"Andrew Goodbody" <andrew.goodbody@linaro.org>,
"Yegor Yefremov" <yegorslists@googlemail.com>,
"Mike Looijmans" <mike.looijmans@topic.nl>,
"Weijie Gao" <weijie.gao@mediatek.com>,
"Alexander Stein" <alexander.stein@ew.tq-group.com>,
"Neil Armstrong" <neil.armstrong@linaro.org>,
"Mayuresh Chitale" <mchitale@ventanamicro.com>,
"Paul HENRYS" <paul.henrys_ext@softathome.com>,
u-boot@lists.denx.de, "John Crispin" <john@phrozen.org>,
"Paul Spooren" <mail@aparcar.org>
Subject: Re: [RFC PATCH 09/20] boot: fit: support on-demand loading in fit_image_load()
Date: Thu, 19 Feb 2026 16:47:49 +0000 [thread overview]
Message-ID: <aZc-tSa3jkduf9aJ@makrotopia.org> (raw)
In-Reply-To: <CAFLszTi3r_6VynzrZKkDNbcucntoEW=4nLCV_q8kv3+vQojLBg@mail.gmail.com>
On Thu, Feb 19, 2026 at 06:09:26AM -0700, Simon Glass wrote:
> Hi Daniel,
>
> On Mon, 16 Feb 2026 at 14:22, Daniel Golle <daniel@makrotopia.org> wrote:
> >
> > Add an on-demand loading path to fit_image_load() for use when
> > images->loader is set (storage-backed boot).
> >
> > For external-data FIT images, the new path avoids dereferencing
> > fit + data_offset (which would point into unmapped memory) and
> > instead:
> >
> > 1. Extracts the data offset and size from FDT properties
> > (data-position / data-offset + data-size) -- metadata only,
> > no payload access.
> >
> > 2. Returns early for IH_TYPE_FILESYSTEM sub-images, which stay on
> > storage and are never loaded into RAM (e.g. squashfs rootfs).
> >
> > 3. Determines the RAM destination:
> > - If the sub-image has a load address, loads directly there
> > via image_loader_map_to() (zero-copy).
> > - Otherwise, allocates scratch RAM via image_loader_map().
> >
> > 4. Verifies the hash/signature in-place using
> > fit_image_verify_with_data(), which is address-agnostic.
> >
> > 5. Jumps to the common tail, skipping the normal
> > fit_image_get_data() + memcpy() sequence since data is already
> > at its final location.
> >
> > The entire path is gated by 'if (images->loader && external)' and
> > USE_HOSTCC, so the existing in-memory flow is completely unchanged
> > when no loader is set or when building host tools.
> >
> > For inline-data FIT images (no data-position/data-offset), the FDT
> > structure loaded during format detection already contains all sub-
> > image data, so the existing path handles them correctly.
> >
> > Also adds a 'struct image_loader *loader' member to struct
> > bootm_headers (initialised to NULL).
> >
> > Signed-off-by: Daniel Golle <daniel@makrotopia.org>
> > ---
> > boot/image-fit.c | 96 ++++++++++++++++++++++++++++++++++++++++++++++++
> > include/image.h | 4 ++
> > 2 files changed, 100 insertions(+)
> >
> > diff --git a/boot/image-fit.c b/boot/image-fit.c
> > index 3ed69b5f7bc..73d3bf7df08 100644
> > --- a/boot/image-fit.c
> > +++ b/boot/image-fit.c
> > @@ -24,6 +24,7 @@ extern void *aligned_alloc(size_t alignment, size_t size);
> > #include <linux/sizes.h>
> > #include <errno.h>
> > #include <log.h>
> > +#include <image-loader.h>
> > #include <mapmem.h>
> > #include <asm/io.h>
> > #include <malloc.h>
> > @@ -2166,6 +2167,100 @@ int fit_image_load(struct bootm_headers *images, ulong addr,
> >
> > printf(" Trying '%s' %s subimage\n", fit_uname, prop_name);
> >
> > +#if !defined(USE_HOSTCC) && CONFIG_IS_ENABLED(IMAGE_LOADER)
>
> This function is far too long so this code should go in its own
> function. Also use if() and tools_build()
I have significantly changed this whole part and folded storage access
into fit_image_get_data(). A pre-loading stage in fit_image_load(), much
fewer lines than the current do-it-all storage path, currently still
remains in fit_image_load(). I will present it soon in a (manually...)
reworked RFCv2 once I looked into and adressed all the other comments
received for the initial RFC.
>
> > + /*
> > + * Storage-backed path: when an image_loader is active and the
> > + * sub-image uses external data, load the payload from storage
> > + * instead of dereferencing fit + data_offset. The FDT structure
> > + * (containing all metadata, hashes, and signatures) is already
> > + * in RAM; only the payload is on storage.
> > + *
> > + * Sequence:
> > + * 1. Print image info (fit_image_select with verify=0)
> > + * 2. Extract data location from FDT properties (no data access)
> > + * 3. Skip IH_TYPE_FILESYSTEM sub-images — they stay on storage
> > + * 4. Determine RAM destination (load address or scratch area)
> > + * 5. Read payload via image_loader_map_to() / image_loader_map()
> > + * 6. Verify hash/signature in-place
> > + * 7. Jump to common tail (FDT validation, output params)
> > + */
> > + if (images && images->loader) {
> > + int data_off = 0, data_sz = 0;
> > + bool external = false;
> > + u8 img_type;
> > +
> > + if (!fit_image_get_data_position(fit, noffset, &data_off)) {
> > + external = true;
> > + } else if (!fit_image_get_data_offset(fit, noffset, &data_off)) {
> > + external = true;
> > + data_off += ALIGN(fdt_totalsize(fit), 4);
> > + }
> > +
> > + if (external && !fit_image_get_data_size(fit, noffset, &data_sz)) {
> > + /* Print image info without verifying data */
> > + ret = fit_image_select(fit, noffset, 0);
> > + if (ret) {
> > + bootstage_error(bootstage_id + BOOTSTAGE_SUB_HASH);
> > + return ret;
> > + }
> > +
> > + /* Skip filesystem images — they stay on storage */
> > + if (!fit_image_get_type(fit, noffset, &img_type) &&
> > + img_type == IH_TYPE_FILESYSTEM) {
> > + *datap = 0;
> > + *lenp = 0;
> > + return noffset;
>
> Should add a comment here about why you are not doing verification. I
> assume the FS is protected with dm-verify, iwc should the root hash be
> stored in the FIT?
Yes, I agree with that. A single property won't be enough, so what I
came up with and currently test is a node under the image, ie.
dm-verity {
block-size = <0x1000>;
data-blocks = <0xdead>;
algo = "sha256";
root-hash = "averylonghashasstring";
salt = "anotherverylonghashasstring";
};
This is sufficient to then let U-Boot generate the dm-mod.create="..."
parameter handed over to the kernel.
Currently I'm just putting this in the its source file, but of course we
could also extend 'mkimage' to call 'veritysetup format ...' and
populate such section like it is done for the hashes.
next prev parent reply other threads:[~2026-02-19 16:48 UTC|newest]
Thread overview: 88+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-16 21:21 [RFC PATCH 00/20] boot: add OpenWrt boot method and on-demand FIT loading Daniel Golle
2026-02-16 21:21 ` [RFC PATCH 01/20] boot: add image_loader on-demand loading abstraction Daniel Golle
2026-02-19 13:09 ` Simon Glass
2026-02-16 21:21 ` [RFC PATCH 02/20] boot: image-loader: add block device backend Daniel Golle
2026-02-19 13:09 ` Simon Glass
2026-02-16 21:21 ` [RFC PATCH 03/20] mtd: add mtd_read_skip_bad() helper Daniel Golle
2026-02-16 21:21 ` [RFC PATCH 04/20] boot: image-loader: add MTD backend Daniel Golle
2026-02-16 21:21 ` [RFC PATCH 05/20] cmd: ubi: export ubi_find_volume() Daniel Golle
2026-02-19 13:09 ` Simon Glass
2026-02-16 21:22 ` [RFC PATCH 06/20] mtd: set flash_node on DT-created partitions Daniel Golle
2026-02-16 21:22 ` [RFC PATCH 07/20] cmd: ubi: add ubi_part_from_mtd() Daniel Golle
2026-02-16 21:22 ` [RFC PATCH 08/20] boot: image-loader: add UBI volume backend Daniel Golle
2026-02-19 13:09 ` Simon Glass
2026-02-19 16:51 ` Daniel Golle
2026-02-23 17:51 ` Simon Glass
2026-02-23 19:24 ` Daniel Golle
2026-02-23 19:30 ` Mikhail Kshevetskiy
2026-02-23 19:32 ` Mikhail Kshevetskiy
2026-02-24 0:12 ` Daniel Golle
2026-02-24 0:40 ` Mikhail Kshevetskiy
2026-02-24 1:06 ` Daniel Golle
2026-02-23 20:06 ` Daniel Golle
2026-02-16 21:22 ` [RFC PATCH 09/20] boot: fit: support on-demand loading in fit_image_load() Daniel Golle
2026-02-19 13:09 ` Simon Glass
2026-02-19 16:47 ` Daniel Golle [this message]
2026-02-23 17:51 ` Simon Glass
2026-02-24 12:41 ` Daniel Golle
2026-02-16 21:22 ` [RFC PATCH 10/20] cmd: bootm: accept storage device as image source Daniel Golle
2026-02-19 13:09 ` Simon Glass
2026-02-16 21:22 ` [RFC PATCH 11/20] test: boot: add image_loader unit tests Daniel Golle
2026-02-17 19:05 ` Tom Rini
2026-02-19 13:10 ` Simon Glass
2026-02-19 14:04 ` Tom Rini
2026-02-19 14:34 ` Simon Glass
2026-02-19 15:41 ` Tom Rini
2026-02-16 21:23 ` [RFC PATCH 12/20] doc: bootm: document direct storage boot Daniel Golle
2026-02-16 21:23 ` [RFC PATCH 13/20] boot: bootmeth: add OpenWrt boot method skeleton Daniel Golle
2026-02-19 13:09 ` Simon Glass
2026-02-19 14:00 ` Tom Rini
2026-02-19 14:31 ` Simon Glass
2026-02-19 15:31 ` Tom Rini
2026-02-19 16:52 ` Daniel Golle
2026-02-16 21:23 ` [RFC PATCH 14/20] boot: bootmeth: openwrt: implement read_bootflow for block devices Daniel Golle
2026-02-19 13:09 ` Simon Glass
2026-02-16 21:23 ` [RFC PATCH 15/20] boot: bootmeth: openwrt: implement boot via bootm storage path Daniel Golle
2026-02-19 13:09 ` Simon Glass
2026-02-16 21:23 ` [RFC PATCH 16/20] boot: bootdev: add MTD boot device Daniel Golle
2026-02-19 13:09 ` Simon Glass
2026-02-16 21:24 ` [RFC PATCH 17/20] boot: bootdev: add UBI " Daniel Golle
2026-02-19 13:09 ` Simon Glass
2026-02-19 16:56 ` Daniel Golle
2026-02-23 17:51 ` Simon Glass
2026-02-16 21:24 ` [RFC PATCH 18/20] boot: bootmeth: openwrt: support MTD and UBI bootdevs Daniel Golle
2026-02-19 13:09 ` Simon Glass
2026-02-16 21:24 ` [RFC PATCH 19/20] boot: bootmeth: openwrt: add openwrt_boot_script hook for bootconf Daniel Golle
2026-02-19 13:11 ` Simon Glass
2026-02-16 21:24 ` [RFC PATCH 20/20] boot: bootmeth: openwrt: add slot configuration from environment Daniel Golle
2026-02-19 13:11 ` Simon Glass
2026-02-16 22:16 ` [RFC PATCH 00/20] boot: add OpenWrt boot method and on-demand FIT loading Marek Vasut
2026-02-17 1:18 ` Daniel Golle
2026-02-17 2:04 ` Marek Vasut
2026-02-17 13:02 ` Daniel Golle
2026-02-17 19:15 ` Tom Rini
2026-02-17 13:32 ` Simon Glass
2026-02-17 15:08 ` Tom Rini
2026-02-17 17:46 ` Tom Rini
2026-02-23 19:32 ` Tom Rini
2026-02-24 11:57 ` Daniel Golle
2026-02-24 17:24 ` Tom Rini
2026-02-25 14:34 ` Daniel Golle
2026-02-25 22:16 ` Tom Rini
2026-02-25 23:49 ` Daniel Golle
2026-02-26 18:45 ` Tom Rini
2026-02-26 23:44 ` Simon Glass
2026-02-17 18:13 ` Tom Rini
2026-02-17 19:28 ` Daniel Golle
2026-02-17 19:35 ` Tom Rini
2026-02-17 21:07 ` Daniel Golle
2026-02-17 21:18 ` Tom Rini
[not found] ` <aZTqyRfqYe1iJ9EY@makrotopia.org>
2026-02-18 15:58 ` Tom Rini
2026-02-18 17:25 ` Daniel Golle
2026-02-18 20:33 ` Tom Rini
2026-02-24 0:37 ` Daniel Golle
2026-02-24 14:24 ` Tom Rini
2026-02-24 14:36 ` Daniel Golle
2026-02-18 23:08 ` Daniel Golle
2026-02-19 15:29 ` Tom Rini
2026-02-17 19:20 ` Tom Rini
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=aZc-tSa3jkduf9aJ@makrotopia.org \
--to=daniel@makrotopia.org \
--cc=Zone.Niuzh@hotmail.com \
--cc=alexander.stein@ew.tq-group.com \
--cc=andrew.goodbody@linaro.org \
--cc=anshuld@ti.com \
--cc=dlechner@baylibre.com \
--cc=frank-w@public-files.de \
--cc=ilias.apalodimas@linaro.org \
--cc=jj251510319013@gmail.com \
--cc=john@phrozen.org \
--cc=kory.maincent@bootlin.com \
--cc=m.schwan@phytec.de \
--cc=mail@aparcar.org \
--cc=marek.vasut+renesas@mailbox.org \
--cc=mchitale@ventanamicro.com \
--cc=michael@amarulasolutions.com \
--cc=mike.looijmans@topic.nl \
--cc=mikhail.kshevetskiy@iopsys.eu \
--cc=miquel.raynal@bootlin.com \
--cc=mkorpershoek@kernel.org \
--cc=neil.armstrong@linaro.org \
--cc=osama.abdelkader@gmail.com \
--cc=paul.henrys_ext@softathome.com \
--cc=quentin.schulz@cherry.de \
--cc=sjg@chromium.org \
--cc=sughosh.ganu@arm.com \
--cc=trini@konsulko.com \
--cc=u-boot@lists.denx.de \
--cc=weijie.gao@mediatek.com \
--cc=wolfgang.wallner@at.abb.com \
--cc=xypron.glpk@gmx.de \
--cc=yegorslists@googlemail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox