9ae3a8
From 5554a8bea7ed5a16e306fc384a88fe4ff25d9f1a Mon Sep 17 00:00:00 2001
9ae3a8
From: Laszlo Ersek <lersek@redhat.com>
9ae3a8
Date: Sat, 11 Jan 2014 17:59:55 +0100
9ae3a8
Subject: [PATCH 05/22] isapc: Fix non-KVM qemu boot (read/write memory for isapc BIOS)
9ae3a8
9ae3a8
RH-Author: Laszlo Ersek <lersek@redhat.com>
9ae3a8
Message-id: <1389463208-6278-6-git-send-email-lersek@redhat.com>
9ae3a8
Patchwork-id: 56618
9ae3a8
O-Subject: [RHEL-7.0 qemu-kvm PATCH 05/18] isapc: Fix non-KVM qemu boot (read/write memory for isapc BIOS)
9ae3a8
Bugzilla: 1032346
9ae3a8
RH-Acked-by: Paolo Bonzini <pbonzini@redhat.com>
9ae3a8
RH-Acked-by: Amos Kong <akong@redhat.com>
9ae3a8
RH-Acked-by: Andrew Jones <drjones@redhat.com>
9ae3a8
RH-Acked-by: Kevin Wolf <kwolf@redhat.com>
9ae3a8
9ae3a8
From: Jordan Justen <jordan.l.justen@intel.com>
9ae3a8
9ae3a8
The isapc machine with seabios currently requires the BIOS region
9ae3a8
to be read/write memory rather than read-only memory.
9ae3a8
9ae3a8
KVM currently cannot support the BIOS as a ROM region, but qemu
9ae3a8
in non-KVM mode can. Based on this, isapc machine currently only
9ae3a8
works with KVM.
9ae3a8
9ae3a8
To work-around this isapc issue, this change avoids marking the
9ae3a8
BIOS as readonly for isapc.
9ae3a8
9ae3a8
This change also will allow KVM to start supporting ROM mode
9ae3a8
via KVM_CAP_READONLY_MEM.
9ae3a8
9ae3a8
Signed-off-by: Jordan Justen <jordan.l.justen@intel.com>
9ae3a8
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
9ae3a8
Message-id: 1369816047-16384-2-git-send-email-jordan.l.justen@intel.com
9ae3a8
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
9ae3a8
(cherry picked from commit dade922f357c709c02eed2e1b1891453896756dd)
9ae3a8
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
9ae3a8
---
9ae3a8
 hw/block/pc_sysfw.c | 16 +++++++++++-----
9ae3a8
 hw/i386/pc_piix.c   |  5 +++++
9ae3a8
 2 files changed, 16 insertions(+), 5 deletions(-)
9ae3a8
9ae3a8
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
9ae3a8
---
9ae3a8
 hw/block/pc_sysfw.c |   16 +++++++++++-----
9ae3a8
 hw/i386/pc_piix.c   |    5 +++++
9ae3a8
 2 files changed, 16 insertions(+), 5 deletions(-)
9ae3a8
9ae3a8
diff --git a/hw/block/pc_sysfw.c b/hw/block/pc_sysfw.c
9ae3a8
index 6149b20..4d82c70 100644
9ae3a8
--- a/hw/block/pc_sysfw.c
9ae3a8
+++ b/hw/block/pc_sysfw.c
9ae3a8
@@ -39,6 +39,7 @@
9ae3a8
 typedef struct PcSysFwDevice {
9ae3a8
     SysBusDevice busdev;
9ae3a8
     uint8_t rom_only;
9ae3a8
+    uint8_t isapc_ram_fw;
9ae3a8
 } PcSysFwDevice;
9ae3a8
 
