Skip to contentSkip to conversation

spice: fix checking for surface bpp match

PATCH In review Leo Grange 3 participants 5 messages Aug 6, 2015 – Oct 29, 2015

lore
Share & tools
lore

Leo Grange

author
#0 lore raw

PATCH 1/1 spice: fix checking for surface bpp match

Spice surface_switch fast-path was checking only width/height matching, which leads to a crash when surface bpp has been increased but size didn't change (and probably other issues if bpp has been decreased).

---
 ui/spice-display.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
ui/spice-display.c +4 -3
index 0360abf..d1e0972 100644
@@ -406,10 +406,11 @@ void qemu_spice_display_switch(SimpleSpiceDisplay *ssd,
     SimpleSpiceUpdate *update;
     bool need_destroy;
 
-    if (surface && ssd->surface &&
+    if (surface && ssd->surface && ssd->ds &&
         surface_width(surface) == pixman_image_get_width(ssd->surface) &&
-        surface_height(surface) == pixman_image_get_height(ssd->surface)) {
-        /* no-resize fast path: just swap backing store */
+        surface_height(surface) == pixman_image_get_height(ssd->surface) &&
+		surface_bits_per_pixel(surface) == surface_bits_per_pixel(ssd->ds)) {
+        /* no-resize and no bpp change fast path: just swap backing store */
         dprint(1, "%s/%d: fast (%dx%d)\n", __func__, ssd->qxl.id,
                surface_width(surface), surface_height(surface));
         qemu_mutex_lock(&ssd->lock);
Signature · 1 line
2.5.0
#1 lore raw

Ping, as I had no feedback about this small patch. Please tell me if I need to do anything else.

2015-08-06 17:36 GMT+02:00 Leo Grange <[email protected]>:

Quoted 31 lines

Spice surface_switch fast-path was checking only width/height matching, which leads to a crash when surface bpp has been increased but size didn't change (and probably other issues if bpp has been decreased).

---
 ui/spice-display.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
ui/spice-display.c +4 -4
index 0360abf..d1e0972 100644
@@ -406,10 +406,11 @@ void qemu_spice_display_switch(SimpleSpiceDisplay *ssd,
     SimpleSpiceUpdate *update;
     bool need_destroy;
 
-    if (surface && ssd->surface &&
+    if (surface && ssd->surface && ssd->ds &&
         surface_width(surface) == pixman_image_get_width(ssd->surface) &&
-        surface_height(surface) == pixman_image_get_height(ssd->surface)) {
-        /* no-resize fast path: just swap backing store */
+        surface_height(surface) == pixman_image_get_height(ssd->surface) &&
+               surface_bits_per_pixel(surface) == surface_bits_per_pixel(ssd->ds)) {
+        /* no-resize and no bpp change fast path: just swap backing store */
         dprint(1, "%s/%d: fast (%dx%d)\n", __func__, ssd->qxl.id,
                surface_width(surface), surface_height(surface));
         qemu_mutex_lock(&ssd->lock);
--

2.5.0

#2 lore raw
Quoted 2 lines · Léo Grange

Ping, as I had no feedback about this small patch. Please tell me if I need to do anything else.

Hello!

I've seen initial version of your patch, thought it isn't exactly trivial ;), and hoped someone will comment. Only now I realized you sent it to -trivial but not to -devel, so there's no one to comment on it. Please don't do this, always include qemu-devel when sending patches, so a patch will have a chance to be reviewed. I've added qemu-devel to Cc now.

Here, I _think_ the patch is okay, but it'd be better for it to have some review still.

Thanks,

/mjt

Quoted 33 lines

2015-08-06 17:36 GMT+02:00 Leo Grange <[email protected]>:

Quoted 31 lines

Spice surface_switch fast-path was checking only width/height matching, which leads to a crash when surface bpp has been increased but size didn't change (and probably other issues if bpp has been decreased).

---
 ui/spice-display.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
ui/spice-display.c +4 -4
index 0360abf..d1e0972 100644
@@ -406,10 +406,11 @@ void qemu_spice_display_switch(SimpleSpiceDisplay *ssd,
     SimpleSpiceUpdate *update;
     bool need_destroy;
 
-    if (surface && ssd->surface &&
+    if (surface && ssd->surface && ssd->ds &&
         surface_width(surface) == pixman_image_get_width(ssd->surface) &&
-        surface_height(surface) == pixman_image_get_height(ssd->surface)) {
-        /* no-resize fast path: just swap backing store */
+        surface_height(surface) == pixman_image_get_height(ssd->surface) &&
+               surface_bits_per_pixel(surface) == surface_bits_per_pixel(ssd->ds)) {
+        /* no-resize and no bpp change fast path: just swap backing store */
         dprint(1, "%s/%d: fast (%dx%d)\n", __func__, ssd->qxl.id,
                surface_width(surface), surface_height(surface));
         qemu_mutex_lock(&ssd->lock);
--

2.5.0

#3 lore raw
Quoted 6 lines · Michael Tokarev
Quoted 2 lines · Léo Grange

Ping, as I had no feedback about this small patch. Please tell me if I need to do anything else.

Hello!

Quoted 8 lines

I've seen initial version of your patch, thought it isn't exactly trivial ;), and hoped someone will comment. Only now I realized you sent it to -trivial but not to -devel, so there's no one to comment on it. Please don't do this, always include qemu-devel when sending patches, so a patch will have a chance to be reviewed. I've added qemu-devel to Cc now.

Here, I _think_ the patch is okay, but it'd be better for it to have some review still.

Gerd, Cc'ing you this time, can you please take a look at this patch?

Thanks,

/mjt

Quoted 35 lines
Quoted 33 lines

2015-08-06 17:36 GMT+02:00 Leo Grange <[email protected]>:

Quoted 31 lines

Spice surface_switch fast-path was checking only width/height matching, which leads to a crash when surface bpp has been increased but size didn't change (and probably other issues if bpp has been decreased).

---
 ui/spice-display.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
ui/spice-display.c +4 -4
index 0360abf..d1e0972 100644
@@ -406,10 +406,11 @@ void qemu_spice_display_switch(SimpleSpiceDisplay *ssd,
     SimpleSpiceUpdate *update;
     bool need_destroy;
 
-    if (surface && ssd->surface &&
+    if (surface && ssd->surface && ssd->ds &&
         surface_width(surface) == pixman_image_get_width(ssd->surface) &&
-        surface_height(surface) == pixman_image_get_height(ssd->surface)) {
-        /* no-resize fast path: just swap backing store */
+        surface_height(surface) == pixman_image_get_height(ssd->surface) &&
+               surface_bits_per_pixel(surface) == surface_bits_per_pixel(ssd->ds)) {
+        /* no-resize and no bpp change fast path: just swap backing store */
         dprint(1, "%s/%d: fast (%dx%d)\n", __func__, ssd->qxl.id,
                surface_width(surface), surface_height(surface));
         qemu_mutex_lock(&ssd->lock);
--

2.5.0

#4 lore raw
Quoted 13 lines · Michael Tokarev
Quoted 12 lines · Michael Tokarev
Quoted 2 lines · Léo Grange

Ping, as I had no feedback about this small patch. Please tell me if I need to do anything else.

Hello!

I've seen initial version of your patch, thought it isn't exactly trivial ;), and hoped someone will comment. Only now I realized you sent it to -trivial but not to -devel, so there's no one to comment on it. Please don't do this, always include qemu-devel when sending patches, so a patch will have a chance to be reviewed. I've added qemu-devel to Cc now.

Quoted 4 lines
Quoted 2 lines

Here, I _think_ the patch is okay, but it'd be better for it to have some review still.

Gerd, Cc'ing you this time, can you please take a look at this patch?

Obsolete, commit b2af43cc379e1d4c30d92af257bedebf0e3f618a fixes this (and a few more cases).

cheers,
Gerd