Skip to contentSkip to conversation

qxl/update_area_io: guest_bug on invalid parameters

PATCH Superseded Alon Levy 2 participants 5 messages Aug 21, 2012

v10 of 11 Superseded Latest is v11 →

lore
Share & tools
lore

Alon Levy

author
#0 lore raw

PATCH v10 1/4 qxl/update_area_io: guest_bug on invalid parameters

---
v9->v10
Use CONFIG_QXL_IO_MONITORS_CONFIG_ASYNC instead of -D directly, define is created in config-host.h so hw/qxl.[ch] is unchanged except for s/QXL_HAS_IO_MONITORS_CONFIG_ASYNC/CONFIG_QXL_IO_MONITORS_CONFIG_ASYNC (Blue Swirl)
No other patches changed. Dropped the wrongly sent last patch.

 hw/qxl.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)
hw/qxl.c +12 -0
index c2dd3b4..6c48eb9 100644
@@ -1385,6 +1385,18 @@ async_common:
         QXLCookie *cookie = NULL;
         QXLRect update = d->ram->update_area;
 
+        if (d->ram->update_surface > NUM_SURFACES) {
+            qxl_set_guest_bug(d, "QXL_IO_UPDATE_AREA: invalid surface id %d\n",
+                              d->ram->update_surface);
+            return;
+        }
+        if (update.left >= update.right || update.top >= update.bottom) {
+            qxl_set_guest_bug(d,
+                    "QXL_IO_UPDATE_AREA: invalid area (%ux%u)x(%ux%u)\n",
+                    update.left, update.top, update.right, update.bottom);
+            return;
+        }
+
         if (async == QXL_ASYNC) {
             cookie = qxl_cookie_new(QXL_COOKIE_TYPE_IO,
                                     QXL_IO_UPDATE_AREA_ASYNC);
Signature · 1 line
1.7.11.2
author
#2 lore raw

PATCH v10 3/4 qxl: add QXL_IO_MONITORS_CONFIG_ASYNC

Revision bumped to 4 for new IO support, enabled for spice-server >= 0.11.1. New io enabled iff revision is 4. Revision can be set to 4, and defaults to 4, iff spice-server >= 0.11.1 && spice-protocol >= 0.12.0.

This io calls the corresponding new spice api spice_qxl_monitors_config_async to let spice-server read a new guest set monitors config and notify the client.

On migration reissue spice_qxl_monitors_config_async.

RHBZ: 770842

---
 configure          |  7 +++++
 hw/qxl.c           | 91 ++++++++++++++++++++++++++++++++++++++++++++++++++++--
 hw/qxl.h           |  8 +++++
 trace-events       |  1 +
 ui/spice-display.h |  1 +
 5 files changed, 105 insertions(+), 3 deletions(-)
configure +7 -0
index cc774b5..84fa2c6 100755
@@ -2657,6 +2657,9 @@ EOF
     spice="yes"
     libs_softmmu="$libs_softmmu $spice_libs"
     QEMU_CFLAGS="$QEMU_CFLAGS $spice_cflags"
+    if $pkg_config --atleast-version=0.12.0 spice-protocol >/dev/null 2>&1; then
+        spice_qxl_io_monitors_config_async="yes"
+    fi
   else
     if test "$spice" = "yes" ; then
       feature_not_found "spice"
@@ -3392,6 +3395,10 @@ if test "$spice" = "yes" ; then
   echo "CONFIG_SPICE=y" >> $config_host_mak
 fi
 
+if test "$spice_qxl_io_monitors_config_async" = "yes" ; then
+  echo "CONFIG_QXL_IO_MONITORS_CONFIG_ASYNC=y" >> $config_host_mak
+fi
+
 if test "$smartcard" = "yes" ; then
   echo "CONFIG_SMARTCARD=y" >> $config_host_mak
 fi
hw/qxl.c +88 -3

177 lines not on this page · raw message

hw/qxl.h +8 -0
index 172baf6..b4fbe0e 100644
@@ -71,6 +71,8 @@ typedef struct PCIQXLDevice {
     } guest_surfaces;
     QXLPHYSICAL        guest_cursor;
 
+    QXLPHYSICAL        guest_monitors_config;
+
     QemuMutex          track_lock;
 
     /* thread signaling */
@@ -128,7 +130,13 @@ typedef struct PCIQXLDevice {
         }                                                               \
     } while (0)
 
+/* 0x000b01 == 0.11.1 */
+#if SPICE_SERVER_VERSION >= 0x000b01 &&\
+    defined(QXL_HAS_IO_MONITORS_CONFIG_ASYNC)
+#define QXL_DEFAULT_REVISION QXL_REVISION_STABLE_V12
+#else
 #define QXL_DEFAULT_REVISION QXL_REVISION_STABLE_V10
