From: Andrei Borzenkov <arvidjaar@gmail.com>
To: David Shaw <dshaw@jabberwocky.com>
Cc: grub-devel@gnu.org, syslinux@zytor.com
Subject: Re: Using memdisk with grub2 and a gzip-compressed ISO
Date: Wed, 29 Apr 2015 20:45:01 +0300 [thread overview]
Message-ID: <20150429204501.1d3e1021@opensuse.site> (raw)
In-Reply-To: <C7ACECCE-ACED-44D0-BD29-22D9D8FB9941@jabberwocky.com>
В Thu, 23 Apr 2015 10:23:09 -0400
David Shaw <dshaw@jabberwocky.com> пишет:
>
> 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 <arvidjaar@gmail.com>
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 <dshaw@jabberwocky.com>
---
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)
next prev parent reply other threads:[~2015-04-29 17:45 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-04-23 14:23 Using memdisk with grub2 and a gzip-compressed ISO David Shaw
2015-04-23 16:59 ` Andrei Borzenkov
2015-04-23 22:17 ` [syslinux] " H. Peter Anvin
2015-04-24 3:14 ` Andrei Borzenkov
2015-04-24 3:30 ` H. Peter Anvin
2015-04-24 3:41 ` Andrei Borzenkov
2015-04-24 4:39 ` H. Peter Anvin
2015-04-24 6:25 ` Andrei Borzenkov
2015-04-27 22:20 ` H. Peter Anvin
2015-04-29 13:55 ` Vladimir 'φ-coder/phcoder' Serbinenko
2015-04-29 16:28 ` Andrei Borzenkov
2015-04-29 17:45 ` Andrei Borzenkov [this message]
2015-04-29 18:35 ` Vladimir 'phcoder' Serbinenko
2015-04-30 3:36 ` Andrei Borzenkov
2015-04-29 18:42 ` David Shaw
2015-05-07 14:23 ` Vladimir 'φ-coder/phcoder' Serbinenko
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20150429204501.1d3e1021@opensuse.site \
--to=arvidjaar@gmail.com \
--cc=dshaw@jabberwocky.com \
--cc=grub-devel@gnu.org \
--cc=syslinux@zytor.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.