{"id":2228771,"url":"http://patchwork.ozlabs.org/api/1.1/patches/2228771/?format=json","web_url":"http://patchwork.ozlabs.org/project/qemu-devel/patch/20260427105531.75701-1-benno.fuenfstueck@neodyme.io/","project":{"id":14,"url":"http://patchwork.ozlabs.org/api/1.1/projects/14/?format=json","name":"QEMU Development","link_name":"qemu-devel","list_id":"qemu-devel.nongnu.org","list_email":"qemu-devel@nongnu.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20260427105531.75701-1-benno.fuenfstueck@neodyme.io>","date":"2026-04-27T10:54:00","name":"[v2] virtio-gpu: fix inverted mouse cursor","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"8b444f4aede60cada36c3885e4e94d61ebcc2f13","submitter":{"id":93105,"url":"http://patchwork.ozlabs.org/api/1.1/people/93105/?format=json","name":"Benno Fünfstück","email":"benno.fuenfstueck@neodyme.io"},"delegate":null,"mbox":"http://patchwork.ozlabs.org/project/qemu-devel/patch/20260427105531.75701-1-benno.fuenfstueck@neodyme.io/mbox/","series":[{"id":501621,"url":"http://patchwork.ozlabs.org/api/1.1/series/501621/?format=json","web_url":"http://patchwork.ozlabs.org/project/qemu-devel/list/?series=501621","date":"2026-04-27T10:54:00","name":"[v2] virtio-gpu: fix inverted mouse cursor","version":2,"mbox":"http://patchwork.ozlabs.org/series/501621/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/2228771/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/2228771/checks/","tags":{},"headers":{"Return-Path":"<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>","X-Original-To":"incoming@patchwork.ozlabs.org","Delivered-To":"patchwork-incoming@legolas.ozlabs.org","Authentication-Results":["legolas.ozlabs.org;\n\tdkim=pass (2048-bit key;\n unprotected) header.d=neodyme.io header.i=@neodyme.io header.a=rsa-sha256\n header.s=google header.b=cSJAwQqs;\n\tdkim-atps=neutral","legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org\n (client-ip=209.51.188.17; helo=lists1p.gnu.org;\n envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org;\n receiver=patchwork.ozlabs.org)"],"Received":["from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17])\n\t(using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits))\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4g40rN55Zmz1yJs\n\tfor <incoming@patchwork.ozlabs.org>; Mon, 27 Apr 2026 20:57:07 +1000 (AEST)","from localhost ([::1] helo=lists1p.gnu.org)\n\tby lists1p.gnu.org with esmtp (Exim 4.90_1)\n\t(envelope-from <qemu-devel-bounces@nongnu.org>)\n\tid 1wHJdk-00012O-Nd; Mon, 27 Apr 2026 06:56:36 -0400","from eggs.gnu.org ([2001:470:142:3::10])\n by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)\n (Exim 4.90_1) (envelope-from <benno.fuenfstueck@neodyme.io>)\n id 1wHJdc-00010L-DJ\n for qemu-devel@nongnu.org; Mon, 27 Apr 2026 06:56:28 -0400","from mail-wm1-x32c.google.com ([2a00:1450:4864:20::32c])\n by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128)\n (Exim 4.90_1) (envelope-from <benno.fuenfstueck@neodyme.io>)\n id 1wHJdZ-00068i-Ez\n for qemu-devel@nongnu.org; Mon, 27 Apr 2026 06:56:28 -0400","by mail-wm1-x32c.google.com with SMTP id\n 5b1f17b1804b1-488ad135063so92257625e9.0\n for <qemu-devel@nongnu.org>; Mon, 27 Apr 2026 03:56:22 -0700 (PDT)","from i-cube.net ([2003:a:1211:8e00:481b:c50e:1a28:4b5a])\n by smtp.gmail.com with ESMTPSA id\n 5b1f17b1804b1-4891978ef6bsm263372245e9.4.2026.04.27.03.56.19\n (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n Mon, 27 Apr 2026 03:56:20 -0700 (PDT)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=neodyme.io; s=google; t=1777287381; x=1777892181; darn=nongnu.org;\n h=content-transfer-encoding:mime-version:message-id:date:subject:cc\n :to:from:from:to:cc:subject:date:message-id:reply-to;\n bh=BZRs1OCHPcx9hN6j0fIIM5Fbvz2EoRUmdAfqwfTt8RI=;\n b=cSJAwQqsX2XZZw9JEWYZCSVDA4fDzSXoKT/pGNyQAdpBTxezwp6aZLzCPkaAKQV2aV\n 5siQ0DtfibqkluuiAL78YAeBZ8IkMz6tehj9ntaaZqxt3F8eXefPTDDhZlHs5OgnYR4A\n A9XEEOuansky1wmvxqIFiT11EmokrxT5u6U3zIQnfWtjxQ1ZlI5w/7bRzigk94x+bZ18\n S5a0BTO8NlwtLsq9a+1yrJF413LHrFroqbEB2L1OdOhIJaUk8j1RbVsz1B0Z2uge0GR1\n YNoZbW9Z+fq9Sj7S2La/JyPqgVtovWviOgkq+rDbFODIaFpSqYPWRt9GUq4lB1KRXkQP\n ol8Q==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=1e100.net; s=20251104; t=1777287381; x=1777892181;\n h=content-transfer-encoding:mime-version:message-id:date:subject:cc\n :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date\n :message-id:reply-to;\n bh=BZRs1OCHPcx9hN6j0fIIM5Fbvz2EoRUmdAfqwfTt8RI=;\n b=H+idlUK8mmxToXrxgHA29CYLVW2rRtkwf8uHjrJ4Ux/7gI97/JNXgsZkubtpoa47D5\n 04DPCjmn/+Vak9FHJfFG64yWiNnNgqG8mNOwX9YGy/PecHGK+JZ3D3+AmDlK08U76Df3\n HICpMJYshSs47e5To9+6RzbHtG6VOVdDJHLi9CqzDEdzpOPceBB0SHSDdgATqiRhIBhP\n WkhVtvxU3c5debrI7MuiVLHifGrXwIts4UJ6EOJz2mEaRH+XvawYTtXOdWA4K9P2f0D8\n RD7duWssHwyCeG694f4gHA8P7x9w4EydazPlyLt4iXtfs6ouTo5J/Szhd9k2GlZiNCFb\n TGjg==","X-Gm-Message-State":"AOJu0YyrF21PfZqzOcqzumO84HkiLO8mLRoMh8E1DJCoi6yXXllFzZ2w\n cvnuAZ5wsczFk+RrmMTAyCN+ycYXh31aBCHfv526zRAus+kdb+/kn6SsCEqm9VtfaBynVOXj4Au\n ZTdr6+Ui6wwWC8+gsG0h/ff5EQ6nUPOqYlGlVNSUt7U0g7WK+4SfNGY5KKacUP4Y1mlzMLrlcLi\n g=","X-Gm-Gg":"AeBDieuKtTq94H3SGPy9iJt6MGWTpzM9i9GI/cJx0B3YVSj8SnB0xyp2sTXrB+npEhA\n iqV7SUtcEXmQ/z2Z+vQyxleyk/5WH8NpQ1JvqMaNl6WyTSaCpeZGdzxNMrV7yFmXPCAahQKl6ID\n Xd/GNwMtqavnJAQjFtldp8HbjWuJb9a70UreGDx150wIkaORFm7f+Hc87tNDWvnSpdG2GH3Kwc8\n PnjnsDIWLf3R3penKT6tJvfJBEmFEnycVc50g4vwNtbAEwdlI2eW5qZ4ZlEmL3iug1P5q38sj7N\n aZR/K14Mne2g8XGBUFEefh+h5Swx8cQVhEmQ68AV7BslWnY++vfWVL8pxbcE6nbZtRfaebdJPVZ\n RM+i2zwhmhokKMmySkYGevOzrc2mfZvpzNfAGpqCOg/jffLOaZbgYXZlT642bmWS0HIz3yAvcy6\n cGnPBm5ZrYBy2VbLLHaRTC25VHFLIuTTQdtIINuAyvXaSt8g4DF4DsJ1zc993JsdlJWQ==","X-Received":"by 2002:a05:600c:4714:b0:48a:5574:3a5d with SMTP id\n 5b1f17b1804b1-48a55743e96mr391725165e9.7.1777287380641;\n Mon, 27 Apr 2026 03:56:20 -0700 (PDT)","From":"=?utf-8?q?Benno_F=C3=BCnst=C3=BCck?= <benno.fuenfstueck@neodyme.io>","To":"qemu-devel@nongnu.org","Cc":"\"Michael S. Tsirkin\" <mst@redhat.com>,\n =?utf-8?q?Alex_Benn=C3=A9e?= <alex.bennee@linaro.org>,\n Akihiko Odaki <odaki@rsg.ci.i.u-tokyo.ac.jp>,\n Dmitry Osipenko <dmitry.osipenko@collabora.com>, =?utf-8?b?QmVubm8gRsO8bmZz?=\n\t=?utf-8?b?dMO8Y2s=?= <benno.fuenfstueck@neodyme.io>","Subject":"[PATCH v2] virtio-gpu: fix inverted mouse cursor","Date":"Mon, 27 Apr 2026 12:54:00 +0200","Message-ID":"<20260427105531.75701-1-benno.fuenfstueck@neodyme.io>","X-Mailer":"git-send-email 2.51.2","MIME-Version":"1.0","Content-Type":"text/plain; charset=\"UTF-8\"","Content-Transfer-Encoding":"quoted-printable","Received-SPF":"pass client-ip=2a00:1450:4864:20::32c;\n envelope-from=benno.fuenfstueck@neodyme.io; helo=mail-wm1-x32c.google.com","X-Spam_score_int":"-20","X-Spam_score":"-2.1","X-Spam_bar":"--","X-Spam_report":"(-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1,\n DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1,\n RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001,\n SPF_PASS=-0.001 autolearn=ham autolearn_force=no","X-Spam_action":"no action","X-BeenThere":"qemu-devel@nongnu.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"qemu development <qemu-devel.nongnu.org>","List-Unsubscribe":"<https://lists.nongnu.org/mailman/options/qemu-devel>,\n <mailto:qemu-devel-request@nongnu.org?subject=unsubscribe>","List-Archive":"<https://lists.nongnu.org/archive/html/qemu-devel>","List-Post":"<mailto:qemu-devel@nongnu.org>","List-Help":"<mailto:qemu-devel-request@nongnu.org?subject=help>","List-Subscribe":"<https://lists.nongnu.org/mailman/listinfo/qemu-devel>,\n <mailto:qemu-devel-request@nongnu.org?subject=subscribe>","Errors-To":"qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org","Sender":"qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org"},"content":"From: Benno Fünfstück <benno.fuenfstueck@neodyme.io>\n\nThis is a fix for a bug in virglrenderer, where if the guest uses hardware mouse cursor acceleration then the mouse cursor can end up being a resource with the flag Y_0_TOP set.\nBut virglrenderer does not honor this flag when reading the cursor data.\nThis has been fixed in current virglrenderer master.\nFor older virglrenderer, we need to make sure to flip the cursor data such that display clients render it correctly.\n\nFor example, this fixes mouse cursor rendering for wlroots-based window managers (like Sway) in Linux guests.\n\nResolves: https://gitlab.com/qemu-project/qemu/-/work_items/2315\nSigned-off-by: Benno Fünfstück <benno.fuenfstueck@neodyme.io>\n---\nNow with a version check, since the fix for this is in virlglrenderer master so I think it is any version newer than the current one (which is 1.3.0).\nI copied the code from virtio-gpu-virgl.c for the version check for simplicty, if I should instead move that code for some DRY feel free to say so.\n\n hw/display/virtio-gpu-gl.c | 45 ++++++++++++++++++++++++++++++++++++++\n 1 file changed, 45 insertions(+)","diff":"diff --git a/hw/display/virtio-gpu-gl.c b/hw/display/virtio-gpu-gl.c\nindex 2b7a41c466..6505a84f5e 100644\n--- a/hw/display/virtio-gpu-gl.c\n+++ b/hw/display/virtio-gpu-gl.c\n@@ -26,6 +26,25 @@\n \n #include <virglrenderer.h>\n \n+/*\n+ * VIRGL_CHECK_VERSION available since libvirglrenderer 1.0.1 and was fixed\n+ * in 1.1.0. Undefine bugged version of the macro and provide our own.\n+ */\n+#if defined(VIRGL_CHECK_VERSION) && \\\n+    VIRGL_VERSION_MAJOR == 1 && VIRGL_VERSION_MINOR < 1\n+#undef VIRGL_CHECK_VERSION\n+#endif\n+\n+#ifndef VIRGL_CHECK_VERSION\n+#define VIRGL_CHECK_VERSION(major, minor, micro) \\\n+    (VIRGL_VERSION_MAJOR > (major) || \\\n+     VIRGL_VERSION_MAJOR == (major) && VIRGL_VERSION_MINOR > (minor) || \\\n+     VIRGL_VERSION_MAJOR == (major) && VIRGL_VERSION_MINOR == (minor) && \\\n+     VIRGL_VERSION_MICRO >= (micro))\n+#endif\n+\n+#define VIRGL_NEEDS_CURSOR_DATA_FLIP_FIX (!VIRGL_CHECK_VERSION(1, 3, 1))\n+\n static void virtio_gpu_gl_update_cursor_data(VirtIOGPU *g,\n                                              struct virtio_gpu_scanout *s,\n                                              uint32_t resource_id)\n@@ -33,6 +52,11 @@ static void virtio_gpu_gl_update_cursor_data(VirtIOGPU *g,\n     VirtIOGPUGL *gl = VIRTIO_GPU_GL(g);\n     uint32_t width, height;\n     uint32_t pixels, *data;\n+#if VIRGL_NEEDS_CURSOR_DATA_FLIP_FIX\n+    bool y_0_top = true;\n+    int ret;\n+    struct virgl_renderer_resource_info info;\n+#endif\n \n     if (gl->renderer_state != RS_INITED) {\n         return;\n@@ -49,8 +73,29 @@ static void virtio_gpu_gl_update_cursor_data(VirtIOGPU *g,\n         return;\n     }\n \n+#if VIRGL_NEEDS_CURSOR_DATA_FLIP_FIX\n+    memset(&info, 0, sizeof(info));\n+    ret = virgl_renderer_resource_get_info(resource_id, &info);\n+    if (ret == 0) {\n+        y_0_top = info.flags & VIRTIO_GPU_RESOURCE_FLAG_Y_0_TOP;\n+    }\n+#endif\n+\n     pixels = s->current_cursor->width * s->current_cursor->height;\n+#if VIRGL_NEEDS_CURSOR_DATA_FLIP_FIX\n+    if (y_0_top) {\n+        memcpy(s->current_cursor->data, data, pixels * sizeof(uint32_t));\n+    } else {\n+        uint32_t *dst = s->current_cursor->data;\n+        for (uint32_t y = 0; y < height; y++) {\n+            memcpy(dst + y * width,\n+                   data + (height - 1 - y) * width,\n+                   width * sizeof(uint32_t));\n+        }\n+    }\n+#else\n     memcpy(s->current_cursor->data, data, pixels * sizeof(uint32_t));\n+#endif\n     free(data);\n }\n \n","prefixes":["v2"]}