hw/display/qxl: improve framebuffer error message
PATCH 1/2 hw/display/qxl: improve framebuffer error message
--- hw/display/qxl.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
hw/display/qxl.c +2 -1
@@ -1367,7 +1367,8 @@ static void qxl_create_guest_primary(PCIQXLDevice *qxl, int loadvm, size =abs (requested_stride) * requested_height;if (size > qxl->vgamem_size) {qxl_set_guest_bug (qxl,"%s: requested primary larger then framebuffer" -" size" , __func__); +" size %d > %d" , __func__, size, + qxl->vgamem_size);return ; }
Signature · 1 line
1.8.4.2
PATCH 2/2 qxl: clear irq on reset
Without this we occasionally trigger an assert at hw/pci/pci.c:pcibus_reset that asserts the irq_count is zero on reset.
This has become a problem with the new drm driver for linux, since doing a reboot from console causes a race between console updates that set the irq and the reset assertion that the irq is clear.
--- hw/display/qxl.c | 1 + 1 file changed, 1 insertion(+)
hw/display/qxl.c +1 -0
@@ -1126,6 +1126,7 @@ static void qxl_reset_state(PCIQXLDevice *d) d->num_free_res =0 ; d->last_release =NULL ;memset (&d->ssd.dirty,0 ,sizeof (d->ssd.dirty)); +qxl_update_irq (d); }static void qxl_soft_reset (PCIQXLDevice *d)
Signature · 1 line
1.8.4.2
Re: [Qemu-devel] [PATCH 2/2] qxl: clear irq on reset
Quoted 9 lines · Alon Levy
Without this we occasionally trigger an assert at hw/pci/pci.c:pcibus_reset that asserts the
irq_countis zero on reset.This has become a problem with the new drm driver for linux, since doing
a reboot from console causes a race between console updates that set the
irq and the reset assertion that the irq is clear.
Added to spice patch queue.
thanks,
Gerd
Quoted 10 lines · Alon Levy
Signed-off-by Alon Levy <[email protected]>--- hw/display/qxl.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)hw/display/qxl.c +0
-0
hw/display/qxl.c static void qxl_create_guest_primary(PCIQXLDevice *qxl, int loadvm, · line 1373
Quoted 8 lines
hw/display/qxl.c +2
-1@@ -1367,7 +1367,8 @@ static void qxl_create_guest_primary(PCIQXLDevice *qxl, int loadvm, size =abs (requested_stride) * requested_height;if (size > qxl->vgamem_size) {qxl_set_guest_bug (qxl,"%s: requested primary larger then framebuffer" -" size" , __func__); +" size %d > %d" , __func__, size, + qxl->vgamem_size);return ; }
Shouldn't you use %u or %PRIu32 to print uint32_t qxl->vgamem_size?
Hmm, we're comparing int size to uint32_t vgamem_size, not nice. Should size be unsigned?
Since you touch the message anyway, you could fix "larger then" to "larger than".
PATCH v2 1/1 hw/display/qxl: fix signed to unsigned comparison
Fix signed to unsigned comparison in qxl_create_guest_primary and add the size of the framebuffer to the error message used when setting the guest bug state (which causes a complete guess blackout until reset, so it helps if it is verbose).
--- hw/display/qxl.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
hw/display/qxl.c +4 -3
@@ -1360,14 +1360,15 @@ static void qxl_create_guest_primary(PCIQXLDevice *qxl, int loadvm, {QXLDevSurfaceCreate surface;QXLSurfaceCreate *sc = &qxl->guest_primary.surface; -int size; +uint32_t size;int requested_height =le32_to_cpu (sc->height);int requested_stride =le32_to_cpu (sc->stride); size =abs (requested_stride) * requested_height;if (size > qxl->vgamem_size) { -qxl_set_guest_bug (qxl,"%s: requested primary larger then framebuffer" -" size" , __func__); +qxl_set_guest_bug (qxl,"%s: requested primary larger than framebuffer" +" size %u > %u" , __func__, size, + qxl->vgamem_size);return ; }
Signature · 1 line
1.8.4.2
Re: [Qemu-devel] [PATCH v2] hw/display/qxl: fix signed to unsigned comparison
Quoted 6 lines · Alon Levy
Fix signed to unsigned comparison in
qxl_create_guest_primaryand add the size of the framebuffer to the error message used when setting the guest bug state (which causes a complete guess blackout until reset, so it helps if it is verbose).Signed-off-by Alon Levy <[email protected]>
Re: [Qemu-devel] [PATCH v2] hw/display/qxl: fix signed to unsigned comparison
In reply to Alon LevyQuoted 15 lines · Alon Levy
Fix signed to unsigned comparison in
qxl_create_guest_primaryand add the size of the framebuffer to the error message used when setting the guest bug state (which causes a complete guess blackout until reset, so it helps if it is verbose).Signed-off-by Alon Levy <[email protected]>--- hw/display/qxl.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)hw/display/qxl.c +0
-0
hw/display/qxl.c static void qxl_create_guest_primary(PCIQXLDevice *qxl, int loadvm, · line 1367
Quoted 9 lines
hw/display/qxl.c +1
-1@@ -1360,14 +1360,15 @@ static void qxl_create_guest_primary(PCIQXLDevice *qxl, int loadvm, {QXLDevSurfaceCreate surface;QXLSurfaceCreate *sc = &qxl->guest_primary.surface; -int size; +uint32_t size;int requested_height =le32_to_cpu (sc->height);int requested_stride =le32_to_cpu (sc->stride); size =abs (requested_stride) * requested_height;
This looks a bit dubious -- the multiply is still going to be done with signed arithmetic, so if it's possible we might overflow so as to require a uint32_t size then we've already hit undefined behaviour. Also, if the multiply overflows 32 bits the check will not catch this. Probably better to do this as a 64 bit multiply.
Is requested_height really supposed to be signed? Why is requested_stride an int that needs to go through abs()? What is the behaviour supposed to be if it is the minimum integer (in which case abs(x) is undefined)?
hw/display/qxl.c static void qxl_create_guest_primary(PCIQXLDevice *qxl, int loadvm, · line 1373
Quoted 8 lines
hw/display/qxl.c +3
-2if (size > qxl->vgamem_size) { -qxl_set_guest_bug (qxl,"%s: requested primary larger then framebuffer" -" size" , __func__); +qxl_set_guest_bug (qxl,"%s: requested primary larger than framebuffer" +" size %u > %u" , __func__, size, + qxl->vgamem_size);return ; }
PRIu32 is more portable for printing uint32_t types.
thanks
-- PMM