On Wed, Oct 28, 2026 at 08:55:26AM +0800, Bin Meng wrote:
> On Sat, Oct 17, 2026 at 5:19 AM Elliot Berman <[email protected]> wrote:
> >
> > Provide guidance for testing capsule updates on x86/x86_64.
> >
> > Signed-off-by: Elliot Berman <[email protected]>
> > ---
> > doc/board/emulation/qemu-x86.rst | 39
> > +++++++++++++++++++++++++++++++++++++--
> > 1 file changed, 37 insertions(+), 2 deletions(-)
> >
> > diff --git a/doc/board/emulation/qemu-x86.rst
> > b/doc/board/emulation/qemu-x86.rst
> > index c604e42990e..d40cc500994 100644
> > --- a/doc/board/emulation/qemu-x86.rst
> > +++ b/doc/board/emulation/qemu-x86.rst
> > @@ -113,17 +113,52 @@ sure the specified CPU supports 64-bit like '-cpu
> > core2duo'. Conversely
> > '-cpu pentium' won't work for obvious reasons that the processor only
> > supports 32-bit.
> >
> > +Running as flash binary
> > +-----------------------
> > +
> > +Running U-Boot from emulated flash lets QEMU write a new image back to the
> > ROM.
> > +This allows EFI capsule updates to be tested. To create a U-Boot binary
> > that can
> > +accept capsule updates, build qemu-x86_64_defconfig or qemu-x86_defconfig
> > with::
> > +
> > + CONFIG_EFI_CAPSULE_ON_DISK=y
> > + CONFIG_EFI_CAPSULE_FIRMWARE_RAW=y
>
> On x86, the linking of u-boot.rom failed due to address overlap (with
> gcc 15.2 on Ubuntu 26.04)
>
> LD u-boot
> /usr/bin/x86_64-linux-gnu-ld.bfd: section .rel.dyn VMA wraps around
> address space
> /usr/bin/x86_64-linux-gnu-ld.bfd: section .start16 LMA
> [fffff800,fffff86f] overlaps section .rel.dyn LMA [fffdfd78,00000c37]
> make: *** [Makefile:2131: u-boot] Err
>
I wasn't able to reproduce this on commit ee9fc27f2a2 ("cmd: mdio: check argc
for extended mode") using gcc 15.2 from NixOS.
> > +
> > +See :ref:`uefi_capsule_update_ref` for the full set of capsule options and
> > the
> > +general update procedure.
> > +
> > +Instead of the '-bios' option, attach u-boot.rom as writable pflash with
> > +readonly=false. For 64-bit U-Boot::
> > +
> > + $ qemu-system-x86_64 -nographic \
> > + -drive if=pflash,format=raw,file=path/to/u-boot.rom,readonly=off
> > +
> > +For 32-bit U-Boot::
> > +
> > + $ qemu-system-i386 -nographic \
> > + -drive if=pflash,format=raw,file=path/to/u-boot.rom,readonly=off
> > +
> > +Generate a capsule with mkeficapsule::
> > +
> > + $ mkeficapsule --index 1 --guid 5bb9ce0d-a389-456f-83a8-2bdfb8ad01a1 \
> > + u-boot.rom uboot.capsule # qemu-x86_64
>
> Please use u-boot.capsule as the file name.
>
> With gcc 15.2 on Ubuntu 26.04, the generated x86_64 uboot.capsule is
> about 2.1MiB, which slightly exceeds the SYS_MALLOC_LEN.
>
> as the malloc(file_size) in efi_capsule_read_file() reads the whole
> file at once by allocating the size of the capsule file.
>
Ah, thanks! I've mostly been testing by applying capsules using
EFI_RUNTIME_UPDATE_CAPSULE support. I think the straightforward thing to
do is use `efi_alloc_pool()` instead of `malloc()`. With this, we'll be
able to allocate more than SYS_MALLOC_LEN and able to apply capsule
updates from disk. I'll send this out in the next version.
Thanks,
Elliot