Skip to contentSkip to conversation

qxl: don't assert() if device isn't yet initialized

PATCH In review [email protected] 2 participants 2 messages Aug 14, 2023 – Aug 17, 2023

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 qxl: don't assert() if device isn't yet initialized

From: Marc-André Lureau <[email protected]>

If the PCI BAR isn't yet mapped or was unmapped, QXL_IO_SET_MODE will assert(). Instead, report a guest bug and keep going.

This can be reproduced with:

cat << EOF | ./qemu-system-x86_64 -vga qxl -m 2048 -nodefaults -qtest stdio outl 0xcf8 0x8000101c
outl 0xcfc 0xc000
outl 0xcf8 0x80001001
outl 0xcfc 0x01000000
outl 0xc006 0x00
EOF

---
 hw/display/qxl.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
hw/display/qxl.c +4 -1
index f1c0eb7dfc..70b73820b2 100644
@@ -1591,7 +1591,10 @@ static void qxl_set_mode(PCIQXLDevice *d, unsigned int modenr, int loadvm)
     }
 
     d->guest_slots[0].slot = slot;
-    assert(qxl_add_memslot(d, 0, devmem, QXL_SYNC) == 0);
+    if (qxl_add_memslot(d, 0, devmem, QXL_SYNC) != 0) {
+        qxl_set_guest_bug(d, "device isn't initialized yet");
+        return;
+    }
 
     d->guest_primary.surface = surface;
     qxl_create_guest_primary(d, 0, QXL_SYNC);
Signature · 1 line
2.41.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 28 lines · On 14/08/2023 21.33, [email protected] wrote:

From: Marc-André Lureau <[email protected]>

If the PCI BAR isn't yet mapped or was unmapped, QXL_IO_SET_MODE will assert(). Instead, report a guest bug and keep going.

This can be reproduced with:

cat << EOF | ./qemu-system-x86_64 -vga qxl -m 2048 -nodefaults -qtest stdio outl 0xcf8 0x8000101c
outl 0xcfc 0xc000
outl 0xcf8 0x80001001
outl 0xcfc 0x01000000
outl 0xc006 0x00
EOF

---
  hw/display/qxl.c | 5 ++++-
  1 file changed, 4 insertions(+), 1 deletion(-)
hw/display/qxl.c +0 -0
index f1c0eb7dfc..70b73820b2 100644
@@ -1591,7 +1591,10 @@ static void qxl_set_mode(PCIQXLDevice *d, unsigned int modenr, int loadvm)
      }

hw/display/qxl.c static void qxl_set_mode(PCIQXLDevice *d, unsigned int modenr, int loadvm) · line 1600

Quoted 10 lines
hw/display/qxl.c +4 -1
 
      d->guest_slots[0].slot = slot;
-    assert(qxl_add_memslot(d, 0, devmem, QXL_SYNC) == 0);
+    if (qxl_add_memslot(d, 0, devmem, QXL_SYNC) != 0) {
+        qxl_set_guest_bug(d, "device isn't initialized yet");
+        return;
+    }
 
      d->guest_primary.surface = surface;
      qxl_create_guest_primary(d, 0, QXL_SYNC);