26ba25
From 71562f446db550489bf4ba79e634a8b55e74d83f Mon Sep 17 00:00:00 2001
26ba25
From: Miroslav Rezanina <mrezanin@redhat.com>
26ba25
Date: Thu, 26 Apr 2018 02:54:06 +0000
26ba25
Subject: Remove SeaBIOS shadowing
26ba25
26ba25
As we do not support RHEL 6 compatibility on RHEL 8 we can remove
26ba25
hacks that shadow SeaBIOS for incomming RHEL-6 host
26ba25
26ba25
This feature was added in qemu-kvm RHEL 7.1 for BZ 1027565 (fail to
26ba25
reboot guest after migration from RHEL6.5 host to RHEL7.0 host) as
26ba25
commit 9f136b4ed4ec and was backported to RHEL 7.0 as 0day fix (BZ 1091322,
26ba25
commit df9e9e9c56c7).
26ba25
26ba25
In addition, fix was provided for qemu-kvm-rhev in RHEL 7.1 (BZ 1103579,
26ba25
commit cada12245ab9).
26ba25
26ba25
For qemu-kvm, use of this hack was extended for BZ 1176283
26ba25
([migration]migrationfailed when configure guest with OVMF bios + machine
26ba25
 type=rhel6.5.0) in RHEL 7.2 by commit c3f813d2f.
26ba25
26ba25
For qemu-kvm-rhev, use of this hack was extened for BZ 1170093 (guest NUMA
26ba25
failed to migrate when machine is rhel6.5.0) for RHEL 7.1 by commit 8e8107cb3
26ba25
and BZ 1175099 ([migration]migration failed when configure guest with OVMF
26ba25
bios + machine type=rhel6.5.0) for RHEL 7.2 by commit 8b220c0e.
26ba25
26ba25
In addition, during rebase to 2.10, handling was moved to separate module
26ba25
and stub version was provided.
26ba25
26ba25
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
26ba25
---
26ba25
 hw/i386/Makefile.objs   |  1 -
26ba25
 hw/i386/pc_sysfw.c      | 16 -------------
26ba25
 hw/i386/shadow-bios.c   | 64 -------------------------------------------------
26ba25
 include/sysemu/sysemu.h |  2 --
26ba25
 migration/savevm.c      |  7 ------
26ba25
 numa.c                  | 13 ----------
26ba25
 stubs/Makefile.objs     |  1 -
26ba25
 stubs/shadow-bios.c     |  7 ------
26ba25
 8 files changed, 111 deletions(-)
26ba25
 delete mode 100644 hw/i386/shadow-bios.c
26ba25
 delete mode 100644 stubs/shadow-bios.c
26ba25
26ba25
diff --git a/hw/i386/Makefile.objs b/hw/i386/Makefile.objs
26ba25
index 8c25538..fa87a14 100644
26ba25
--- a/hw/i386/Makefile.objs
26ba25
+++ b/hw/i386/Makefile.objs
26ba25
@@ -10,4 +10,3 @@ obj-$(CONFIG_VMMOUSE) += vmmouse.o
26ba25
 
26ba25
 obj-y += kvmvapic.o
26ba25
 obj-y += acpi-build.o
26ba25
-obj-y += shadow-bios.o
26ba25
diff --git a/hw/i386/pc_sysfw.c b/hw/i386/pc_sysfw.c
26ba25
index 2a6de35..73ac783 100644
26ba25
--- a/hw/i386/pc_sysfw.c
26ba25
+++ b/hw/i386/pc_sysfw.c
26ba25
@@ -207,13 +207,6 @@ static void old_pc_system_rom_init(MemoryRegion *rom_memory, bool isapc_ram_fw)
26ba25
         (bios_size % 65536) != 0) {
26ba25
         goto bios_error;
26ba25
     }
26ba25
-    if (shadow_bios_after_incoming && bios_size != 128 * 1024) {
26ba25
-        MachineClass *mc;
26ba25
-
26ba25
-        mc = MACHINE_GET_CLASS(current_machine);
26ba25
-        error_report("machine %s only supports a 128KB BIOS image", mc->name);
26ba25
-        exit(1);
26ba25
-    }
26ba25
     bios = g_malloc(sizeof(*bios));
26ba25
     memory_region_init_ram(bios, NULL, "pc.bios", bios_size, &error_fatal);
26ba25
     if (!isapc_ram_fw) {
26ba25
@@ -261,15 +254,6 @@ void pc_system_firmware_init(MemoryRegion *rom_memory, bool isapc_ram_fw)
26ba25
         return;
26ba25
     }
26ba25
 