+#endif
 
 /* qxl.c */
 void *qxl_phys2virt(PCIQXLDevice *qxl, QXLPHYSICAL phys, int group_id);
trace-events +1 -0
index 04b0723..8fcbc50 100644
@@ -956,6 +956,7 @@ qxl_spice_destroy_surfaces(int qid, int async) "%d async=%d"
 qxl_spice_destroy_surface_wait_complete(int qid, uint32_t id) "%d sid=%d"
 qxl_spice_destroy_surface_wait(int qid, uint32_t id, int async) "%d sid=%d async=%d"
 qxl_spice_flush_surfaces_async(int qid, uint32_t surface_count, uint32_t num_free_res) "%d s#=%d, res#=%d"
+qxl_spice_monitors_config(int id) "%d"
 qxl_spice_loadvm_commands(int qid, void *ext, uint32_t count) "%d ext=%p count=%d"
 qxl_spice_oom(int qid) "%d"
 qxl_spice_reset_cursor(int qid) "%d"
ui/spice-display.h +1 -0
index 12e50b6..7fa095f 100644
@@ -51,6 +51,7 @@ typedef enum qxl_async_io {
 enum {
     QXL_COOKIE_TYPE_IO,
     QXL_COOKIE_TYPE_RENDER_UPDATE_AREA,
+    QXL_COOKIE_TYPE_POST_LOAD_MONITORS_CONFIG,
 };
 
 typedef struct QXLCookie {
Signature · 1 line
1.7.11.2
author
#1 lore raw

PATCH v10 2/4 qxl: disallow unknown revisions

In reply to Alon Levy
---
 hw/qxl.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
hw/qxl.c +4 -1
index 6c48eb9..c978f5e 100644
@@ -1797,10 +1797,13 @@ static int qxl_init_common(PCIQXLDevice *qxl)
         io_size = 16;
         break;
     case 3: /* qxl-3 */
-    default:
         pci_device_rev = QXL_DEFAULT_REVISION;
         io_size = msb_mask(QXL_IO_RANGE_SIZE * 2 - 1);
         break;
+    default:
+        error_report("Invalid revision %d for qxl device (max %d)",
+                     qxl->revision, QXL_DEFAULT_REVISION);
+        return -1;
     }
 
     pci_set_byte(&config[PCI_REVISION_ID], pci_device_rev);
Signature · 1 line
1.7.11.2
author
#4 lore raw

PATCH v10 4/4 configure: print spice-protocol and spice-server versions

In reply to Alon Levy
---
 configure | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
configure +3 -1
index 84fa2c6..02c06aa 100755
@@ -2657,6 +2657,8 @@ EOF
     spice="yes"
     libs_softmmu="$libs_softmmu $spice_libs"
     QEMU_CFLAGS="$QEMU_CFLAGS $spice_cflags"
+    spice_protocol_version=$($pkg_config --modversion spice-protocol)
+    spice_server_version=$($pkg_config --modversion spice-server)
     if $pkg_config --atleast-version=0.12.0 spice-protocol >/dev/null 2>&1; then
         spice_qxl_io_monitors_config_async="yes"
     fi
@@ -3114,7 +3116,7 @@ echo "libcap-ng support $cap_ng"
 echo "vhost-net support $vhost_net"
 echo "Trace backend     $trace_backend"
 echo "Trace output file $trace_file-<pid>"
-echo "spice support     $spice"
+echo "spice support     $spice ($spice_protocol_version/$spice_server_version)"
 echo "rbd support       $rbd"
 echo "xfsctl support    $xfs"
 echo "nss used          $smartcard_nss"
Signature · 1 line
1.7.11.2
#3 lore raw

Re: [Qemu-devel] [PATCH v10 3/4] qxl: add QXL_IO_MONITORS_CONFIG_ASYNC

In reply to Alon Levy
Quoted 10 lines · Alon Levy

Revision bumped to 4 for new IO support, enabled for spice-server >= 0.11.1. New io enabled iff revision is 4. Revision can be set to 4, and defaults to 4, iff spice-server >= 0.11.1 && spice-protocol >= 0.12.0.

This io calls the corresponding new spice api spice_qxl_monitors_config_async to let spice-server read a new guest set monitors config and notify the client.

On migration reissue spice_qxl_monitors_config_async.

Applying: qxl: add QXL_IO_MONITORS_CONFIG_ASYNC === checkpatch complains ===
ERROR: space prohibited before open square bracket '[' #198: FILE: hw/qxl.c:2116:
+ .fields = (VMStateField []) {

ERROR: space prohibited before open square bracket '[' #211: FILE: hw/qxl.c:2148:
+ .subsections = (VMStateSubsection []) {

total: 2 errors, 0 warnings, 231 lines checked