cryptospore / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone

Blame SOURCES/kvm-exec-rom_reset-Free-rom-data-during-inmigrate-skip.patch

22c213
From 5770fe43fe1e15e6f53cfd3705605e8645b95a98 Mon Sep 17 00:00:00 2001
22c213
From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
22c213
Date: Fri, 13 Mar 2020 17:17:08 +0000
22c213
Subject: [PATCH 20/20] exec/rom_reset: Free rom data during inmigrate skip
22c213
MIME-Version: 1.0
22c213
Content-Type: text/plain; charset=UTF-8
22c213
Content-Transfer-Encoding: 8bit
22c213
22c213
RH-Author: Dr. David Alan Gilbert <dgilbert@redhat.com>
22c213
Message-id: <20200313171708.242774-1-dgilbert@redhat.com>
22c213
Patchwork-id: 94292
22c213
O-Subject: [RHEL-AV-8.2.0 qemu-kvm PATCH 1/1] exec/rom_reset: Free rom data during inmigrate skip
22c213
Bugzilla: 1809380
22c213
RH-Acked-by: Daniel P. Berrange <berrange@redhat.com>
22c213
RH-Acked-by: Philippe Mathieu-Daudé <philmd@redhat.com>
22c213
RH-Acked-by: Paolo Bonzini <pbonzini@redhat.com>
22c213
22c213
From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
22c213
22c213
bz: https://bugzilla.redhat.com/show_bug.cgi?id=1809380
22c213
brew: https://brewweb.engineering.redhat.com/brew/taskinfo?taskID=27249921
22c213
branch: rhel-av-8.2.0
22c213
upstream: Posted and with review-by, not merged yet
22c213
22c213
Commit 355477f8c73e9 skips rom reset when we're an incoming migration
22c213
so as not to overwrite shared ram in the ignore-shared migration
22c213
optimisation.
22c213
However, it's got an unexpected side effect that because it skips
22c213
freeing the ROM data, when rom_reset gets called later on, after
22c213
migration (e.g. during a reboot), the ROM does get reset to the original
22c213
file contents.  Because of seabios/x86's weird reboot process
22c213
this confuses a reboot into hanging after a migration.
22c213
22c213
Fixes: 355477f8c73e9 ("migration: do not rom_reset() during incoming migration")
22c213
https://bugzilla.redhat.com/show_bug.cgi?id=1809380
22c213
22c213
Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
22c213
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
22c213
---
22c213
 hw/core/loader.c | 25 ++++++++++++++++---------
22c213
 1 file changed, 16 insertions(+), 9 deletions(-)
22c213
22c213
diff --git a/hw/core/loader.c b/hw/core/loader.c
22c213
index 5099f27..375b29b 100644
22c213
--- a/hw/core/loader.c
22c213
+++ b/hw/core/loader.c
22c213
@@ -1118,19 +1118,26 @@ static void rom_reset(void *unused)
22c213
 {
22c213
     Rom *rom;
22c213
 
22c213
-    /*
22c213
-     * We don't need to fill in the RAM with ROM data because we'll fill
22c213
-     * the data in during the next incoming migration in all cases.  Note
22c213
-     * that some of those RAMs can actually be modified by the guest on ARM
22c213
-     * so this is probably the only right thing to do here.
22c213
-     */
22c213
-    if (runstate_check(RUN_STATE_INMIGRATE))
22c213
-        return;
22c213
-
22c213
     QTAILQ_FOREACH(rom, &roms, next) {
22c213
         if (rom->fw_file) {
22c213
             continue;
22c213
         }
22c213
+        /*
22c213
+         * We don't need to fill in the RAM with ROM data because we'll fill
22c213
+         * the data in during the next incoming migration in all cases.  Note
22c213
+         * that some of those RAMs can actually be modified by the guest.
22c213
+         */
22c213
+        if (runstate_check(RUN_STATE_INMIGRATE)) {
22c213
+            if (rom->data && rom->isrom) {
22c213
+                /*
22c213
+                 * Free it so that a rom_reset after migration doesn't
22c213
+                 * overwrite a potentially modified 'rom'.
22c213
+                 */
22c213
+                rom_free_data(rom);
22c213
+            }
22c213
+            continue;
22c213
+        }
22c213
+
22c213
         if (rom->data == NULL) {
22c213
             continue;
22c213
         }
22c213
-- 
22c213
1.8.3.1
22c213