26ba25
-    if (shadow_bios_after_incoming) {
26ba25
-        MachineClass *mc;
26ba25
-
26ba25
-        mc = MACHINE_GET_CLASS(current_machine);
26ba25
-        error_report("flash-based firmware is not supported by machine %s",
26ba25
-                     mc->name);
26ba25
-        exit(1);
26ba25
-    }
26ba25
-
26ba25
     if (kvm_enabled() && !kvm_readonly_mem_enabled()) {
26ba25
         /* Older KVM cannot execute from device memory. So, flash memory
26ba25
          * cannot be used unless the readonly memory kvm capability is present. */
26ba25
diff --git a/hw/i386/shadow-bios.c b/hw/i386/shadow-bios.c
26ba25
deleted file mode 100644
26ba25
index 65a4cb8..0000000
26ba25
--- a/hw/i386/shadow-bios.c
26ba25
+++ /dev/null
26ba25
@@ -1,64 +0,0 @@
26ba25
-#include "qemu/osdep.h"
26ba25
-#include "sysemu/sysemu.h"
26ba25
-#include "target/i386/cpu.h"
26ba25
-#include "exec/ram_addr.h"
26ba25
-#include "qemu/cutils.h"
26ba25
-
26ba25
-void shadow_bios(void)
26ba25
-{
26ba25
-    RAMBlock *block, *ram, *oprom, *bios;
26ba25
-    size_t one_meg, oprom_size, bios_size;
26ba25
-    uint8_t *cd_seg_host, *ef_seg_host;
26ba25
-
26ba25
-    ram = NULL;
26ba25
-    oprom = NULL;
26ba25
-    bios = NULL;
26ba25
-    rcu_read_lock();
26ba25
-    QLIST_FOREACH_RCU(block, &ram_list.blocks, next) {
26ba25
-        if (strcmp("pc.ram", block->idstr) == 0) {
26ba25
-            assert(ram == NULL);
26ba25
-            ram = block;
26ba25
-        } else if (strcmp("pc.rom", block->idstr) == 0) {
26ba25
-            assert(oprom == NULL);
26ba25
-            oprom = block;
26ba25
-        } else if (strcmp("pc.bios", block->idstr) == 0) {
26ba25
-            assert(bios == NULL);
26ba25
-            bios = block;
26ba25
-        }
26ba25
-    }
26ba25
-    assert(ram != NULL);
26ba25
-    assert(oprom != NULL);
26ba25
-    assert(bios != NULL);
26ba25
-    assert(memory_region_is_ram(ram->mr));
26ba25
-    assert(memory_region_is_ram(oprom->mr));
26ba25
-    assert(memory_region_is_ram(bios->mr));
26ba25
-    assert(int128_eq(ram->mr->size, int128_make64(ram->used_length)));
26ba25
-    assert(int128_eq(oprom->mr->size, int128_make64(oprom->used_length)));
26ba25
-    assert(int128_eq(bios->mr->size, int128_make64(bios->used_length)));
26ba25
-
26ba25
-    one_meg = 1024 * 1024;
26ba25
-    oprom_size = 128 * 1024;
26ba25
-    bios_size = 128 * 1024;
26ba25
-    assert(ram->used_length >= one_meg);
26ba25
-    assert(oprom->used_length == oprom_size);
26ba25
-    assert(bios->used_length == bios_size);
26ba25
-
26ba25
-    ef_seg_host = memory_region_get_ram_ptr(ram->mr) + (one_meg - bios_size);
26ba25
-    cd_seg_host = ef_seg_host - oprom_size;
26ba25
-
26ba25
-    /* This is a crude hack, but we must distinguish a rhel6.x.0 machtype guest
26ba25
-     * coming in from a RHEL-6 emulator (where shadowing has had no effect on
26ba25
-     * "pc.ram") from a similar guest coming in from a RHEL-7 emulator (where
26ba25
-     * shadowing has worked). In the latter case we must not trample the live
26ba25
-     * SeaBIOS variables in "pc.ram".
26ba25
-     */
26ba25
-    if (buffer_is_zero(ef_seg_host, bios_size)) {
26ba25
-        fprintf(stderr, "copying E and F segments from pc.bios to pc.ram\n");
26ba25
-        memcpy(ef_seg_host, memory_region_get_ram_ptr(bios->mr), bios_size);
26ba25
-    }
26ba25
-    if (buffer_is_zero(cd_seg_host, oprom_size)) {
26ba25
-        fprintf(stderr, "copying C and D segments from pc.rom to pc.ram\n");
26ba25
-        memcpy(cd_seg_host, memory_region_get_ram_ptr(oprom->mr), oprom_size);
26ba25
-    }
26ba25
-    rcu_read_unlock();
26ba25
-}
26ba25
diff --git a/include/sysemu/sysemu.h b/include/sysemu/sysemu.h
26ba25
index 5832c38..2b42151 100644
26ba25
--- a/include/sysemu/sysemu.h
26ba25
+++ b/include/sysemu/sysemu.h
26ba25
@@ -94,8 +94,6 @@ void qemu_add_machine_init_done_notifier(Notifier *notify);
26ba25
 void qemu_remove_machine_init_done_notifier(Notifier *notify);
26ba25
 
26ba25
 void qemu_announce_self(void);
26ba25
-extern bool shadow_bios_after_incoming;
26ba25
-void shadow_bios(void);
26ba25
 
26ba25
 extern int autostart;
26ba25
 
26ba25
diff --git a/migration/savevm.c b/migration/savevm.c
26ba25
index 56c9feb..6c539d1 100644
26ba25
--- a/migration/savevm.c
26ba25
+++ b/migration/savevm.c
26ba25
@@ -84,7 +84,6 @@ enum qemu_vm_cmd {
26ba25
     MIG_CMD_PACKAGED,          /* Send a wrapped stream within this stream */
26ba25
     MIG_CMD_MAX
26ba25
 };
26ba25
-bool shadow_bios_after_incoming;
26ba25
 
26ba25
 #define MAX_VM_CMD_PACKAGED_SIZE UINT32_MAX
26ba25
 static struct mig_cmd_args {
26ba25
@@ -2206,12 +2205,6 @@ int qemu_loadvm_state(QEMUFile *f)
26ba25
     }
26ba25
 
26ba25
     qemu_loadvm_state_cleanup();
26ba25
-    /* Supplement SeaBIOS's shadowing now, because it was useless when the
26ba25
-     * incoming VM started on the RHEL-6 emulator.
26ba25
-     */
26ba25
-    if (shadow_bios_after_incoming) {
26ba25
-        shadow_bios();
26ba25
-    }
26ba25
 
26ba25
     cpu_synchronize_all_post_init();
26ba25
 
26ba25
diff --git a/numa.c b/numa.c
26ba25
index daf10d8..1116c90 100644
26ba25
--- a/numa.c
26ba25
+++ b/numa.c
26ba25
@@ -493,19 +493,6 @@ void memory_region_allocate_system_memory(MemoryRegion *mr, Object *owner,
26ba25
         return;
26ba25
     }
26ba25
 
26ba25
-    /* The shadow_bios_after_incoming hack at savevm.c:shadow_bios() is not
26ba25
-     * able to handle the multiple memory blocks added when using NUMA
26ba25
-     * memdevs. We can disallow -numa memdev= when using rhel6.* machine-types
26ba25
-     * because RHEL-6 didn't support the NUMA memdev option.
26ba25
-     */
26ba25
-    if (shadow_bios_after_incoming) {
26ba25
-        MachineClass *mc;
26ba25
-        mc = MACHINE_GET_CLASS(current_machine);
26ba25
-        error_report("-numa memdev is not supported by machine %s",
26ba25
-                     mc->name);
26ba25
-        exit(1);
26ba25
-    }
26ba25
-
26ba25
     memory_region_init(mr, owner, name, ram_size);
26ba25
     for (i = 0; i < nb_numa_nodes; i++) {
26ba25
         uint64_t size = numa_info[i].node_mem;
26ba25
diff --git a/stubs/Makefile.objs b/stubs/Makefile.objs
26ba25
index 8f111c5..dfdfca7 100644
26ba25
--- a/stubs/Makefile.objs
26ba25
+++ b/stubs/Makefile.objs
26ba25
@@ -44,4 +44,3 @@ stub-obj-y += xen-hvm.o
26ba25
 stub-obj-y += pci-host-piix.o
26ba25
 stub-obj-y += ram-block.o
26ba25
 stub-obj-y += ide-isa.o
26ba25
-stub-obj-y += shadow-bios.o
26ba25
diff --git a/stubs/shadow-bios.c b/stubs/shadow-bios.c
26ba25
deleted file mode 100644
26ba25
index c77cd7a..0000000
26ba25
--- a/stubs/shadow-bios.c
26ba25
+++ /dev/null
26ba25
@@ -1,7 +0,0 @@
26ba25
-#include "qemu/osdep.h"
26ba25
-#include "sysemu/sysemu.h"
26ba25
-
26ba25
-void shadow_bios(void)
26ba25
-{
26ba25
-  abort();
26ba25
-}
26ba25
-- 
26ba25
1.8.3.1
26ba25