yeahuh / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone
9ae3a8
From 758b4f721ba664f383bd234458f78984f22823b6 Mon Sep 17 00:00:00 2001
9ae3a8
From: Kevin Wolf <kwolf@redhat.com>
9ae3a8
Date: Thu, 26 Jul 2018 16:24:43 +0200
9ae3a8
Subject: [PATCH 1/8] multiboot: bss_end_addr can be zero
9ae3a8
9ae3a8
RH-Author: Kevin Wolf <kwolf@redhat.com>
9ae3a8
Message-id: <20180726162448.22072-2-kwolf@redhat.com>
9ae3a8
Patchwork-id: 81517
9ae3a8
O-Subject: [RHEL-7.6/7.5.z qemu-kvm PATCH 1/6] multiboot: bss_end_addr can be zero
9ae3a8
Bugzilla: 1549822
9ae3a8
RH-Acked-by: John Snow <jsnow@redhat.com>
9ae3a8
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
9ae3a8
RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
9ae3a8
9ae3a8
From: Jack Schwartz <jack.schwartz@oracle.com>
9ae3a8
9ae3a8
The multiboot spec (https://www.gnu.org/software/grub/manual/multiboot/),
9ae3a8
section 3.1.3, allows for bss_end_addr to be zero.
9ae3a8
9ae3a8
A zero bss_end_addr signifies there is no .bss section.
9ae3a8
9ae3a8
Suggested-by: Daniel Kiper <daniel.kiper@oracle.com>
9ae3a8
Signed-off-by: Jack Schwartz <jack.schwartz@oracle.com>
9ae3a8
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
9ae3a8
Reviewed-by: Prasad J Pandit <pjp@fedoraproject.org>
9ae3a8
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
9ae3a8
(cherry picked from commit 2a8fcd119eb7c6bb3837fc3669eb1b2dfb31daf8)
9ae3a8
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
9ae3a8
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
9ae3a8
---
9ae3a8
 hw/i386/multiboot.c | 18 ++++++++++--------
9ae3a8
 1 file changed, 10 insertions(+), 8 deletions(-)
9ae3a8
9ae3a8
diff --git a/hw/i386/multiboot.c b/hw/i386/multiboot.c
9ae3a8
index 7eec230..9a9a2e1 100644
9ae3a8
--- a/hw/i386/multiboot.c
9ae3a8
+++ b/hw/i386/multiboot.c
9ae3a8
@@ -212,12 +212,6 @@ int load_multiboot(FWCfgState *fw_cfg,
9ae3a8
         mh_entry_addr = ldl_p(header+i+28);
9ae3a8
 
9ae3a8
         if (mh_load_end_addr) {
9ae3a8
-            if (mh_bss_end_addr < mh_load_addr) {
9ae3a8
-                fprintf(stderr, "invalid mh_bss_end_addr address\n");
9ae3a8
-                exit(1);
9ae3a8
-            }
9ae3a8
-            mb_kernel_size = mh_bss_end_addr - mh_load_addr;
9ae3a8
-
9ae3a8
             if (mh_load_end_addr < mh_load_addr) {
9ae3a8
                 fprintf(stderr, "invalid mh_load_end_addr address\n");
9ae3a8
                 exit(1);
9ae3a8
@@ -228,8 +222,16 @@ int load_multiboot(FWCfgState *fw_cfg,
9ae3a8
                 fprintf(stderr, "invalid kernel_file_size\n");
9ae3a8
                 exit(1);
9ae3a8
             }
9ae3a8
-            mb_kernel_size = kernel_file_size - mb_kernel_text_offset;
9ae3a8
-            mb_load_size = mb_kernel_size;
9ae3a8
+            mb_load_size = kernel_file_size - mb_kernel_text_offset;
9ae3a8
+        }
9ae3a8
+        if (mh_bss_end_addr) {
9ae3a8
+            if (mh_bss_end_addr < (mh_load_addr + mb_load_size)) {
9ae3a8
+                fprintf(stderr, "invalid mh_bss_end_addr address\n");
9ae3a8
+                exit(1);
9ae3a8
+            }
9ae3a8
+            mb_kernel_size = mh_bss_end_addr - mh_load_addr;
9ae3a8
+        } else {
9ae3a8
+            mb_kernel_size = mb_load_size;
9ae3a8
         }
9ae3a8
 
9ae3a8
         /* Valid if mh_flags sets MULTIBOOT_HEADER_HAS_VBE.
9ae3a8
-- 
9ae3a8
1.8.3.1
9ae3a8