From nobody Wed Nov 12 03:41:37 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=1568290888; cv=none; d=zoho.com; s=zohoarc; b=Wmk0+UabZfsknjE0Q3p8TnlpWJV/ALgvEBh1MK7QU4nMT8NyXgHLQxqAYTyY0xHmbirJ35zFqnURBI14/A/tczQKBeeg/QPpbsWMFvpR4L7LQl35YRMdAIXo6GsqvYMzMekF1+obdoN5oNQNkY7YvmcKWe/QOKN8Jy95QXvvKU4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1568290888; 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=Zg7NcpigTgWs/MUDxDTmgwNdEob79VXmQCOz9dy1aNY=; b=A3JvwcnFreXM3mTGCqIJ9377qDsTPN01zciMwuaViDW0L249Ebvij8k4WVtwg8iyAvK8dMHgBufrQ2Myt39y5arHfqC0WulcN3fKMZQ/XtkxWpYZpbV569SdXUy46uynjk+YtHm4NOHfPss11rmQ5n1CVocN6YtZ1XTf7X8vbFg= 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 1568290888462479.25838489851776; Thu, 12 Sep 2019 05:21:28 -0700 (PDT) Received: from localhost ([::1]:33838 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i8O6I-0005fy-TP for importer@patchew.org; Thu, 12 Sep 2019 08:21:26 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50499) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i8O3l-0002xT-9P for qemu-devel@nongnu.org; Thu, 12 Sep 2019 08:18:50 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i8O3k-0005il-0y for qemu-devel@nongnu.org; Thu, 12 Sep 2019 08:18:49 -0400 Received: from mx1.redhat.com ([209.132.183.28]:50880) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1i8O3j-0005iI-Ot for qemu-devel@nongnu.org; Thu, 12 Sep 2019 08:18:47 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 050773090FD2; Thu, 12 Sep 2019 12:18:47 +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 ACC9C60920; Thu, 12 Sep 2019 12:18:36 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id E1BA217534; Thu, 12 Sep 2019 14:18:35 +0200 (CEST) From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Thu, 12 Sep 2019 14:18:34 +0200 Message-Id: <20190912121835.18362-2-kraxel@redhat.com> In-Reply-To: <20190912121835.18362-1-kraxel@redhat.com> References: <20190912121835.18362-1-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.43]); Thu, 12 Sep 2019 12:18:47 +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 1/2] vga: move access helpers to separate include file 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" Signed-off-by: Gerd Hoffmann --- hw/display/vga-access.h | 49 ++++++++++++++++++++++++++++++++++++++++ hw/display/vga-helpers.h | 26 --------------------- hw/display/vga.c | 1 + 3 files changed, 50 insertions(+), 26 deletions(-) create mode 100644 hw/display/vga-access.h diff --git a/hw/display/vga-access.h b/hw/display/vga-access.h new file mode 100644 index 000000000000..c0fbd9958b2e --- /dev/null +++ b/hw/display/vga-access.h @@ -0,0 +1,49 @@ +/* + * QEMU VGA Emulator templates + * + * Copyright (c) 2003 Fabrice Bellard + * + * Permission is hereby granted, free of charge, to any person obtaining a= copy + * of this software and associated documentation files (the "Software"), t= o deal + * in the Software without restriction, including without limitation the r= ights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or se= ll + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included= in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS= OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OT= HER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING= FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS = IN + * THE SOFTWARE. + */ + +static inline uint8_t vga_read_byte(VGACommonState *vga, uint32_t addr) +{ + return vga->vram_ptr[addr & vga->vbe_size_mask]; +} + +static inline uint16_t vga_read_word_le(VGACommonState *vga, uint32_t addr) +{ + uint32_t offset =3D addr & vga->vbe_size_mask & ~1; + uint16_t *ptr =3D (uint16_t *)(vga->vram_ptr + offset); + return lduw_le_p(ptr); +} + +static inline uint16_t vga_read_word_be(VGACommonState *vga, uint32_t addr) +{ + uint32_t offset =3D addr & vga->vbe_size_mask & ~1; + uint16_t *ptr =3D (uint16_t *)(vga->vram_ptr + offset); + return lduw_be_p(ptr); +} + +static inline uint32_t vga_read_dword_le(VGACommonState *vga, uint32_t add= r) +{ + uint32_t offset =3D addr & vga->vbe_size_mask & ~3; + uint32_t *ptr =3D (uint32_t *)(vga->vram_ptr + offset); + return ldl_le_p(ptr); +} diff --git a/hw/display/vga-helpers.h b/hw/display/vga-helpers.h index 5a752b3f9efd..10e9cfd40a04 100644 --- a/hw/display/vga-helpers.h +++ b/hw/display/vga-helpers.h @@ -95,32 +95,6 @@ static void vga_draw_glyph9(uint8_t *d, int linesize, } while (--h); } =20 -static inline uint8_t vga_read_byte(VGACommonState *vga, uint32_t addr) -{ - return vga->vram_ptr[addr & vga->vbe_size_mask]; -} - -static inline uint16_t vga_read_word_le(VGACommonState *vga, uint32_t addr) -{ - uint32_t offset =3D addr & vga->vbe_size_mask & ~1; - uint16_t *ptr =3D (uint16_t *)(vga->vram_ptr + offset); - return lduw_le_p(ptr); -} - -static inline uint16_t vga_read_word_be(VGACommonState *vga, uint32_t addr) -{ - uint32_t offset =3D addr & vga->vbe_size_mask & ~1; - uint16_t *ptr =3D (uint16_t *)(vga->vram_ptr + offset); - return lduw_be_p(ptr); -} - -static inline uint32_t vga_read_dword_le(VGACommonState *vga, uint32_t add= r) -{ - uint32_t offset =3D addr & vga->vbe_size_mask & ~3; - uint32_t *ptr =3D (uint32_t *)(vga->vram_ptr + offset); - return ldl_le_p(ptr); -} - /* * 4 color mode */ diff --git a/hw/display/vga.c b/hw/display/vga.c index 573d223d46f0..82ebe5361096 100644 --- a/hw/display/vga.c +++ b/hw/display/vga.c @@ -1009,6 +1009,7 @@ void vga_mem_writeb(VGACommonState *s, hwaddr addr, u= int32_t val) typedef void vga_draw_line_func(VGACommonState *s1, uint8_t *d, uint32_t srcaddr, int width); =20 +#include "vga-access.h" #include "vga-helpers.h" =20 /* return true if the palette was modified */ --=20 2.18.1 From nobody Wed Nov 12 03:41:37 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=1568291000; cv=none; d=zoho.com; s=zohoarc; b=PgDIOoLW+MYUrN6NJLZAQ0ITr1plL45W9RcGyW2595u4ONmiX1QYbLBLtYNUiX/TERBS0PbxNpW/BSpqVpIr2hVSGOIlZVP6bngqF/A8NB6ubA8/1rgajJ0dT6+VGhWp4HCnbOGhL28P1obR89PHl3oDae4POVahUT8+ys5v3Oc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1568291000; 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=hRCVZ4RqklPv6Zo2imagFiZLMDIDY9l+rdlFVazTTGs=; b=DopaVRLHCBOtKMWUhBX3QIO7Owz2Uqv89HaT4ORsAnQ2gzZn3Clod1qfwCbWruVlmBlHP/kSF1K2Ym+57wzmKaaxNm2Qx9rCA87DovRfG0LkMZcaV5dk8t+IdvhqcuCEvJbzbLNtbhef5BZqynfN8fE8N6urM6dC+D0KLPAW+5g= 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 1568291000597198.27964885573647; Thu, 12 Sep 2019 05:23:20 -0700 (PDT) Received: from localhost ([::1]:33874 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i8O87-0008Jp-6J for importer@patchew.org; Thu, 12 Sep 2019 08:23:19 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50464) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i8O3g-0002qw-RZ for qemu-devel@nongnu.org; Thu, 12 Sep 2019 08:18:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i8O3e-0005fx-T7 for qemu-devel@nongnu.org; Thu, 12 Sep 2019 08:18:43 -0400 Received: from mx1.redhat.com ([209.132.183.28]:41232) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1i8O3e-0005fe-OQ for qemu-devel@nongnu.org; Thu, 12 Sep 2019 08:18:42 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 16A6C301D678; Thu, 12 Sep 2019 12:18:42 +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 BEC1C5D713; Thu, 12 Sep 2019 12:18:36 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id EADD3268; Thu, 12 Sep 2019 14:18:35 +0200 (CEST) From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Thu, 12 Sep 2019 14:18:35 +0200 Message-Id: <20190912121835.18362-3-kraxel@redhat.com> In-Reply-To: <20190912121835.18362-1-kraxel@redhat.com> References: <20190912121835.18362-1-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.47]); Thu, 12 Sep 2019 12:18:42 +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 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. Reported-by: xu hang Signed-off-by: Gerd Hoffmann --- hw/display/ati.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/hw/display/ati.c b/hw/display/ati.c index 8f940eee221a..6d77c40b8287 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) { --=20 2.18.1