From: "Marc-André Lureau" <marcandre.lureau@redhat.com>
To: qemu-devel@nongnu.org
Cc: "Stefan Hajnoczi" <stefanha@redhat.com>,
"Alex Bennée" <alex.bennee@linaro.org>,
"Akihiko Odaki" <odaki@rsg.ci.i.u-tokyo.ac.jp>,
"Dmitry Osipenko" <dmitry.osipenko@collabora.com>,
"Michael S. Tsirkin" <mst@redhat.com>
Subject: [GIT PULL 01/23] hw/display/virtio-gpu: Remove the bytes_pp field
Date: Mon, 27 Jul 2026 15:51:10 +0400 [thread overview]
Message-ID: <20260727-fix-v1-1-ca3fa3851347@redhat.com> (raw)
In-Reply-To: <20260727-fix-v1-0-ca3fa3851347@redhat.com>
From: Akihiko Odaki <odaki@rsg.ci.i.u-tokyo.ac.jp>
virtio_gpu_do_set_scanout() validates the stride field of struct
virtio_gpu_framebuffer against the bytes_pp field, but bytes_pp in the
migration stream may be inconsistent with the format field, which
pixman_image_create_bits() uses when it accesses the framebuffer.
That validation is therefore incomplete.
To avoid the trouble of synchronizing the two fields, remove bytes_pp,
and always derive its value from format. Removing bytes_pp is safe
because no released version of QEMU uses its migrated value.
Fixes: 7b5574225429 ("hw/display: check frame buffer can hold blob")
Cc: qemu-stable@nongnu.org
Reviewed-by: Dmitry Osipenko <dmitry.osipenko@collabora.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
[ Marc-André - fix rebase conflict ]
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Signed-off-by: Akihiko Odaki <odaki@rsg.ci.i.u-tokyo.ac.jp>
Message-ID: <20260719-bpp-v1-1-9b91946d6cf3@rsg.ci.i.u-tokyo.ac.jp>
---
include/hw/virtio/virtio-gpu.h | 1 -
hw/display/virtio-gpu.c | 27 +++++++++++++++++----------
2 files changed, 17 insertions(+), 11 deletions(-)
diff --git a/include/hw/virtio/virtio-gpu.h b/include/hw/virtio/virtio-gpu.h
index b9bad27c97a8..2f60c72078b3 100644
--- a/include/hw/virtio/virtio-gpu.h
+++ b/include/hw/virtio/virtio-gpu.h
@@ -66,7 +66,6 @@ struct virtio_gpu_simple_resource {
struct virtio_gpu_framebuffer {
pixman_format_code_t format;
- uint32_t bytes_pp;
uint32_t width, height;
uint32_t stride;
uint32_t offset;
diff --git a/hw/display/virtio-gpu.c b/hw/display/virtio-gpu.c
index 718ba3039290..eac039c3c366 100644
--- a/hw/display/virtio-gpu.c
+++ b/hw/display/virtio-gpu.c
@@ -617,6 +617,11 @@ void virtio_gpu_update_scanout(VirtIOGPU *g,
scanout->fb = *fb;
}
+static uint32_t virtio_gpu_format_bytes_pp(pixman_format_code_t format)
+{
+ return DIV_ROUND_UP(PIXMAN_FORMAT_BPP(format), 8);
+}
+
static bool virtio_gpu_do_set_scanout(VirtIOGPU *g,
uint32_t scanout_id,
struct virtio_gpu_framebuffer *fb,
@@ -625,6 +630,7 @@ static bool virtio_gpu_do_set_scanout(VirtIOGPU *g,
uint32_t *error)
{
struct virtio_gpu_scanout *scanout;
+ uint32_t bytes_pp = virtio_gpu_format_bytes_pp(fb->format);
uint8_t *data;
scanout = &g->parent_obj.scanout[scanout_id];
@@ -646,10 +652,10 @@ static bool virtio_gpu_do_set_scanout(VirtIOGPU *g,
return false;
}
- if (fb->stride < (uint64_t)fb->width * fb->bytes_pp) {
+ if (fb->stride < (uint64_t)fb->width * bytes_pp) {
qemu_log_mask(LOG_GUEST_ERROR,
"%s: stride %u too small for width %u at %u bpp\n",
- __func__, fb->stride, fb->width, fb->bytes_pp);
+ __func__, fb->stride, fb->width, bytes_pp);
*error = VIRTIO_GPU_RESP_ERR_INVALID_PARAMETER;
return false;
}
@@ -720,6 +726,7 @@ static void virtio_gpu_set_scanout(VirtIOGPU *g,
struct virtio_gpu_simple_resource *res;
struct virtio_gpu_framebuffer fb = { 0 };
struct virtio_gpu_set_scanout ss;
+ uint32_t bytes_pp;
VIRTIO_GPU_FILL_CMD(ss);
virtio_gpu_bswap_32(&ss, sizeof(ss));
@@ -745,11 +752,11 @@ static void virtio_gpu_set_scanout(VirtIOGPU *g,
}
fb.format = pixman_image_get_format(res->image);
- fb.bytes_pp = DIV_ROUND_UP(PIXMAN_FORMAT_BPP(fb.format), 8);
+ bytes_pp = virtio_gpu_format_bytes_pp(fb.format);
fb.width = pixman_image_get_width(res->image);
fb.height = pixman_image_get_height(res->image);
fb.stride = pixman_image_get_stride(res->image);
- fb.offset = ss.r.x * fb.bytes_pp + ss.r.y * fb.stride;
+ fb.offset = ss.r.x * bytes_pp + ss.r.y * fb.stride;
virtio_gpu_do_set_scanout(g, ss.scanout_id,
&fb, res, &ss.r, &cmd->error);
@@ -760,6 +767,7 @@ bool virtio_gpu_scanout_blob_to_fb(struct virtio_gpu_framebuffer *fb,
uint64_t blob_size)
{
uint64_t fbend;
+ uint32_t bytes_pp;
fb->format = virtio_gpu_get_pixman_format(ss->format);
if (!fb->format) {
@@ -769,15 +777,15 @@ bool virtio_gpu_scanout_blob_to_fb(struct virtio_gpu_framebuffer *fb,
return false;
}
- fb->bytes_pp = DIV_ROUND_UP(PIXMAN_FORMAT_BPP(fb->format), 8);
+ bytes_pp = virtio_gpu_format_bytes_pp(fb->format);
fb->width = ss->width;
fb->height = ss->height;
fb->stride = ss->strides[0];
- if (fb->stride < (uint64_t)fb->width * fb->bytes_pp) {
+ if (fb->stride < (uint64_t)fb->width * bytes_pp) {
qemu_log_mask(LOG_GUEST_ERROR,
"%s: stride %u too small for width %u at %u bpp\n",
- __func__, fb->stride, fb->width, fb->bytes_pp);
+ __func__, fb->stride, fb->width, bytes_pp);
return false;
}
@@ -788,7 +796,7 @@ bool virtio_gpu_scanout_blob_to_fb(struct virtio_gpu_framebuffer *fb,
return false;
}
- fb->offset = ss->offsets[0] + ss->r.x * fb->bytes_pp + ss->r.y * fb->stride;
+ fb->offset = ss->offsets[0] + ss->r.x * bytes_pp + ss->r.y * fb->stride;
fbend = fb->offset;
fbend += (uint64_t) fb->stride * ss->r.height;
@@ -1238,8 +1246,7 @@ static const VMStateDescription vmstate_virtio_gpu_scanout = {
VMSTATE_UINT32(cursor.pos.y, struct virtio_gpu_scanout),
VMSTATE_UINT32_TEST(fb.format, struct virtio_gpu_scanout,
scanout_vmstate_after_v2),
- VMSTATE_UINT32_TEST(fb.bytes_pp, struct virtio_gpu_scanout,
- scanout_vmstate_after_v2),
+ VMSTATE_UNUSED_TEST(scanout_vmstate_after_v2, 4),
VMSTATE_UINT32_TEST(fb.width, struct virtio_gpu_scanout,
scanout_vmstate_after_v2),
VMSTATE_UINT32_TEST(fb.height, struct virtio_gpu_scanout,
--
2.55.0
next prev parent reply other threads:[~2026-07-27 11:53 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-27 11:51 [GIT PULL 00/23] Fixes for 11.1-rc2 Marc-André Lureau
2026-07-27 11:51 ` Marc-André Lureau [this message]
2026-07-27 11:51 ` [GIT PULL 02/23] hw/display/vhost-user-gpu: validate message payload sizes Marc-André Lureau
2026-07-27 11:51 ` [GIT PULL 03/23] ui/vnc: remove redundant rows computation Marc-André Lureau
2026-07-27 11:51 ` [GIT PULL 04/23] hw/display/qxl: unregister vm_change_state handler and BHs Marc-André Lureau
2026-07-27 11:51 ` [GIT PULL 05/23] net/colo: fix g_hash_table_destroy assertion on uninitialized filter Marc-André Lureau
2026-07-27 11:51 ` [GIT PULL 06/23] target/i386/sev: fix MemoryRegion reference leaks in gpa2hva callers Marc-André Lureau
2026-07-27 11:51 ` [GIT PULL 07/23] virtio-gpu: fix NULL deref in rutabaga set_scanout Marc-André Lureau
2026-07-27 11:51 ` [GIT PULL 08/23] docs/hyperv: fix misleading hv-crash shutdown description Marc-André Lureau
2026-07-27 11:51 ` [GIT PULL 09/23] hw/display/virtio-gpu: Fix empty blob discrimination Marc-André Lureau
2026-07-27 11:51 ` [GIT PULL 10/23] hw/display/virtio-gpu: Initialize blob mapping for ATTACH_BACKING Marc-André Lureau
2026-07-27 11:51 ` [GIT PULL 11/23] hw/display/virtio-gpu: Avoid leaking migration blocker Marc-André Lureau
2026-07-27 11:51 ` [GIT PULL 12/23] hw/display/virtio-gpu: Block Rutabaga migration Marc-André Lureau
2026-07-27 11:51 ` [GIT PULL 13/23] hw/display/virtio-gpu-rutabaga: zero-init capset info response Marc-André Lureau
2026-07-27 11:51 ` [GIT PULL 14/23] hw/cxl: fix invalid free on early return Marc-André Lureau
2026-07-27 11:51 ` [GIT PULL 15/23] hw/hexagon: fix machine->fdt leak in qom-test Marc-André Lureau
2026-07-27 11:51 ` [GIT PULL 16/23] block/blkio: fix compiler false-positive warning Marc-André Lureau
2026-07-27 11:51 ` [GIT PULL 17/23] monitor: annotate monitor_qmp_dispatcher_pop_any() as coroutine Marc-André Lureau
2026-07-27 11:51 ` [GIT PULL 18/23] migration: fix qemu_get_counted_string annotation Marc-André Lureau
2026-07-27 11:51 ` [GIT PULL 19/23] io: add missing coroutine annotation Marc-André Lureau
2026-07-27 11:51 ` [GIT PULL 20/23] block: " Marc-André Lureau
2026-07-27 11:51 ` [GIT PULL 21/23] qcow2: remove invalid qcow2_check_refcounts calls Marc-André Lureau
2026-07-27 11:51 ` [GIT PULL 22/23] hw/9pfs: annotate V9fsTransport callbacks as coroutine_fn Marc-André Lureau
2026-07-27 11:51 ` [GIT PULL 23/23] migration/rdma: annotate and simplify wait_comp_channel() Marc-André Lureau
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260727-fix-v1-1-ca3fa3851347@redhat.com \
--to=marcandre.lureau@redhat.com \
--cc=alex.bennee@linaro.org \
--cc=dmitry.osipenko@collabora.com \
--cc=mst@redhat.com \
--cc=odaki@rsg.ci.i.u-tokyo.ac.jp \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.