From nobody Sun Mar 22 15:31:48 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=eik.bme.hu Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1774055116489206.236724087271; Fri, 20 Mar 2026 18:05:16 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1w3klY-0008RI-Vd; Fri, 20 Mar 2026 21:04:36 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1w3klX-0008QT-0u for qemu-devel@nongnu.org; Fri, 20 Mar 2026 21:04:35 -0400 Received: from zero.eik.bme.hu ([2001:738:2001:2001::2001]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1w3klU-0003zM-Ez for qemu-devel@nongnu.org; Fri, 20 Mar 2026 21:04:34 -0400 Received: from localhost (localhost [127.0.0.1]) by zero.eik.bme.hu (Postfix) with ESMTP id 36881596E02; Sat, 21 Mar 2026 02:04:30 +0100 (CET) Received: from zero.eik.bme.hu ([127.0.0.1]) by localhost (zero.eik.bme.hu [127.0.0.1]) (amavis, port 10028) with ESMTP id 04Wgy9woiyOc; Sat, 21 Mar 2026 02:04:28 +0100 (CET) Received: by zero.eik.bme.hu (Postfix, from userid 432) id 8F368596E06; Sat, 21 Mar 2026 02:04:25 +0100 (CET) X-Virus-Scanned: amavis at eik.bme.hu Message-ID: <306212035766ca9459c6c8e890135d361bb5d491.1774054635.git.balaton@eik.bme.hu> In-Reply-To: References: From: BALATON Zoltan Subject: [PATCH v5 7/8] ati-vga: Fix mouse pointer on big endian frame buffer MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable To: qemu-devel@nongnu.org Cc: Gerd Hoffmann , marcandre.lureau@redhat.com, Chad Jablonski , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Date: Sat, 21 Mar 2026 02:04:25 +0100 (CET) Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2001:738:2001:2001::2001; envelope-from=balaton@eik.bme.hu; helo=zero.eik.bme.hu X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_HELO_NONE=0.001, 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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZM-MESSAGEID: 1774055122895154101 Content-Type: text/plain; charset="utf-8" Rewrite reading of mouse pointer image to fix broken mouse cursor with big endian frame buffer. I am not sure this is entirely correct but appears to work at least on little endian host with PPC guests using little or big endian frame buffer. Signed-off-by: BALATON Zoltan --- hw/display/ati.c | 63 +++++++++++++++++++++++++++--------------------- 1 file changed, 35 insertions(+), 28 deletions(-) diff --git a/hw/display/ati.c b/hw/display/ati.c index fba73a9956..c278d11d34 100644 --- a/hw/display/ati.c +++ b/hw/display/ati.c @@ -142,27 +142,29 @@ static void ati_vga_switch_mode(ATIVGAState *s) /* Used by host side hardware cursor */ static void ati_cursor_define(ATIVGAState *s) { - uint8_t data[1024]; + uint64_t data[128]; uint32_t srcoff; - int i, j, idx =3D 0; =20 if ((s->regs.cur_offset & BIT(31)) || s->cursor_guest_mode) { return; /* Do not update cursor if locked or rendered by guest */ } /* FIXME handle cur_hv_offs correctly */ - srcoff =3D s->regs.cur_offset - - (s->regs.cur_hv_offs >> 16) - (s->regs.cur_hv_offs & 0xffff) * 16; - for (i =3D 0; i < 64; i++) { - for (j =3D 0; j < 8; j++, idx++) { - data[idx] =3D vga_read_byte(&s->vga, srcoff + i * 16 + j); - data[512 + idx] =3D vga_read_byte(&s->vga, srcoff + i * 16 + j= + 8); + srcoff =3D s->regs.cur_offset - (s->regs.cur_hv_offs >> 16) - + (s->regs.cur_hv_offs & 0xffff) * 16; + for (int i =3D 0; i < 64; i++, srcoff +=3D 16) { + if (s->vga.big_endian_fb) { + data[i] =3D wswap64(ldq_be_p(&s->vga.vram_ptr[srcoff])); + data[i + 64] =3D wswap64(ldq_be_p(&s->vga.vram_ptr[srcoff + 8]= )); + } else { + data[i] =3D ldq_le_p(&s->vga.vram_ptr[srcoff]); + data[i + 64] =3D ldq_le_p(&s->vga.vram_ptr[srcoff + 8]); } } if (!s->cursor) { s->cursor =3D cursor_alloc(64, 64); } cursor_set_mono(s->cursor, s->regs.cur_color1, s->regs.cur_color0, - &data[512], 1, &data[0]); + (uint8_t *)&data[64], 1, (uint8_t *)&data[0]); dpy_cursor_define(s->vga.con, s->cursor); } =20 @@ -197,9 +199,9 @@ static void ati_cursor_invalidate(VGACommonState *vga) static void ati_cursor_draw_line(VGACommonState *vga, uint8_t *d, int scr_= y) { ATIVGAState *s =3D container_of(vga, ATIVGAState, vga); - uint32_t srcoff; + uint32_t h, srcoff, color; + uint64_t abits, xbits, mask; uint32_t *dp =3D (uint32_t *)d; - int i, j, h, idx =3D 0; =20 if (!(s->regs.crtc_gen_cntl & CRTC2_CUR_EN) || scr_y < vga->hw_cursor_y || scr_y >=3D vga->hw_cursor_y + 64 || @@ -210,26 +212,31 @@ static void ati_cursor_draw_line(VGACommonState *vga,= uint8_t *d, int scr_y) srcoff =3D s->cursor_offset + (scr_y - vga->hw_cursor_y) * 16; dp =3D &dp[vga->hw_cursor_x]; h =3D ((s->regs.crtc_h_total_disp >> 16) + 1) * 8; - for (i =3D 0; i < 8; i++) { - uint32_t color; - uint8_t abits =3D vga_read_byte(vga, srcoff + i); - uint8_t xbits =3D vga_read_byte(vga, srcoff + i + 8); - for (j =3D 0; j < 8; j++, abits <<=3D 1, xbits <<=3D 1, idx++) { - if (vga->hw_cursor_x + idx >=3D h) { - return; /* end of screen, don't span to next line */ - } - if (abits & BIT(7)) { - if (xbits & BIT(7)) { - color =3D dp[idx] ^ 0xffffffff; /* complement */ - } else { - continue; /* transparent, no change */ - } + abits =3D ldq_le_p(&vga->vram_ptr[srcoff]); + xbits =3D ldq_le_p(&vga->vram_ptr[srcoff + 8]); + if (vga->big_endian_fb) { + abits =3D wswap64(abits); + xbits =3D wswap64(xbits); + } else { + bswap64s(&abits); + bswap64s(&xbits); + } + mask =3D BIT(63); + for (int i =3D 0; i < 64; i++, mask >>=3D 1) { + if (vga->hw_cursor_x + i >=3D h) { + return; /* end of screen, don't span to next line */ + } + if (abits & mask) { + if (xbits & mask) { + color =3D dp[i] ^ 0xffffffff; /* complement */ } else { - color =3D (xbits & BIT(7) ? s->regs.cur_color1 : - s->regs.cur_color0) | 0xff000000; + continue; /* transparent, no change */ } - dp[idx] =3D color; + } else { + color =3D (xbits & mask ? s->regs.cur_color1 : + s->regs.cur_color0) | 0xff000000; } + dp[i] =3D color; } } =20 --=20 2.41.3