05bba0
From c3f813d2f53fb8f9e2dc7e2b3c6b17d7fadb2de5 Mon Sep 17 00:00:00 2001
05bba0
From: Laszlo Ersek <lersek@redhat.com>
05bba0
Date: Tue, 27 Jan 2015 17:48:11 +0100
05bba0
Subject: [PATCH 08/16] pc_sysfw: prevent pflash and/or mis-sized firmware for
05bba0
 rhel6.x.0 machtypes
05bba0
05bba0
Message-id: <1422380891-11054-3-git-send-email-lersek@redhat.com>
05bba0
Patchwork-id: 63585
05bba0
O-Subject: [RHEL-7.2 qemu-kvm PATCH 2/2] pc_sysfw: prevent pflash and/or mis-sized firmware for rhel6.x.0 machtypes
05bba0
Bugzilla: 1176283
05bba0
RH-Acked-by: Paolo Bonzini <pbonzini@redhat.com>
05bba0
RH-Acked-by: Vitaly Kuznetsov <vkuznets@redhat.com>
05bba0
RH-Acked-by: Markus Armbruster <armbru@redhat.com>
05bba0
05bba0
QE tried to boot OVMF on a rhel6.x.0 machine type. The shadow_bios()
05bba0
migration hack that is in effect for those machine types is not compatible
05bba0
with the OVMF image. An assert() in shadow_bios() catches it, but -- given
05bba0
that OVMF has never been intended for rhel6.x.0 machine types -- QE has
05bba0
rather requested us to deny such startups cleanly.
05bba0
05bba0
The first hunk prevents "-M rhel6.x.0 -bios ..." style invocations where
05bba0
the BIOS image is not 128 KB in size. This was suggested by Paolo and it
05bba0
prevents the case when someone passes an OVMF binary via -bios.
05bba0
05bba0
The second hunk prevents "-M rhel6.x.0 -pflash ...", since that
05bba0
configuration (for boot firmware purposes or otherwise) was never
05bba0
supported.
05bba0
05bba0
Downstream only.
05bba0
05bba0
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
05bba0
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
05bba0
---
05bba0
 hw/i386/pc_sysfw.c | 11 +++++++++++
05bba0
 1 file changed, 11 insertions(+)
05bba0
05bba0
diff --git a/hw/i386/pc_sysfw.c b/hw/i386/pc_sysfw.c
05bba0
index 6f5ecde..2f26ff5 100644
05bba0
--- a/hw/i386/pc_sysfw.c
05bba0
+++ b/hw/i386/pc_sysfw.c
05bba0
@@ -191,6 +191,11 @@ static void old_pc_system_rom_init(MemoryRegion *rom_memory, bool isapc_ram_fw)
05bba0
         (bios_size % 65536) != 0) {
05bba0
         goto bios_error;
05bba0
     }
05bba0
+    if (shadow_bios_after_incoming && bios_size != 128 * 1024) {
05bba0
+        error_report("machine %s only supports a 128KB BIOS image",
05bba0
+                     current_machine->name);
05bba0
+        exit(1);
05bba0
+    }
05bba0
     bios = g_malloc(sizeof(*bios));
05bba0
     memory_region_init_ram(bios, "pc.bios", bios_size);
05bba0
     vmstate_register_ram_global(bios);
05bba0
@@ -241,6 +246,12 @@ void pc_system_firmware_init(MemoryRegion *rom_memory, bool isapc_ram_fw)
05bba0
         return;
05bba0
     }
05bba0
 
05bba0
+    if (shadow_bios_after_incoming) {
05bba0
+        error_report("flash-based firmware is not supported by machine %s",
05bba0
+                     current_machine->name);
05bba0
+        exit(1);
05bba0
+    }
05bba0
+
05bba0
     if (kvm_enabled() && !kvm_readonly_mem_enabled()) {
05bba0
         /* Older KVM cannot execute from device memory. So, flash memory
05bba0
          * cannot be used unless the readonly memory kvm capability is present. */
05bba0
-- 
05bba0
1.8.3.1
05bba0