Skip to content
  • Paul Barbieri's avatar
    EFI: Fix ReadBlocks API reading incorrect sector for UCLASS_PARTITION devices · 7a85f324
    Paul Barbieri authored and Heinrich Schuchardt's avatar Heinrich Schuchardt committed
    
    
    The requsted partition disk sector incorrectly has the parition start
    sector added in twice for UCLASS_PARTITION devices. The efi_disk_rw_blocks()
    routine adds the diskobj->offset to the requested lba. When the device
    is a UCLASS_PARTITION, the dev_read() or dev_write() routine is called
    which adds part-gpt_part_info.start. This causes I/O to the wrong sector.
    
    Takahiro Akashi suggested removing the offset field from the efi_disk_obj
    structure since disk-uclass.c handles the partition start biasing. Device
    types other than UCLASS_PARTITION set the diskobj->offset field to zero
    which makes the field unnecessary. This change removes the offset field
    from the structure and removes all references from the code which is
    isolated to the lib/efi_loader/efi_disk.c module.
    
    This change also adds a test for the EFI ReadBlocks() API in the EFI
    selftest code. There is already a test for reading a FAT file. The new
    test uses ReadBlocks() to read the same "disk" block and compare it to
    the data read from the file system API.
    
    Signed-Off-by: default avatarPaul Barbieri <plb365@gmail.com>
    Cc: Heinrich Schuchardt <xypron.glpk@gmx.de>
    Cc: AKASHI Takahiro <takahiro.akashi@linaro.org>
    Reviewed-by: default avatarHeinrich Schuchardt <heinrich.schuchardt@canonical.com>
    7a85f324