yeahuh / rpms / qemu-kvm

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