OSDN Git Service

ramfb: fix size calculation
authorGerd Hoffmann <kraxel@redhat.com>
Wed, 29 Apr 2020 11:52:36 +0000 (13:52 +0200)
committerGerd Hoffmann <kraxel@redhat.com>
Mon, 18 May 2020 13:43:51 +0000 (15:43 +0200)
commit3fcf15df0073a76d37e2816597771d4c9763e413
treef0975d07b7c1062416c7c8555c8c9cb1ad1d7ac2
parent819c83e27895472befbfee67d3d7d089c61d7fbd
ramfb: fix size calculation

size calculation isn't correct with guest-supplied stride, the last
display line isn't accounted for correctly.

For the typical case of stride > linesize (add padding) we error on the
safe side (calculated size is larger than actual size).

With stride < linesize (scanlines overlap) the calculated size is
smaller than the actual size though so our guest memory mapping might
end up being too small.

While being at it also fix ramfb_create_display_surface to use hwaddr
for the parameters.  That way all calculation are done with hwaddr type
and we can't get funny effects from type castings.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Acked-by: Laszlo Ersek <lersek@redhat.com>
Message-id: 20200429115236.28709-7-kraxel@redhat.com
hw/display/ramfb.c