Blame SOURCES/kvm-isapc-Fix-non-KVM-qemu-boot-read-write-memory-for-is.patch

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