Skip to contentSkip to conversation

qxl: create slots on post_load in any state (fix RHBZ 740547)

PATCH In review Alon Levy 2 participants 3 messages Oct 17, 2011

lore
Share & tools
lore

Alon Levy

author
#0 lore raw

PATCH 1/1 qxl: create slots on post_load in any state (fix RHBZ 740547)

If we migrate when the device is not in a native state the guest still believes the slots are created, and will cause operations that reference the slots, causing a "panic: virtual address out of range" on the first of them. Easy to see by migrating in vga mode (with a driver loaded, for instance windows cmd window in full screen mode) and then exiting vga mode back to native mode will cause said panic.

Fixed by doing the slot recreation unconditionally at post_load

---
 hw/qxl.c |   14 ++++++++------
 1 files changed, 8 insertions(+), 6 deletions(-)
hw/qxl.c +8 -6
index 03848ed..4e9f39f 100644
@@ -1684,6 +1684,14 @@ static int qxl_post_load(void *opaque, int version)
         qxl_mode_to_string(d->mode));
     newmode = d->mode;
     d->mode = QXL_MODE_UNDEFINED;
+    for (i = 0; i < NUM_MEMSLOTS; i++) {
+        if (!d->guest_slots[i].active) {
+            continue;
+        }
+        dprint(d, 1, "%s: restoring guest slot %d delta %"PRIu64"\n",
+               __func__, i, d->guest_slots[i].delta);
+        qxl_add_memslot(d, i, d->guest_slots[i].delta, QXL_SYNC);
+    }
     switch (newmode) {
     case QXL_MODE_UNDEFINED:
         break;
@@ -1691,12 +1699,6 @@ static int qxl_post_load(void *opaque, int version)
         qxl_enter_vga_mode(d);
         break;
     case QXL_MODE_NATIVE:
-        for (i = 0; i < NUM_MEMSLOTS; i++) {
-            if (!d->guest_slots[i].active) {
-                continue;
-            }
-            qxl_add_memslot(d, i, 0, QXL_SYNC);
-        }
         qxl_create_guest_primary(d, 1, QXL_SYNC);
 
         /* replay surface-create and cursor-set commands */
Signature · 1 line
1.7.6.4
#1 lore raw

ACK

Quoted 46 lines · Alon Levy

If we migrate when the device is not in a native state the guest still believes the slots are created, and will cause operations that reference the slots, causing a "panic: virtual address out of range" on the first of them. Easy to see by migrating in vga mode (with a driver loaded, for instance windows cmd window in full screen mode) and then exiting vga mode back to native mode will cause said panic.

Fixed by doing the slot recreation unconditionally at post_load

---
  hw/qxl.c |   14 ++++++++------
  1 files changed, 8 insertions(+), 6 deletions(-)
hw/qxl.c +8 -6
index 03848ed..4e9f39f 100644
@@ -1684,6 +1684,14 @@ static int qxl_post_load(void *opaque, int version)
          qxl_mode_to_string(d->mode));
      newmode = d->mode;
      d->mode = QXL_MODE_UNDEFINED;
+    for (i = 0; i<  NUM_MEMSLOTS; i++) {
+        if (!d->guest_slots[i].active) {
+            continue;
+        }
+        dprint(d, 1, "%s: restoring guest slot %d delta %"PRIu64"\n",
+               __func__, i, d->guest_slots[i].delta);
+        qxl_add_memslot(d, i, d->guest_slots[i].delta, QXL_SYNC);
+    }
      switch (newmode) {
      case QXL_MODE_UNDEFINED:
          break;
@@ -1691,12 +1699,6 @@ static int qxl_post_load(void *opaque, int version)
          qxl_enter_vga_mode(d);
          break;
      case QXL_MODE_NATIVE:
-        for (i = 0; i<  NUM_MEMSLOTS; i++) {
-            if (!d->guest_slots[i].active) {
-                continue;
-            }
-            qxl_add_memslot(d, i, 0, QXL_SYNC);
-        }
          qxl_create_guest_primary(d, 1, QXL_SYNC);
 
          /* replay surface-create and cursor-set commands */
author
#2 lore raw
In reply to Alon Levy
Quoted 7 lines · Alon Levy

If we migrate when the device is not in a native state the guest still believes the slots are created, and will cause operations that reference the slots, causing a "panic: virtual address out of range" on the first of them. Easy to see by migrating in vga mode (with a driver loaded, for instance windows cmd window in full screen mode) and then exiting vga mode back to native mode will cause said panic.

Self NACK, doesn't work with compat mode. We don't save delta in migration.

Quoted 43 lines

Fixed by doing the slot recreation unconditionally at post_load

---
 hw/qxl.c |   14 ++++++++------
 1 files changed, 8 insertions(+), 6 deletions(-)
hw/qxl.c +8 -6
index 03848ed..4e9f39f 100644
@@ -1684,6 +1684,14 @@ static int qxl_post_load(void *opaque, int version)
         qxl_mode_to_string(d->mode));
     newmode = d->mode;
     d->mode = QXL_MODE_UNDEFINED;
+    for (i = 0; i < NUM_MEMSLOTS; i++) {
+        if (!d->guest_slots[i].active) {
+            continue;
+        }
+        dprint(d, 1, "%s: restoring guest slot %d delta %"PRIu64"\n",
+               __func__, i, d->guest_slots[i].delta);
+        qxl_add_memslot(d, i, d->guest_slots[i].delta, QXL_SYNC);
+    }
     switch (newmode) {
     case QXL_MODE_UNDEFINED:
         break;
@@ -1691,12 +1699,6 @@ static int qxl_post_load(void *opaque, int version)
         qxl_enter_vga_mode(d);
         break;
     case QXL_MODE_NATIVE:
-        for (i = 0; i < NUM_MEMSLOTS; i++) {
-            if (!d->guest_slots[i].active) {
-                continue;
-            }
-            qxl_add_memslot(d, i, 0, QXL_SYNC);
-        }
         qxl_create_guest_primary(d, 1, QXL_SYNC);
 
         /* replay surface-create and cursor-set commands */
Signature · 1 line
1.7.6.4