From 2e13ede59e237fa4ef9b53018143c8ab0197de2c Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Tue, 24 Jan 2012 14:39:29 +0100 Subject: Eliminate fixed limit on reed solomon decoder length. * grub-core/boot/i386/pc/lnxboot.S: Scan for multiboot signature rather than hardcoding the address. * grub-core/boot/i386/pc/startup_raw.S: Add new data field no_reed_solomon_length. Move gate_a20 to no-reed-solomon part. Don't force a particular size of no reed-solomon part. * include/grub/offsets.h (GRUB_KERNEL_I386_PC_NO_REED_SOLOMON_PART): Removed. (GRUB_KERNEL_I386_PC_NO_REED_SOLOMON_LENGTH): New define. * util/grub-setup.c (setup): Read no_rs_length from the image itself. --- util/grub-setup.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'util/grub-setup.c') diff --git a/util/grub-setup.c b/util/grub-setup.c index 8965143c5..9618d1a5d 100644 --- a/util/grub-setup.c +++ b/util/grub-setup.c @@ -444,14 +444,22 @@ setup (const char *dir, + GRUB_DISK_SECTOR_SIZE - sizeof (*block)); + grub_size_t no_rs_length; *(grub_uint32_t *) (core_img + GRUB_DISK_SECTOR_SIZE + GRUB_KERNEL_I386_PC_REED_SOLOMON_REDUNDANCY) = grub_host_to_target32 (nsec * GRUB_DISK_SECTOR_SIZE - core_size); + no_rs_length = grub_target_to_host16 + (*(grub_uint16_t *) (core_img + + GRUB_DISK_SECTOR_SIZE + + GRUB_KERNEL_I386_PC_NO_REED_SOLOMON_LENGTH)); + + if (no_rs_length == 0xffff) + grub_util_error ("core.img version mismatch"); void *tmp = xmalloc (core_size); grub_memcpy (tmp, core_img, core_size); - grub_reed_solomon_add_redundancy (core_img + GRUB_KERNEL_I386_PC_NO_REED_SOLOMON_PART + GRUB_DISK_SECTOR_SIZE, - core_size - GRUB_KERNEL_I386_PC_NO_REED_SOLOMON_PART - GRUB_DISK_SECTOR_SIZE, + grub_reed_solomon_add_redundancy (core_img + no_rs_length + GRUB_DISK_SECTOR_SIZE, + core_size - no_rs_length - GRUB_DISK_SECTOR_SIZE, nsec * GRUB_DISK_SECTOR_SIZE - core_size); assert (grub_memcmp (tmp, core_img, core_size) == 0); -- cgit v1.2.3