diff options
author | Paul Barbieri <plb365@gmail.com> | 2022-06-30 07:02:04 -0400 |
---|---|---|
committer | Heinrich Schuchardt <heinrich.schuchardt@canonical.com> | 2022-07-02 14:19:12 +0200 |
commit | 7a85f32413a34b18a2f84c865d7b448790200b13 (patch) | |
tree | 11d8e3b55ca47d4bbcaaab11fddcd560f82f41db /lib/efi_loader/efi_disk.c | |
parent | 054de212cef6a5bfc2b91083d10451c892ce7714 (diff) |
EFI: Fix ReadBlocks API reading incorrect sector for UCLASS_PARTITION devices
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: Paul Barbieri <plb365@gmail.com>
Cc: Heinrich Schuchardt <xypron.glpk@gmx.de>
Cc: AKASHI Takahiro <takahiro.akashi@linaro.org>
Reviewed-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
Diffstat (limited to 'lib/efi_loader/efi_disk.c')
-rw-r--r-- | lib/efi_loader/efi_disk.c | 8 |
1 files changed, 1 insertions, 7 deletions
diff --git a/lib/efi_loader/efi_disk.c b/lib/efi_loader/efi_disk.c index 1e82f52dc07..1d700b2a6be 100644 --- a/lib/efi_loader/efi_disk.c +++ b/lib/efi_loader/efi_disk.c @@ -35,7 +35,6 @@ const efi_guid_t efi_system_partition_guid = PARTITION_SYSTEM_GUID; * @dp: device path to the block device * @part: partition * @volume: simple file system protocol of the partition - * @offset: offset into disk for simple partition * @dev: associated DM device */ struct efi_disk_obj { @@ -47,7 +46,6 @@ struct efi_disk_obj { struct efi_device_path *dp; unsigned int part; struct efi_simple_file_system_protocol *volume; - lbaint_t offset; struct udevice *dev; /* TODO: move it to efi_object */ }; @@ -117,7 +115,6 @@ static efi_status_t efi_disk_rw_blocks(struct efi_block_io *this, diskobj = container_of(this, struct efi_disk_obj, ops); blksz = diskobj->media.block_size; blocks = buffer_size / blksz; - lba += diskobj->offset; EFI_PRINT("blocks=%x lba=%llx blksz=%x dir=%d\n", blocks, lba, blksz, direction); @@ -440,13 +437,11 @@ static efi_status_t efi_disk_add_dev( diskobj->dp = efi_dp_append_node(dp_parent, node); efi_free_pool(node); - diskobj->offset = part_info->start; diskobj->media.last_block = part_info->size - 1; if (part_info->bootable & PART_EFI_SYSTEM_PARTITION) guid = &efi_system_partition_guid; } else { diskobj->dp = efi_dp_from_part(desc, part); - diskobj->offset = 0; diskobj->media.last_block = desc->lba - 1; } diskobj->part = part; @@ -501,12 +496,11 @@ static efi_status_t efi_disk_add_dev( *disk = diskobj; EFI_PRINT("BlockIO: part %u, present %d, logical %d, removable %d" - ", offset " LBAF ", last_block %llu\n", + ", last_block %llu\n", diskobj->part, diskobj->media.media_present, diskobj->media.logical_partition, diskobj->media.removable_media, - diskobj->offset, diskobj->media.last_block); /* Store first EFI system partition */ |