Skip to contentSkip to conversation

Allow last block to be read

PATCH New Jesper Schmitz Mouridsen 2 participants 3 messages Feb 9, 2021 – Feb 16, 2021

lore
Share & tools
lore
#0 lore raw

cover Allow last block to be read

The last block could not be read by FreeBSD
loader.efi (the gpt backup block)

Jesper Schmitz Mouridsen (1):
Allow last block to be read

 lib/efi_loader/efi_disk.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Signature · 1 line
2.30.0
#1 lore raw

PATCH 1/1 Allow last block to be read

The last block is of size media->block_size

---
 lib/efi_loader/efi_disk.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
lib/efi_loader/efi_disk.c +1 -1
index 1f6b817dea..f77f465d20 100644
@@ -148,7 +148,7 @@ static efi_status_t EFIAPI efi_disk_read_blocks(struct efi_block_io *this,
 	    (uintptr_t)buffer & (this->media->io_align - 1))
 		return EFI_INVALID_PARAMETER;
 	if (lba * this->media->block_size + buffer_size >
-	    this->media->last_block * this->media->block_size)
+	    this->media->last_block * this->media->block_size + this->media->block_size)
 		return EFI_INVALID_PARAMETER;
 
 #ifdef CONFIG_EFI_LOADER_BOUNCE_BUFFER
Signature · 1 line
2.30.0
#2 lore raw

PATCH v2 1/1 Allow last block to be read

From: Jesper Schmitz Mouridsen <[email protected]>

The last block is of size media->block_size

Simplify expression.
Apply same change to efi_disk_write_blocks().

---
v2:
Add missing signed-off lign.
Simplify expression.
Apply same change to efi_disk_write_blocks().

---
 lib/efi_loader/efi_disk.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
lib/efi_loader/efi_disk.c +2 -2
index 1f6b817dea..307d5d759b 100644
@@ -148,7 +148,7 @@ static efi_status_t EFIAPI efi_disk_read_blocks(struct efi_block_io *this,
 	    (uintptr_t)buffer & (this->media->io_align - 1))
 		return EFI_INVALID_PARAMETER;
 	if (lba * this->media->block_size + buffer_size >
-	    this->media->last_block * this->media->block_size)
+	    (this->media->last_block + 1) * this->media->block_size)
 		return EFI_INVALID_PARAMETER;
 
 #ifdef CONFIG_EFI_LOADER_BOUNCE_BUFFER
@@ -216,7 +216,7 @@ static efi_status_t EFIAPI efi_disk_write_blocks(struct efi_block_io *this,
 	    (uintptr_t)buffer & (this->media->io_align - 1))
 		return EFI_INVALID_PARAMETER;
 	if (lba * this->media->block_size + buffer_size >
-	    this->media->last_block * this->media->block_size)
+	    (this->media->last_block + 1) * this->media->block_size)
 		return EFI_INVALID_PARAMETER;
 
 #ifdef CONFIG_EFI_LOADER_BOUNCE_BUFFER

--
2.30.0