> From: Qemu-devel [mailto:qemu-devel- > bounces+andrew.baumann=microsoft....@nongnu.org] On Behalf Of Sylvain > Garrigues > Sent: Thursday, 21 April 2016 12:42 > > As the framebuffer settings are copied into the result message before it is > reconfigured, inconsistent behavior can happen when, for instance, you set > with a sinle message the width, height, and depth, and ask at the same time to > allocate the buffer and get the pitch and the size. > > In this case, the reported pitch and size would be incorrect as they were > computed with the initial values of width, height and depth, not the ones the > client requested. > > Signed-off-by: Sylvain Garrigues <sylv...@sylvaingarrigues.com> > --- > hw/misc/bcm2835_property.c | 31 ++++++++++++++++++++++--------- > 1 file changed, 22 insertions(+), 9 deletions(-) > > diff --git a/hw/misc/bcm2835_property.c b/hw/misc/bcm2835_property.c > index 530411f..0102144 100644 > --- a/hw/misc/bcm2835_property.c > +++ b/hw/misc/bcm2835_property.c > @@ -21,6 +21,7 @@ static void > bcm2835_property_mbox_push(BCM2835PropertyState *s, uint32_t value) > int n; > uint32_t offset, length, color; > uint32_t xres, yres, xoffset, yoffset, bpp, pixo, alpha; > + uint32_t tmp_xres, tmp_yres, tmp_xoffset, tmp_yoffset, tmp_bpp, > + tmp_pixo, tmp_alpha; > uint32_t *newxres = NULL, *newyres = NULL, *newxoffset = NULL, > *newyoffset = NULL, *newbpp = NULL, *newpixo = NULL, *newalpha = > NULL; > > @@ -139,7 +140,10 @@ static void > bcm2835_property_mbox_push(BCM2835PropertyState *s, uint32_t value) > > case 0x00040001: /* Allocate buffer */ > stl_le_phys(&s->dma_as, value + 12, s->fbdev->base); > - stl_le_phys(&s->dma_as, value + 16, s->fbdev->size); > + tmp_xres = newxres != NULL ? *newxres : s->fbdev->xres; > + tmp_yres = newyres != NULL ? *newyres : s->fbdev->yres; > + tmp_bpp = newbpp != NULL ? *newbpp : s->fbdev->bpp; > + stl_le_phys(&s->dma_as, value + 16, tmp_xres * tmp_yres * > + (tmp_bpp >> 3));
Personal style nit: I prefer * 8 rather than >> 3, because it's more immediately obvious what you're computing, a trivial optimisation for the compiler, and in this specific example wouldn't need the brackets to ensure the correct operator precedence. But in any case, Reviewed-by: Andrew Baumann <andrew.baum...@microsoft.com> Thanks, Andrew