From: Max Reitz <mreitz@redhat.com>
To: Kevin Wolf <kwolf@redhat.com>, qemu-devel@nongnu.org
Cc: pbonzini@redhat.com, sir@cmpwn.com, stefanha@redhat.com
Subject: Re: [Qemu-devel] [PATCH 2/3] multiboot: Fix offset of bootloader name
Date: Thu, 15 Jan 2015 12:08:41 -0500 [thread overview]
Message-ID: <54B7F419.4060707@redhat.com> (raw)
In-Reply-To: <1421321204-17764-3-git-send-email-kwolf@redhat.com>
On 2015-01-15 at 06:26, Kevin Wolf wrote:
> This fixes a bug introduced in commit 5eba5a66 ('Add bootloader name to
> multiboot implementation').
>
> The calculation of the bootloader name offset didn't consider space
> occupied by module command lines, so some unlucky module got its command
> line partially overwritten with a "qemu" string.
>
> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
> ---
> hw/i386/multiboot.c | 16 +++++++++-------
> 1 file changed, 9 insertions(+), 7 deletions(-)
>
> diff --git a/hw/i386/multiboot.c b/hw/i386/multiboot.c
> index f86d351..1adbe9e 100644
> --- a/hw/i386/multiboot.c
> +++ b/hw/i386/multiboot.c
> @@ -156,6 +156,7 @@ int load_multiboot(FWCfgState *fw_cfg,
> MultibootState mbs;
> uint8_t bootinfo[MBI_SIZE];
> uint8_t *mb_bootinfo_data;
> + uint32_t cmdline_len;
>
> /* Ok, let's see if it is a multiboot image.
> The header is 12x32bit long, so the latest entry may be 8192 - 48. */
> @@ -258,27 +259,28 @@ int load_multiboot(FWCfgState *fw_cfg,
> mbs.offset_mbinfo = mbs.mb_buf_size;
>
> /* Calculate space for cmdlines, bootloader name, and mb_mods */
> - mbs.mb_buf_size += strlen(kernel_filename) + 1;
> - mbs.mb_buf_size += strlen(kernel_cmdline) + 1;
> - mbs.mb_buf_size += strlen(bootloader_name) + 1;
> + cmdline_len = strlen(kernel_filename) + 1;
> + cmdline_len += strlen(kernel_cmdline) + 1;
> if (initrd_filename) {
> const char *r = initrd_filename;
> - mbs.mb_buf_size += strlen(r) + 1;
> + cmdline_len += strlen(r) + 1;
> mbs.mb_mods_avail = 1;
> while (*(r = get_opt_value(NULL, 0, r))) {
> mbs.mb_mods_avail++;
> r++;
> }
> - mbs.mb_buf_size += MB_MOD_SIZE * mbs.mb_mods_avail;
> }
>
> + mbs.mb_buf_size += cmdline_len;
> + mbs.mb_buf_size += MB_MOD_SIZE * mbs.mb_mods_avail;
> + mbs.mb_buf_size += strlen(bootloader_name) + 1;
I would have swapped these two lines to reflect their order in mb_buf,
but it's fine either way.
> +
> mbs.mb_buf_size = TARGET_PAGE_ALIGN(mbs.mb_buf_size);
>
> /* enlarge mb_buf to hold cmdlines, bootloader, mb-info structs */
> mbs.mb_buf = g_realloc(mbs.mb_buf, mbs.mb_buf_size);
> mbs.offset_cmdlines = mbs.offset_mbinfo + mbs.mb_mods_avail * MB_MOD_SIZE;
> - mbs.offset_bootloader = mbs.offset_cmdlines + strlen(kernel_filename) + 1
> - + strlen(kernel_cmdline) + 1;
> + mbs.offset_bootloader = mbs.offset_cmdlines + cmdline_len;
>
> if (initrd_filename) {
> char *next_initrd, not_last;
Reviewed-by: Max Reitz <mreitz@redhat.com>
next prev parent reply other threads:[~2015-01-15 17:09 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-01-15 11:26 [Qemu-devel] [PATCH 0/3] multiboot: Fix offset of bootloader name Kevin Wolf
2015-01-15 11:26 ` [Qemu-devel] [PATCH 1/3] tests/multiboot: Update reference output Kevin Wolf
2015-01-15 11:26 ` [Qemu-devel] [PATCH 2/3] multiboot: Fix offset of bootloader name Kevin Wolf
2015-01-15 17:08 ` Max Reitz [this message]
2015-01-15 11:26 ` [Qemu-devel] [PATCH 3/3] tests/multiboot: Add test for modules Kevin Wolf
2015-01-15 17:57 ` Max Reitz
2015-01-15 17:21 ` [Qemu-devel] [PATCH 0/3] multiboot: Fix offset of bootloader name Drew DeVault
2015-01-19 12:02 ` Paolo Bonzini
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=54B7F419.4060707@redhat.com \
--to=mreitz@redhat.com \
--cc=kwolf@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=sir@cmpwn.com \
--cc=stefanha@redhat.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).