cryptospore / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone

Blame SOURCES/kvm-pc_sysfw-allow-flash-pflash-memory-to-be-used-with-K.patch

0a122b
From 18238ae670fb38f5ca7002bc8da7b7aa9d612f68 Mon Sep 17 00:00:00 2001
0a122b
From: Laszlo Ersek <lersek@redhat.com>
0a122b
Date: Sat, 11 Jan 2014 17:59:58 +0100
0a122b
Subject: [PATCH 08/22] pc_sysfw: allow flash (-pflash) memory to be used with KVM
0a122b
0a122b
RH-Author: Laszlo Ersek <lersek@redhat.com>
0a122b
Message-id: <1389463208-6278-9-git-send-email-lersek@redhat.com>
0a122b
Patchwork-id: 56621
0a122b
O-Subject: [RHEL-7.0 qemu-kvm PATCH 08/18] pc_sysfw: allow flash (-pflash) memory to be used with KVM
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
0a122b
From: Jordan Justen <jordan.l.justen@intel.com>
0a122b
0a122b
When pc-sysfw.rom_only == 0, flash memory will be
0a122b
usable with kvm. In order to enable flash memory mode,
0a122b
a pflash device must be created. (For example, by
0a122b
using the -pflash command line parameter.)
0a122b
0a122b
Usage of a flash memory device with kvm requires
0a122b
KVM_CAP_READONLY_MEM, and kvm will abort if
0a122b
a flash device is used with an older kvm which does
0a122b
not support this capability.
0a122b
0a122b
If a flash device is not used, then qemu/kvm will
0a122b
operate in the original rom-mode.
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-5-git-send-email-jordan.l.justen@intel.com
0a122b
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
0a122b
(cherry picked from commit dafb82e0fc89b631d25f8def649fbfd14fec3db2)
0a122b
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
0a122b
---
0a122b
 hw/block/pc_sysfw.c | 50 +++++++++++++++++++++++++++++++-------------------
0a122b
 1 file changed, 31 insertions(+), 19 deletions(-)
0a122b
0a122b
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
0a122b
---
0a122b
 hw/block/pc_sysfw.c |   50 +++++++++++++++++++++++++++++++-------------------
0a122b
 1 files changed, 31 insertions(+), 19 deletions(-)
0a122b
0a122b
diff --git a/hw/block/pc_sysfw.c b/hw/block/pc_sysfw.c
0a122b
index 4d82c70..76932fc 100644
0a122b
--- a/hw/block/pc_sysfw.c
0a122b
+++ b/hw/block/pc_sysfw.c
0a122b
@@ -217,28 +217,40 @@ void pc_system_firmware_init(MemoryRegion *rom_memory)
0a122b
 
0a122b
     qdev_init_nofail(DEVICE(sysfw_dev));
0a122b
 
0a122b
-    if (sysfw_dev->rom_only) {
0a122b
-        old_pc_system_rom_init(rom_memory, sysfw_dev->isapc_ram_fw);
0a122b
-        return;
0a122b
-    }
0a122b
-
0a122b
     pflash_drv = drive_get(IF_PFLASH, 0, 0);
0a122b
 
0a122b
-    /* Currently KVM cannot execute from device memory.
0a122b
-       Use old rom based firmware initialization for KVM. */
0a122b
-    /*
0a122b
-     * This is a Bad Idea, because it makes enabling/disabling KVM
0a122b
-     * guest-visible.  Let's fix it for real in QEMU 1.6.
0a122b
-     */
0a122b
-    if (kvm_enabled()) {
0a122b
-        if (pflash_drv != NULL) {
0a122b
-            fprintf(stderr, "qemu: pflash cannot be used with kvm enabled\n");
0a122b
-            exit(1);
0a122b
-        } else {
0a122b
-            sysfw_dev->rom_only = 1;
0a122b
-            old_pc_system_rom_init(rom_memory, sysfw_dev->isapc_ram_fw);
0a122b
-            return;
0a122b
+    if (pc_sysfw_flash_vs_rom_bug_compatible) {
0a122b
+        /*
0a122b
+         * This is a Bad Idea, because it makes enabling/disabling KVM
0a122b
+         * guest-visible.  Do it only in bug-compatibility mode.
0a122b
+         */
0a122b
+        if (kvm_enabled()) {
0a122b
+            if (pflash_drv != NULL) {
0a122b
+                fprintf(stderr, "qemu: pflash cannot be used with kvm enabled\n");
0a122b
+                exit(1);
0a122b
+            } else {
0a122b
+                /* In old pc_sysfw_flash_vs_rom_bug_compatible mode, we assume
0a122b
+                 * that KVM cannot execute from device memory. In this case, we
0a122b
+                 * use old rom based firmware initialization for KVM. But, since
0a122b
+                 * this is different from non-kvm mode, this behavior is
0a122b
+                 * undesirable */
0a122b
+                sysfw_dev->rom_only = 1;
0a122b
+            }
0a122b
         }
0a122b
+    } else if (pflash_drv == NULL) {
0a122b
+        /* When a pflash drive is not found, use rom-mode */
0a122b
+        sysfw_dev->rom_only = 1;
0a122b
+    } else if (kvm_enabled() && !kvm_readonly_mem_enabled()) {
0a122b
+        /* Older KVM cannot execute from device memory. So, flash memory
0a122b
+         * cannot be used unless the readonly memory kvm capability is present. */
0a122b
+        fprintf(stderr, "qemu: pflash with kvm requires KVM readonly memory support\n");
0a122b
+        exit(1);
0a122b
+    }
0a122b
+
0a122b
+    /* If rom-mode is active, use the old pc system rom initialization. */
0a122b
+    if (sysfw_dev->rom_only) {
0a122b
+        old_pc_system_rom_init(rom_memory, sysfw_dev->isapc_ram_fw);
0a122b
+        return;
0a122b
     }
0a122b
 
0a122b
     /* If a pflash drive is not found, then create one using
0a122b
-- 
0a122b
1.7.1
0a122b