[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Using memdisk with grub2 and a gzip-compressed ISO
From: |
Andrei Borzenkov |
Subject: |
Re: Using memdisk with grub2 and a gzip-compressed ISO |
Date: |
Wed, 29 Apr 2015 20:45:01 +0300 |
В Thu, 23 Apr 2015 10:23:09 -0400
David Shaw <address@hidden> пишет:
>
> When booting the box with grub2 2.02, it does not work. The error is:
>
> Ramdisk at 0x37979000, length 0x0033b290
> gzip image: decompressed addr 0xbfff7000, len 0x00008f58: failed
> Decompression error: output buffer overrun
>
Could you test attached patch? While I'm past this message using your
archive, in qemu-kvm it hangs after "... booting ..." and in
qemu-system-i386 I get something that looks like memory corruption with
occasional crash when initrd is uncompressed.
From: Andrei Borzenkov <address@hidden>
Subject: [PATCH] loader/linux: do not pad initrd with zeroes at the end
Syslinux memdisk is using initrd image and needs to know uncompressed
size in advance. For gzip uncompressed size is at the end of compressed
stream. Grub padded each input file to 4 bytes at the end, which means
syslinux got wrong size.
Linux initramfs loader apparently does not care about trailing alignment.
So change code to align beginning of each file instead which
automatically gives us the correct size for single file.
Reported-By: David Shaw <address@hidden>
---
grub-core/loader/linux.c | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/grub-core/loader/linux.c b/grub-core/loader/linux.c
index 117232f..35b858e 100644
--- a/grub-core/loader/linux.c
+++ b/grub-core/loader/linux.c
@@ -161,6 +161,9 @@ grub_initrd_init (int argc, char *argv[],
for (i = 0; i < argc; i++)
{
const char *fname = argv[i];
+
+ initrd_ctx->size = ALIGN_UP (initrd_ctx->size, 4);
+
if (grub_memcmp (argv[i], "newc:", 5) == 0)
{
const char *ptr, *eptr;
@@ -205,7 +208,7 @@ grub_initrd_init (int argc, char *argv[],
initrd_ctx->nfiles++;
initrd_ctx->components[i].size
= grub_file_size (initrd_ctx->components[i].file);
- initrd_ctx->size += ALIGN_UP (initrd_ctx->components[i].size, 4);
+ initrd_ctx->size += initrd_ctx->components[i].size;
}
if (newc)
@@ -253,6 +256,9 @@ grub_initrd_load (struct grub_linux_initrd_context
*initrd_ctx,
{
grub_ssize_t cursize;
+ grub_memset (ptr, 0, ALIGN_UP_OVERHEAD ((grub_addr_t)ptr, 4));
+ ptr += ALIGN_UP_OVERHEAD ((grub_addr_t)ptr, 4);
+
if (initrd_ctx->components[i].newc_name)
{
ptr += insert_dir (initrd_ctx->components[i].newc_name,
@@ -283,8 +289,6 @@ grub_initrd_load (struct grub_linux_initrd_context
*initrd_ctx,
return grub_errno;
}
ptr += cursize;
- grub_memset (ptr, 0, ALIGN_UP_OVERHEAD (cursize, 4));
- ptr += ALIGN_UP_OVERHEAD (cursize, 4);
}
if (newc)
ptr = make_header (ptr, "TRAILER!!!", sizeof ("TRAILER!!!") - 1, 0, 0);
--
tg: (104dff3..) u/initrd-pad (depends on: master)
- Re: Using memdisk with grub2 and a gzip-compressed ISO, (continued)
- Re: Using memdisk with grub2 and a gzip-compressed ISO, Andrei Borzenkov, 2015/04/23
- Re: [syslinux] Using memdisk with grub2 and a gzip-compressed ISO, H. Peter Anvin, 2015/04/23
- Re: [syslinux] Using memdisk with grub2 and a gzip-compressed ISO, Andrei Borzenkov, 2015/04/23
- Re: [syslinux] Using memdisk with grub2 and a gzip-compressed ISO, H. Peter Anvin, 2015/04/23
- Re: [syslinux] Using memdisk with grub2 and a gzip-compressed ISO, Andrei Borzenkov, 2015/04/23
- Re: [syslinux] Using memdisk with grub2 and a gzip-compressed ISO, H. Peter Anvin, 2015/04/24
- Re: [syslinux] Using memdisk with grub2 and a gzip-compressed ISO, Andrei Borzenkov, 2015/04/24
- Re: [syslinux] Using memdisk with grub2 and a gzip-compressed ISO, H. Peter Anvin, 2015/04/27
- Re: [syslinux] Using memdisk with grub2 and a gzip-compressed ISO, Vladimir 'φ-coder/phcoder' Serbinenko, 2015/04/29
- Re: [syslinux] Using memdisk with grub2 and a gzip-compressed ISO, Andrei Borzenkov, 2015/04/29
Re: Using memdisk with grub2 and a gzip-compressed ISO,
Andrei Borzenkov <=