diff options
author | Ahmad Fatoum <a.fatoum@pengutronix.de> | 2022-06-30 14:40:35 +0200 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2022-07-05 14:10:10 +0200 |
commit | f9c9651eabe33f0e3690d1230b9a431d0e3e5706 (patch) | |
tree | e8a5c641c5a1270b643908bbe8671ee71553a16d /drivers/block | |
parent | 74a67615fb1a2cd3a249e4a6e8871bf7393f0456 (diff) | |
download | barebox-f9c9651eabe33f0e3690d1230b9a431d0e3e5706.tar.gz |
block: efi: allow disabling /dev/usbdiskX renaming
Some buggy UEFI implementations have been observed to not set
EFI_USB_IO protocol on handles that were instantiated from
USB mass storage. This leads to confusing behavior when barebox
uses /dev/usbdisk for some USB sticks and doesn't for some others.
The proper behavior is not relying on the UEFI and instead check
e.g. GUID of the boot disk image:
if [ "$bootsource" = usb ]; then
mydisk = /dev/usbdisk${bootsource_instance}
else
mydisk = /dev/disk${bootsource_instance}
fi
devlookup -v bootdiskguid $mydisk guid
if [ "$bootdiskguid" = "my-guid" ]; then
boot ${mydisk}.1
else
boot boochooser
fi
When going that way, the renaming to usbdisk is just annoying,
so allow disabling it to simplify scripting.
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
Link: https://lore.barebox.org/20220630124035.4019644-3-a.fatoum@pengutronix.de
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'drivers/block')
-rw-r--r-- | drivers/block/Kconfig | 21 | ||||
-rw-r--r-- | drivers/block/Makefile | 2 | ||||
-rw-r--r-- | drivers/block/efi-block-io.c | 3 |
3 files changed, 24 insertions, 2 deletions
diff --git a/drivers/block/Kconfig b/drivers/block/Kconfig index 68a11438dc..625e81a4ec 100644 --- a/drivers/block/Kconfig +++ b/drivers/block/Kconfig @@ -5,3 +5,24 @@ config VIRTIO_BLK help This is the virtual block driver for virtio. It can be used with QEMU based VMMs (like KVM or Xen). + +config EFI_BLK + bool "EFI block I/O driver" + default y + depends on EFI_BOOTUP + +config EFI_BLK_SEPARATE_USBDISK + bool "rename USB devices to /dev/usbdiskX" + default y + depends on EFI_BLK + help + EFI block devices will be normally called /dev/diskX. Setting this + option will cause block devices instantiated from handles with a + EFI_USB_IO protocol to be called /dev/usbdiskX instead. Note that + some buggy UEFI implementations have been observed to not do this + consistently for all USB mass storage. If you need to absolutely + be sure your boot device is a USB mass storage device and you can't + fix your UEFI, consider disabling this options and setting a GUID + for your disk and checking against it with + + devlookup -v $bootguid /dev/disk$bootsource_instance guid diff --git a/drivers/block/Makefile b/drivers/block/Makefile index c50bdc1d02..a4e14a559c 100644 --- a/drivers/block/Makefile +++ b/drivers/block/Makefile @@ -1,3 +1,3 @@ # SPDX-License-Identifier: GPL-2.0-only -obj-$(CONFIG_EFI_BOOTUP) += efi-block-io.o +obj-$(CONFIG_EFI_BLK) += efi-block-io.o obj-$(CONFIG_VIRTIO_BLK) += virtio_blk.o diff --git a/drivers/block/efi-block-io.c b/drivers/block/efi-block-io.c index 086afb378a..120e4d8f1a 100644 --- a/drivers/block/efi-block-io.c +++ b/drivers/block/efi-block-io.c @@ -140,7 +140,8 @@ static void efi_bio_print_info(struct device_d *dev) static bool is_bio_usbdev(struct efi_device *efidev) { - return efi_device_has_guid(efidev, EFI_USB_IO_PROTOCOL_GUID); + return IS_ENABLED(CONFIG_EFI_BLK_SEPARATE_USBDISK) && + efi_device_has_guid(efidev, EFI_USB_IO_PROTOCOL_GUID); } static int efi_bio_probe(struct efi_device *efidev) |