9ae3a8
 static void pc_isa_bios_init(MemoryRegion *rom_memory,
9ae3a8
@@ -136,7 +137,7 @@ static void pc_system_flash_init(MemoryRegion *rom_memory,
9ae3a8
     pc_isa_bios_init(rom_memory, flash_mem, size);
9ae3a8
 }
9ae3a8
 
9ae3a8
-static void old_pc_system_rom_init(MemoryRegion *rom_memory)
9ae3a8
+static void old_pc_system_rom_init(MemoryRegion *rom_memory, bool isapc_ram_fw)
9ae3a8
 {
9ae3a8
     char *filename;
9ae3a8
     MemoryRegion *bios, *isa_bios;
9ae3a8
@@ -160,7 +161,9 @@ static void old_pc_system_rom_init(MemoryRegion *rom_memory)
9ae3a8
     bios = g_malloc(sizeof(*bios));
9ae3a8
     memory_region_init_ram(bios, "pc.bios", bios_size);
9ae3a8
     vmstate_register_ram_global(bios);
9ae3a8
-    memory_region_set_readonly(bios, true);
9ae3a8
+    if (!isapc_ram_fw) {
9ae3a8
+        memory_region_set_readonly(bios, true);
9ae3a8
+    }
9ae3a8
     ret = rom_add_file_fixed(bios_name, (uint32_t)(-bios_size), -1);
9ae3a8
     if (ret != 0) {
9ae3a8
     bios_error:
9ae3a8
@@ -183,7 +186,9 @@ static void old_pc_system_rom_init(MemoryRegion *rom_memory)
9ae3a8
                                         0x100000 - isa_bios_size,
9ae3a8
                                         isa_bios,
9ae3a8
                                         1);
9ae3a8
-    memory_region_set_readonly(isa_bios, true);
9ae3a8
+    if (!isapc_ram_fw) {
9ae3a8
+        memory_region_set_readonly(isa_bios, true);
9ae3a8
+    }
9ae3a8
 
9ae3a8
     /* map all the bios at the top of memory */
9ae3a8
     memory_region_add_subregion(rom_memory,
9ae3a8
@@ -213,7 +218,7 @@ void pc_system_firmware_init(MemoryRegion *rom_memory)
9ae3a8
     qdev_init_nofail(DEVICE(sysfw_dev));
9ae3a8
 
9ae3a8
     if (sysfw_dev->rom_only) {
9ae3a8
-        old_pc_system_rom_init(rom_memory);
9ae3a8
+        old_pc_system_rom_init(rom_memory, sysfw_dev->isapc_ram_fw);
9ae3a8
         return;
9ae3a8
     }
9ae3a8
 
9ae3a8
@@ -231,7 +236,7 @@ void pc_system_firmware_init(MemoryRegion *rom_memory)
9ae3a8
             exit(1);
9ae3a8
         } else {
9ae3a8
             sysfw_dev->rom_only = 1;
9ae3a8
-            old_pc_system_rom_init(rom_memory);
9ae3a8
+            old_pc_system_rom_init(rom_memory, sysfw_dev->isapc_ram_fw);
9ae3a8
             return;
9ae3a8
         }
9ae3a8
     }
9ae3a8
@@ -252,6 +257,7 @@ void pc_system_firmware_init(MemoryRegion *rom_memory)
9ae3a8
 }
9ae3a8
 
9ae3a8
 static Property pcsysfw_properties[] = {
9ae3a8
+    DEFINE_PROP_UINT8("isapc_ram_fw", PcSysFwDevice, isapc_ram_fw, 0),
9ae3a8
     DEFINE_PROP_UINT8("rom_only", PcSysFwDevice, rom_only, 0),
9ae3a8
     DEFINE_PROP_END_OF_LIST(),
9ae3a8
 };
9ae3a8
diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c
9ae3a8
index 12351f9..0a8a4e5 100644
9ae3a8
--- a/hw/i386/pc_piix.c
9ae3a8
+++ b/hw/i386/pc_piix.c
9ae3a8
@@ -714,6 +714,11 @@ static QEMUMachine isapc_machine = {
9ae3a8
             .property = "rom_only",
9ae3a8
             .value    = stringify(1),
9ae3a8
         },
9ae3a8
+        {
9ae3a8
+            .driver   = "pc-sysfw",
9ae3a8
+            .property = "isapc_ram_fw",
9ae3a8
+            .value    = stringify(1),
9ae3a8
+        },
9ae3a8
         { /* end of list */ }
9ae3a8
     },
9ae3a8
     DEFAULT_MACHINE_OPTIONS,
9ae3a8
-- 
9ae3a8
1.7.1
9ae3a8