thebeanogamer / rpms / qemu-kvm

Forked from rpms/qemu-kvm 5 months ago
Clone

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

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