From: Kevin Wolf <kwolf@redhat.com>
To: qemu-devel@nongnu.org
Cc: kwolf@redhat.com, jack.schwartz@oracle.com
Subject: [Qemu-devel] [PULL 1/4] multiboot: bss_end_addr can be zero
Date: Wed, 7 Mar 2018 12:18:19 +0100 [thread overview]
Message-ID: <20180307111822.29403-2-kwolf@redhat.com> (raw)
In-Reply-To: <20180307111822.29403-1-kwolf@redhat.com>
From: Jack Schwartz <jack.schwartz@oracle.com>
The multiboot spec (https://www.gnu.org/software/grub/manual/multiboot/),
section 3.1.3, allows for bss_end_addr to be zero.
A zero bss_end_addr signifies there is no .bss section.
Suggested-by: Daniel Kiper <daniel.kiper@oracle.com>
Signed-off-by: Jack Schwartz <jack.schwartz@oracle.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
Reviewed-by: Prasad J Pandit <pjp@fedoraproject.org>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
hw/i386/multiboot.c | 18 ++++++++++--------
1 file changed, 10 insertions(+), 8 deletions(-)
diff --git a/hw/i386/multiboot.c b/hw/i386/multiboot.c
index 46d9c68bf5..bb8d8e4629 100644
--- a/hw/i386/multiboot.c
+++ b/hw/i386/multiboot.c
@@ -233,12 +233,6 @@ int load_multiboot(FWCfgState *fw_cfg,
mh_entry_addr = ldl_p(header+i+28);
if (mh_load_end_addr) {
- if (mh_bss_end_addr < mh_load_addr) {
- fprintf(stderr, "invalid mh_bss_end_addr address\n");
- exit(1);
- }
- mb_kernel_size = mh_bss_end_addr - mh_load_addr;
-
if (mh_load_end_addr < mh_load_addr) {
fprintf(stderr, "invalid mh_load_end_addr address\n");
exit(1);
@@ -249,8 +243,16 @@ int load_multiboot(FWCfgState *fw_cfg,
fprintf(stderr, "invalid kernel_file_size\n");
exit(1);
}
- mb_kernel_size = kernel_file_size - mb_kernel_text_offset;
- mb_load_size = mb_kernel_size;
+ mb_load_size = kernel_file_size - mb_kernel_text_offset;
+ }
+ if (mh_bss_end_addr) {
+ if (mh_bss_end_addr < (mh_load_addr + mb_load_size)) {
+ fprintf(stderr, "invalid mh_bss_end_addr address\n");
+ exit(1);
+ }
+ mb_kernel_size = mh_bss_end_addr - mh_load_addr;
+ } else {
+ mb_kernel_size = mb_load_size;
}
/* Valid if mh_flags sets MULTIBOOT_HEADER_HAS_VBE.
--
2.13.6
next prev parent reply other threads:[~2018-03-07 11:18 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-03-07 11:18 [Qemu-devel] [PULL 0/4] Multiboot patches Kevin Wolf
2018-03-07 11:18 ` Kevin Wolf [this message]
2018-03-07 11:18 ` [Qemu-devel] [PULL 2/4] multiboot: Remove unused variables from multiboot.c Kevin Wolf
2018-03-07 11:18 ` [Qemu-devel] [PULL 3/4] multiboot: Use header names when displaying fields Kevin Wolf
2018-03-07 11:18 ` [Qemu-devel] [PULL 4/4] multiboot: fprintf(stderr...) -> error_report() Kevin Wolf
2018-03-08 11:26 ` [Qemu-devel] [PULL 0/4] Multiboot patches Peter Maydell
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=20180307111822.29403-2-kwolf@redhat.com \
--to=kwolf@redhat.com \
--cc=jack.schwartz@oracle.com \
--cc=qemu-devel@nongnu.org \
/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).