From nobody Fri Nov 14 22:21:20 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=jablonski.xyz ARC-Seal: i=1; a=rsa-sha256; t=1759290572; cv=none; d=zohomail.com; s=zohoarc; b=RavvhIYTLvztdZhigNOYiWDRsuMOtZ5t7VsA1G01MEV+6wq9GNRe9unRdop9pdkqrjOV7WIx9aELXZVAv0lXCftYsWOtzwdPKddX37c3x0nU2eQ33PyhylDXEyjkuexlHv8vhZhGIeY0SeEehHK22Fj7TkeypDNc1K6pL1cpfOo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1759290572; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=77T6ZHXAsXlxg15T+Zt5PA5HBrq95r94h9NliztyOxo=; b=QxWJUTWNsZ48CDKAlCM1arSeZ3AbTfLQEW+URybpWWHTiJ9o7lZkXEJLfRvs5daDil4U8F1fSfMpDCQBDZHbi+zDvcqATbFpCkhNUkT1gmlJqFl4n1nPREMCyU2N+2LBMw9QUOluskG1LJMzVhPtbXhIOf32o1/NBAovktMtFw4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1759290572489124.97366966910556; Tue, 30 Sep 2025 20:49:32 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1v3noQ-0002GZ-4J; Tue, 30 Sep 2025 23:47:30 -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 1v3noO-0002GA-7p for qemu-devel@nongnu.org; Tue, 30 Sep 2025 23:47:28 -0400 Received: from fout-b4-smtp.messagingengine.com ([202.12.124.147]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1v3noC-0003Ks-EX for qemu-devel@nongnu.org; Tue, 30 Sep 2025 23:47:27 -0400 Received: from phl-compute-06.internal (phl-compute-06.internal [10.202.2.46]) by mailfout.stl.internal (Postfix) with ESMTP id 183841D000AE; Tue, 30 Sep 2025 23:47:07 -0400 (EDT) Received: from phl-mailfrontend-02 ([10.202.2.163]) by phl-compute-06.internal (MEProxy); Tue, 30 Sep 2025 23:47:07 -0400 Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 30 Sep 2025 23:47:06 -0400 (EDT) Received: from localhost (chomposaur [local]) by chomposaur (OpenSMTPD) with ESMTPA id 3e91d973; Wed, 1 Oct 2025 03:47:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=jablonski.xyz; h=cc:cc:content-transfer-encoding:content-type:date:date:from :from:in-reply-to:message-id:mime-version:reply-to:subject :subject:to:to; s=fm1; t=1759290426; x=1759376826; bh=77T6ZHXAsX lxg15T+Zt5PA5HBrq95r94h9NliztyOxo=; b=qHihEZB1t3O5finlBNjgMVfkY2 /JBbAoHFTg2Jnwdp2nRnanhwIRXQouxJ6khP45jLd4P/IeHcXX5XqFnYZBaSEE4g +B50fg1E1xmwhbU3RKjSPR3Hw09rGTa2h72gwnGNs82qZfSz2+1O/S80KEKlBKJF Rv0qtdtVRvsRtP9DW7DOCZZGIflvaxLeN17nbT9mN18PMBAPZVZkycHTmsuvB74e t0bH8ERbOXGBNCEYppu4qifrd621+HhVqQdH9QKDM8fG1uIUZIVgbwe9N3Z97jcs qbPWdhOBUS/cVUTz+hb+u0mFD74i3/ClblfAms0cvYLiqxz69RFZD+WOA5Ww== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:message-id:mime-version:reply-to:subject:subject:to :to:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm2; t= 1759290426; x=1759376826; bh=77T6ZHXAsXlxg15T+Zt5PA5HBrq95r94h9N liztyOxo=; b=GUDENe3admx8JJgOmmhGu6e3pMrbkDViAURvDKVeDIqYpEvloUn exs6VDjsDS4DsJG4Yrv7SmOKnoPW/6zAHAe1gu6M3LbBHUG8KXwO6P9Nq/wJB/VR urVUgKN1emKOadhNVJ9DttPAFQoMRbVL+AEyUIs3t5n9BqxzjluPSyejKdLp9QEi k+mH0+/IGTO8L21DaPaqP29wL4I8CMIGbS/hqkSD0UOLoXqULjQ6D89GOzXXvpvd s9Kx0BT7a5ZeyZA1Jp5Akn7i+HZT+T3XgGDvJzUBvx3S4qPplQ2ets+jeu4UBGIV C8dNHSLiUEcBjN6n2OLwb6O6UhnFwWDxjHQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeffedrtdeggdekvddtlecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpuffrtefokffrpgfnqfghnecuuegr ihhlohhuthemuceftddtnecufghrlhcuvffnffculdejtddmnecujfgurhephffvvefuff fkofgggfestdekredtredttdenucfhrhhomhepvehhrgguucflrggslhhonhhskhhiuceo tghhrggusehjrggslhhonhhskhhirdighiiiqeenucggtffrrghtthgvrhhnpefhteeugf eujeelteeggfeigeevjeelgeegudfguedvheeghfffudffledukeeiveenucevlhhushht vghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpegthhgrugesjhgrsghloh hnshhkihdrgiihiidpnhgspghrtghpthhtohepvddpmhhouggvpehsmhhtphhouhhtpdhr tghpthhtoheptghhrggusehjrggslhhonhhskhhirdighiiipdhrtghpthhtohepqhgvmh huqdguvghvvghlsehnohhnghhnuhdrohhrgh X-ME-Proxy: Feedback-ID: ib26944c1:Fastmail From: Chad Jablonski To: qemu-devel@nongnu.org Cc: Chad Jablonski Subject: [PATCH] ati-vga: Fix framebuffer mapping by using hardware-correct aperture sizes Date: Tue, 30 Sep 2025 23:46:16 -0400 Message-ID: <20251001034616.3017119-1-chad@jablonski.xyz> X-Mailer: git-send-email 2.51.0 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=202.12.124.147; envelope-from=chad@jablonski.xyz; helo=fout-b4-smtp.messagingengine.com X-Spam_score_int: 7 X-Spam_score: 0.7 X-Spam_bar: / X-Spam_report: (0.7 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FROM_SUSPICIOUS_NTLD=0.5, FROM_SUSPICIOUS_NTLD_FP=1.036, PDS_OTHER_BAD_TLD=1.999, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, UNPARSEABLE_RELAY=0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: 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-ZohoMail-DKIM: pass (identity @jablonski.xyz) X-ZM-MESSAGEID: 1759290574875116600 Content-Type: text/plain; charset="utf-8" Real Rage 128 cards always request 64MB for their linear (framebuffer) aperture. This is regardless of the amount of physical VRAM on the board. This is required for 64MB alignment which is important given the 26-bit addressing in src and dst registers. This discrepancy caused X to segfault or display garbage depending on the version tested. X expects this 64MB alignment. This was confirmed by testing against the behavior of real 16MB and 32MB Rage 128 cards. Real Radeon R100 cards request 128MB for linear aperture. This was tested against a Radeon 7200 with 64MB of VRAM. Signed-off-by: Chad Jablonski --- hw/display/ati.c | 26 ++++++++++++++++++++++++-- hw/display/ati_int.h | 1 + 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/hw/display/ati.c b/hw/display/ati.c index f7c0006a87..db189e0767 100644 --- a/hw/display/ati.c +++ b/hw/display/ati.c @@ -30,9 +30,13 @@ #include "ui/console.h" #include "hw/display/i2c-ddc.h" #include "trace.h" +#include "qemu/units.h" =20 #define ATI_DEBUG_HW_CURSOR 0 =20 +#define ATI_RAGE128_LINEAR_APERTURE_SIZE (64 * MiB) +#define ATI_RADEON_LINEAR_APERTURE_SIZE (128 * MiB) + #ifdef CONFIG_PIXMAN #define DEFAULT_X_PIXMAN 3 #else @@ -361,7 +365,7 @@ static uint64_t ati_mm_read(void *opaque, hwaddr addr, = unsigned int size) PCI_BASE_ADDRESS_0, size) & 0xffffff= f0; break; case CONFIG_APER_SIZE: - val =3D s->vga.vram_size / 2; + val =3D memory_region_size(&s->linear_aper); break; case CONFIG_REG_1_BASE: val =3D pci_default_read_config(&s->dev, @@ -1011,7 +1015,25 @@ static void ati_vga_realize(PCIDevice *dev, Error **= errp) /* io space is alias to beginning of mmregs */ memory_region_init_alias(&s->io, OBJECT(s), "ati.io", &s->mm, 0, 0x100= ); =20 - pci_register_bar(dev, 0, PCI_BASE_ADDRESS_MEM_PREFETCH, &vga->vram); + uint64_t aperture_size; + if (s->dev_id =3D=3D PCI_DEVICE_ID_ATI_RADEON_QY) { + aperture_size =3D ATI_RADEON_LINEAR_APERTURE_SIZE; + } else { + aperture_size =3D ATI_RAGE128_LINEAR_APERTURE_SIZE; + } + memory_region_init(&s->linear_aper, OBJECT(dev), "ati-linear-aperture0= ", + aperture_size); + + /* + * Rage 128: Framebuffer inhabits the bottom 32MB of the linear apertu= re. + * The top 32MB is reserved for AGP (not implemented). + * + * Radeon: The entire linear aperture is used for VRAM. + * AGP is mapped separately. + */ + memory_region_add_subregion(&s->linear_aper, 0, &vga->vram); + + pci_register_bar(dev, 0, PCI_BASE_ADDRESS_MEM_PREFETCH, &s->linear_ape= r); pci_register_bar(dev, 1, PCI_BASE_ADDRESS_SPACE_IO, &s->io); pci_register_bar(dev, 2, PCI_BASE_ADDRESS_SPACE_MEMORY, &s->mm); =20 diff --git a/hw/display/ati_int.h b/hw/display/ati_int.h index f5a47b82b0..ff2a69a0a5 100644 --- a/hw/display/ati_int.h +++ b/hw/display/ati_int.h @@ -97,6 +97,7 @@ struct ATIVGAState { QEMUCursor *cursor; QEMUTimer vblank_timer; bitbang_i2c_interface bbi2c; + MemoryRegion linear_aper; MemoryRegion io; MemoryRegion mm; ATIVGARegs regs; --=20 2.51.0