From: Christian Marangi <ansuelsmth@gmail.com>
To: Simon Glass <sjg@chromium.org>
Cc: Tom Rini <trini@konsulko.com>,
Mattijs Korpershoek <mkorpershoek@kernel.org>,
Marek Vasut <marek.vasut+renesas@mailbox.org>,
Heiko Schocher <hs@nabladev.com>,
Neil Armstrong <neil.armstrong@linaro.org>,
Alexey Charkov <alchark@flipper.net>,
Daniel Golle <daniel@makrotopia.org>,
Aristo Chen <aristo.chen@canonical.com>,
"Lucien.Jheng" <lucienzx159@gmail.com>,
Mehmet Fide <mehmet.fide@screeningeagle.com>,
Casey Connolly <casey.connolly@linaro.org>,
Michal Simek <michal.simek@amd.com>,
Quentin Schulz <quentin.schulz@cherry.de>,
Johan Jonker <jbx6244@gmail.com>, Anshul Dalal <anshuld@ti.com>,
Romain Gantois <romain.gantois@bootlin.com>,
Mateus Lima Alves <mateuslima.ti@gmail.com>,
Marcello Sylvester Bauer <marcello.bauer@9elements.com>,
Tan Siewert <tan.siewert@9elements.com>,
Peng Fan <peng.fan@nxp.com>,
Patrice Chotard <patrice.chotard@foss.st.com>,
Yao Zi <me@ziyao.cc>, Heinrich Schuchardt <xypron.glpk@gmx.de>,
Martin Schwan <m.schwan@phytec.de>,
u-boot@lists.u-boot-project.org
Subject: Re: [PATCH v8 5/7] misc: fw_loader: introduce FIP loader driver
Date: Fri, 23 Oct 2026 18:22:56 +0200 [thread overview]
Message-ID: <6adb89e4.df6a01f8.17b6a2.0e82@mx.google.com> (raw)
In-Reply-To: <CAFLszThunA9w1o0+7qT+5j_jvbZ23bt2wukSyjF5-Xf3qUyF6A@mail.gmail.com>
On Fri, Oct 23, 2026 at 09:12:32AM -0400, Simon Glass wrote:
> Hi Christian,
>
> On 2026-10-22T19:40:35, Christian Marangi (Ansuel) <ansuelsmth@gmail.com> wrote:
> > misc: fw_loader: introduce FIP loader driver
> >
> > Introduce a variant of the FS loader driver to extract images from FIP
> > image. These image can contain additional binary used to init Network
> > accelerator or PHY firmware blob.
> >
> > The way FIP handle image type is with the usage of UUID.
> >
> > This FIP loader driver implement a simple FIP image parser that check
> > every entry for a matching UUID.
> >
> > Similar to FS loader, this driver also support both UBI and Block
> > devices.
> >
> > Also an additional property is added to handle special case with eMMC
> > that doesn't have a GPT partition and require a global offset to
> > reference the FIP partition.
> >
> > An example usage of this driver is the following:
> >
> > [...]
> >
> > drivers/misc/Kconfig | 23 ++
> > drivers/misc/fw_loader/Makefile | 1 +
> > drivers/misc/fw_loader/fip_loader.c | 556 ++++++++++++++++++++++++++++++++++++
> > drivers/misc/fw_loader/internal.h | 2 +
> > 4 files changed, 582 insertions(+)
>
> > diff --git a/drivers/misc/fw_loader/fip_loader.c b/drivers/misc/fw_loader/fip_loader.c
> > @@ -0,0 +1,556 @@
> > +static int blk_read_fip_firmware(struct firmware *firmwarep,
> > + struct blk_desc *desc,
> > + struct disk_partition *part_info,
> > + unsigned int part_offset,
> > + const struct fip_toc_entry *ent)
> > +{
> > + unsigned int offset = part_info->start + part_offset;
>
> The parse path now uses lbaint_t, but this read path still truncates
> part_info->start to unsigned int, so on a large device the header is
> found but the data is read from the wrong block. Please can you use
> lbaint_t here too (and for blkcnt/blkstart, to match
> blk_parse_fip_firmware())?
>
> > diff --git a/drivers/misc/fw_loader/fip_loader.c b/drivers/misc/fw_loader/fip_loader.c
> > @@ -0,0 +1,556 @@
> > + size = min(firmwarep->size, (size_t)ent->size - offset);
> > + ret = ubi_volume_read(ubi_vol,
> > + (u8 *)firmwarep->data,
> > + ent->offset_address + offset,
> > + size);
> > + if (ret)
> > + return ret;
> > +
> > + return size - firmwarep->offset;
>
> 'size' already has the offset taken off, so this subtracts it twice.
> With a non-zero offset the UBI path returns less than it actually
> read, whereas the block path returns the full 'read' count. I think
> this should just be 'return size;'
>
> Also, ubi_volume_read() treats size == 0 as 'read the whole volume',
> which overruns the buffer. That happens if offset == ent->size (which
> the check in fw_get_fip_firmware() allows) or if the caller passes a
> zero-sized buffer. Please can you return early when size is 0?
>
!!! No idea ubi_volume_read() 0 is read all. Thanks a lot for noticing
this.
--
Ansuel
next prev parent reply other threads:[~2026-10-23 16:23 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-22 19:40 [PATCH v8 0/7] misc: fs_loader: reorg and split to FS and FW loader + FIP loader Christian Marangi
2026-10-22 19:40 ` [PATCH v8 1/7] misc: fs_loader: fix ubifs not unmounted on dev_get_priv error Christian Marangi
2026-10-22 19:40 ` [PATCH v8 2/7] misc: fs_loader: reorganize and split to FS loader and FW UCLASS Christian Marangi
2026-10-23 13:12 ` Simon Glass
2026-10-23 16:22 ` Christian Marangi
2026-10-22 19:40 ` [PATCH v8 3/7] misc: fw_loader: implement generic get_fw_loader_from_node() Christian Marangi
2026-10-22 19:40 ` [PATCH v8 4/7] misc: fw_loader: implement request_firmware_size() OP Christian Marangi
2026-10-22 19:40 ` [PATCH v8 5/7] misc: fw_loader: introduce FIP loader driver Christian Marangi
2026-10-23 13:12 ` Simon Glass
2026-10-23 16:22 ` Christian Marangi [this message]
2026-10-22 19:40 ` [PATCH v8 6/7] doc: dtbinding: Update documentation for Generic Firmware loader Christian Marangi
2026-10-23 13:12 ` Simon Glass
2026-10-22 19:40 ` [PATCH v8 7/7] test: dm: Add test for FW Loader feature Christian Marangi
2026-10-23 13:12 ` Simon Glass
2026-10-23 16:27 ` Christian Marangi
2026-10-23 13:12 ` [PATCH v8 0/7] misc: fs_loader: reorg and split to FS and FW loader + FIP loader Simon Glass
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=6adb89e4.df6a01f8.17b6a2.0e82@mx.google.com \
--to=ansuelsmth@gmail.com \
--cc=alchark@flipper.net \
--cc=anshuld@ti.com \
--cc=aristo.chen@canonical.com \
--cc=casey.connolly@linaro.org \
--cc=daniel@makrotopia.org \
--cc=hs@nabladev.com \
--cc=jbx6244@gmail.com \
--cc=lucienzx159@gmail.com \
--cc=m.schwan@phytec.de \
--cc=marcello.bauer@9elements.com \
--cc=marek.vasut+renesas@mailbox.org \
--cc=mateuslima.ti@gmail.com \
--cc=me@ziyao.cc \
--cc=mehmet.fide@screeningeagle.com \
--cc=michal.simek@amd.com \
--cc=mkorpershoek@kernel.org \
--cc=neil.armstrong@linaro.org \
--cc=patrice.chotard@foss.st.com \
--cc=peng.fan@nxp.com \
--cc=quentin.schulz@cherry.de \
--cc=romain.gantois@bootlin.com \
--cc=sjg@chromium.org \
--cc=tan.siewert@9elements.com \
--cc=trini@konsulko.com \
--cc=u-boot@lists.u-boot-project.org \
--cc=xypron.glpk@gmx.de \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.