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