[PATCH] efi_loader: fix efi_bootmgr_enumerate_boot_option

Heinrich Schuchardt heinrich.schuchardt at canonical.com
Tue Oct 17 19:51:48 CEST 2023


Only auto-generate boot options for removable media.

For testing the different handling of removable and non-removable devices
an emulated USB device can be used:

    make qemu-riscv64_smode_defconfig; make
    qemu-system-riscv64 -M virt -kernel u-boot.bin -nographic \
    -device qemu-xhci -drive if=none,file=disk.img,format=raw,id=USB1 \
    -device usb-storage,drive=USB1,removable=on

Fixes: c416f1c0bcab ("bootmenu: add removable media entries")
Fixes: 339b527bd450 ("Move bootorder and bootoption apis to lib")
Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt at canonical.com>
---
 lib/efi_loader/efi_bootmgr.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/lib/efi_loader/efi_bootmgr.c b/lib/efi_loader/efi_bootmgr.c
index a40762c74c..96d45157b3 100644
--- a/lib/efi_loader/efi_bootmgr.c
+++ b/lib/efi_loader/efi_bootmgr.c
@@ -346,7 +346,7 @@ error:
 }
 
 /**
- * efi_bootmgr_enumerate_boot_option() - enumerate the possible bootable media
+ * efi_bootmgr_enumerate_boot_option() - boot options for removable boot media
  *
  * @opt:		pointer to the media boot option structure
  * @volume_handles:	pointer to the efi handles
@@ -370,6 +370,9 @@ static efi_status_t efi_bootmgr_enumerate_boot_option(struct eficonfig_media_boo
 		struct efi_device_path *device_path;
 		struct efi_device_path *short_dp;
 
+		if (!efi_disk_is_removable(volume_handles[i]))
+			continue;
+
 		ret = efi_search_protocol(volume_handles[i], &efi_guid_device_path, &handler);
 		if (ret != EFI_SUCCESS)
 			continue;
@@ -674,7 +677,10 @@ efi_status_t efi_bootmgr_update_media_device_boot_option(void)
 		goto out;
 	}
 
-	/* enumerate all devices supporting EFI_SIMPLE_FILE_SYSTEM_PROTOCOL */
+	/*
+	 * Enumerate all removable devices supporting the
+	 * EFI_SIMPLE_FILE_SYSTEM_PROTOCOL.
+	 */
 	ret = efi_bootmgr_enumerate_boot_option(opt, volume_handles, count);
 	if (ret != EFI_SUCCESS)
 		goto out;
-- 
2.40.1



More information about the U-Boot mailing list