coreboot/payloads/libpayload/drivers
Julius Werner f2cf732997 libpayload: usbmsc: Correctly deal with disks larger than 2TB
Disks larger than 2TB (technically disks with more than 2^32 blocks, but
for the common block size of 512 that comes out to 2TB) cannot represent
their full amount of blocks in the SCSI READ_CAPACITY(10) command used
by libpayload's USB mass storage driver. The entire driver isn't written
to support block addresses larger than 32 bits anyway.

The SCSI command has been designed in a clever way so that devices are
supposed to return the maximum value (0xffffffff) if the actual value
doesn't fit. However, our code adds one to the value (because it is
actually the address of the last block, but we want to know the number
of blocks). This makes it overflow back to 0 which is not great.

This patch caps the result before incrementing it so that the overflow
cannot occur, allowing us to at least access the first 2TB of super
large USB sticks.

Change-Id: Ic445923b7d588c4f523c4ed95a06291bc1969261
Signed-off-by: Julius Werner <jwerner@chromium.org>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/87506
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Yu-Ping Wu <yupingso@google.com>
2025-05-02 23:24:25 +00:00
..
i8042 libpayload: Fix clang fallthrough warning 2023-08-28 02:12:25 +00:00
serial libpayload: Fix compiler warnings 2022-11-21 21:08:30 +00:00
storage libpayload: Add x86_64 (64-bit) support 2024-05-26 01:26:31 +00:00
timer libpayload: timer: Revert timer_hz() return type to 64-bits 2024-02-08 21:07:13 +00:00
udc libpayload: Fix compiler warnings 2022-11-21 21:08:30 +00:00
usb libpayload: usbmsc: Correctly deal with disks larger than 2TB 2025-05-02 23:24:25 +00:00
video libpayload/drivers/video: Add cursor movement support in console 2023-09-18 13:15:44 +00:00
cbmem_console.c libpayload/drivers/cbmem_console: Use C99 flexible arrays 2023-08-01 12:40:07 +00:00
hid.c
Makefile.mk payloads: Rename Makefiles from .inc to .mk 2024-01-24 10:15:10 +00:00
mouse_cursor.c
nvram.c
options.c
pci_io_ops.c libpayload/pci: Add support for bus mapping 2022-05-20 02:51:33 +00:00
pci_map_bus_ops.c libpayload/pci: Add support for bus mapping 2022-05-20 02:51:33 +00:00
pci_ops.c libpayload/pci: Add support for bus mapping 2022-05-20 02:51:33 +00:00
pci_qcom.c libpayload/pci: Add pci_map_bus function for Qualcomm platform 2022-08-01 18:04:54 +00:00
pcie_mediatek.c libpayload/pci: Add pci_map_bus function for MediaTek platform 2022-05-20 02:53:35 +00:00
speaker.c