[PATCH v8 2/2] efi_loader: Improve disk image detection in efi_bootmgr
Ilias Apalodimas
ilias.apalodimas at linaro.org
Fri Oct 10 13:19:46 CEST 2025
On Thu, 9 Oct 2025 at 16:18, Javier Tia <javier.tia at linaro.org> wrote:
>
> Enhances the process for identifying disk images within the EFI boot
> manager. Utilize part_driver_lookup_type() to verify the validity of a
> downloaded file as a disk image, rather than depending on file
> extensions.
>
> part_driver_lookup_type() is now used in the prepare_loaded_image()
> function in the EFI boot manager to detect partitions on a block device
> created from a downloaded image. This allows the boot manager to boot
> from any disk image that can be recognized by a partition driver, not
> just ISO and IMG images.
>
> Update prepare_loaded_image() to create the ramdisk block device
> internally, obtain the blk_desc and use part_driver_lookup_type() to
> detect a valid partition table.
>
> In try_load_from_uri_path(), try prepare_loaded_image() first to detect
> disk images, and fall back to PE-COFF detection only if that fails.
>
> Signed-off-by: Javier Tia <javier.tia at linaro.org>
> ---
> lib/efi_loader/efi_bootmgr.c | 49 +++++++++++++++++++++++++++++++-------------
> 1 file changed, 35 insertions(+), 14 deletions(-)
>
> diff --git a/lib/efi_loader/efi_bootmgr.c b/lib/efi_loader/efi_bootmgr.c
> index 662993fb809..d472dde158a 100644
> --- a/lib/efi_loader/efi_bootmgr.c
> +++ b/lib/efi_loader/efi_bootmgr.c
> @@ -17,6 +17,7 @@
> #include <log.h>
> #include <malloc.h>
> #include <net.h>
> +#include <part.h>
> #include <efi_loader.h>
> #include <efi_variable.h>
> #include <asm/unaligned.h>
> @@ -347,6 +348,9 @@ static efi_status_t fill_default_file_path(struct udevice *blk,
> * @dp: pointer to default file device path
> * @blk: pointer to created blk udevice
> * Return: status code
> + *
> + * This function handles device creation internally and performs cleanup
> + * on error paths.
> */
> static efi_status_t prepare_loaded_image(u16 *label, ulong addr, ulong size,
> struct efi_device_path **dp,
> @@ -355,10 +359,31 @@ static efi_status_t prepare_loaded_image(u16 *label, ulong addr, ulong size,
> u64 pages;
> efi_status_t ret;
> struct udevice *ramdisk_blk;
> + struct blk_desc *desc;
> + struct part_driver *part_drv;
>
> + /* Create the ramdisk block device internally */
> ramdisk_blk = mount_image(label, addr, size);
> - if (!ramdisk_blk)
> - return EFI_LOAD_ERROR;
> + if (!ramdisk_blk) {
> + log_err("Failed to create ramdisk block device\n");
I think this needs to be a log_warning() because we might be booting an EFI app.
Heinrich any preference?
[....]
Other than that
Reviewed-by: Ilias Apalodimas <ilias.apalodimas at linaro.org>
More information about the U-Boot
mailing list