From nobody Wed Nov 12 05:23:20 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.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; Authentication-Results: mx.zohomail.com; spf=pass (zoho.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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1568366834; cv=none; d=zoho.com; s=zohoarc; b=DCz0l2JteIavV8DFXXMAajZLpqT1Y0BiRqrazOtoW8TmLUz0wsKIAiyGB8/a+LoYSPHiQUFQ/B+sWVHQi4dJlaK+K93dv5/EMLbUUjlN/jSN29GQXwY1s0Wl9aFSbxR0/P3Li22Lf2wh6jZCC+4XfYmlVcHAygMADxlEoWFRsAM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1568366834; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=ZLm4yvWBmwNbFfnfHqM6Mio2XvUZ+L8VOPtxAVqbvS4=; b=HMYXgb54v7uBJwLSTVdlvhKlThisSqw2jIQ25RgfU+FYBkGbeWRh5bSh4m+782tGxJr73ZDNjICecnuk5iaq0zqLr2LMOJCPxa4VVae5BXbuI60cKP3Oa/CglBmxrggNodi1i/dDu0WhqrynZSFkdIJc/vosbhfNv1OL2iEo94w= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.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 header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1568366834050314.00986790124784; Fri, 13 Sep 2019 02:27:14 -0700 (PDT) Received: from localhost ([::1]:41708 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i8hr9-0005Sp-AF for importer@patchew.org; Fri, 13 Sep 2019 05:27:07 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54122) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i8hpq-0004F3-5t for qemu-devel@nongnu.org; Fri, 13 Sep 2019 05:25:47 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i8hpp-0007S1-1K for qemu-devel@nongnu.org; Fri, 13 Sep 2019 05:25:46 -0400 Received: from mx1.redhat.com ([209.132.183.28]:46410) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1i8hpo-0007RG-Sp for qemu-devel@nongnu.org; Fri, 13 Sep 2019 05:25:44 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 3C3F37BDA1; Fri, 13 Sep 2019 09:25:44 +0000 (UTC) Received: from sirius.home.kraxel.org (ovpn-116-47.ams2.redhat.com [10.36.116.47]) by smtp.corp.redhat.com (Postfix) with ESMTP id A5D8D5D9C3; Fri, 13 Sep 2019 09:25:38 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 9D2A893C5; Fri, 13 Sep 2019 11:25:37 +0200 (CEST) From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Fri, 13 Sep 2019 11:25:37 +0200 Message-Id: <20190913092537.2913-3-kraxel@redhat.com> In-Reply-To: <20190913092537.2913-1-kraxel@redhat.com> References: <20190913092537.2913-1-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Fri, 13 Sep 2019 09:25:44 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v2 2/2] ati: use vga_read_byte in ati_cursor_define X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "Michael S. Tsirkin" , Gerd Hoffmann , flier_m@outlook.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" This makes sure reads are confined to vga video memory. v2: fix ati_cursor_draw_line too. Reported-by: xu hang Signed-off-by: Gerd Hoffmann --- hw/display/ati.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/hw/display/ati.c b/hw/display/ati.c index 8f940eee221a..f6ae27c0c710 100644 --- a/hw/display/ati.c +++ b/hw/display/ati.c @@ -19,6 +19,7 @@ #include "qemu/osdep.h" #include "ati_int.h" #include "ati_regs.h" +#include "vga-access.h" #include "hw/qdev-properties.h" #include "vga_regs.h" #include "qemu/log.h" @@ -135,19 +136,19 @@ static void ati_vga_switch_mode(ATIVGAState *s) static void ati_cursor_define(ATIVGAState *s) { uint8_t data[1024]; - uint8_t *src; + unsigned 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 */ - src =3D s->vga.vram_ptr + s->regs.cur_offset - - (s->regs.cur_hv_offs >> 16) - (s->regs.cur_hv_offs & 0xffff) * 1= 6; + 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 src[i * 16 + j]; - data[512 + idx] =3D src[i * 16 + j + 8]; + 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); } } if (!s->cursor) { @@ -189,7 +190,7 @@ 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); - uint8_t *src; + uint32_t srcoff; uint32_t *dp =3D (uint32_t *)d; int i, j, h; =20 @@ -199,13 +200,13 @@ static void ati_cursor_draw_line(VGACommonState *vga,= uint8_t *d, int scr_y) return; } /* FIXME handle cur_hv_offs correctly */ - src =3D s->vga.vram_ptr + s->cursor_offset + (scr_y - vga->hw_cursor_y= ) * 16; + 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 src[i]; - uint8_t xbits =3D src[i + 8]; + uint8_t abits =3D vga_read_byte(vga, srcoff + i); + uint8_t xbits =3D vga_read_byte(vga, srcoff + i); for (j =3D 0; j < 8; j++, abits <<=3D 1, xbits <<=3D 1) { if (abits & BIT(7)) { if (xbits & BIT(7)) { --=20 2.18.1