]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
disk/i386/pc/biosdisk: Read up to 63 sectors in LBA mode
authorValdikSS <iam@valdikss.org.ru>
Tue, 10 Oct 2023 18:28:44 +0000 (21:28 +0300)
committerDaniel Kiper <daniel.kiper@oracle.com>
Thu, 12 Oct 2023 17:23:17 +0000 (19:23 +0200)
Current code imposes limitations on the amount of sectors read in
a single call according to CHS layout of the disk even in LBA
read mode. There's no need to obey CHS layout restrictions for
LBA reads on LBA disks. It only slows down booting process.

See: https://lore.kernel.org/grub-devel/d42a11fa-2a59-b5e7-08b1-d2c60444bb99@valdikss.org.ru/

Signed-off-by: ValdikSS <iam@valdikss.org.ru>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
grub-core/disk/i386/pc/biosdisk.c
include/grub/disk.h

index f9362d17cd59cd6ec17c3137a8a3bcaa9351549a..1d67889509ef84713c5b9a4e0cd2f784699be61c 100644 (file)
@@ -471,7 +471,7 @@ grub_biosdisk_rw (int cmd, grub_disk_t disk,
       struct grub_biosdisk_dap *dap;
 
       dap = (struct grub_biosdisk_dap *) (GRUB_MEMORY_MACHINE_SCRATCH_ADDR
-                                         + (data->sectors
+                                         + (GRUB_DISK_MAX_LBA_SECTORS
                                             << disk->log_sector_size));
       dap->length = sizeof (*dap);
       dap->reserved = 0;
@@ -561,6 +561,9 @@ get_safe_sectors (grub_disk_t disk, grub_disk_addr_t sector)
   struct grub_biosdisk_data *data = disk->data;
   grub_uint32_t sectors = data->sectors;
 
+  if (data->flags & GRUB_BIOSDISK_FLAG_LBA)
+    sectors = GRUB_DISK_MAX_LBA_SECTORS;
+
   /* OFFSET = SECTOR % SECTORS */
   grub_divmod64 (sector, sectors, &offset);
 
index a4b5d13f3d8a83e1a97f0f665413cc02f3921175..fbf23df7f2a7c5bb91e873f4d766b18aa68a1bd6 100644 (file)
@@ -190,6 +190,9 @@ typedef struct grub_disk_memberlist *grub_disk_memberlist_t;
 
 #define GRUB_DISK_MAX_MAX_AGGLOMERATE ((1 << (30 - GRUB_DISK_CACHE_BITS - GRUB_DISK_SECTOR_BITS)) - 1)
 
+/* Maximum number of sectors to read in LBA mode at once. */
+#define GRUB_DISK_MAX_LBA_SECTORS 63
+
 /* Return value of grub_disk_native_sectors() in case disk size is unknown. */
 #define GRUB_DISK_SIZE_UNKNOWN  0xffffffffffffffffULL