From nobody Sat May 18 12:12:36 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1647505948001971.1309724522872; Thu, 17 Mar 2022 01:32:28 -0700 (PDT) Received: from localhost ([::1]:35638 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nUlYY-0001Bm-Mf for importer@patchew.org; Thu, 17 Mar 2022 04:32:26 -0400 Received: from eggs.gnu.org ([209.51.188.92]:56162) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nUlWq-0007aI-8e for qemu-devel@nongnu.org; Thu, 17 Mar 2022 04:30:40 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:22572) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nUlWl-0006ir-R7 for qemu-devel@nongnu.org; Thu, 17 Mar 2022 04:30:38 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-274-jNYusWSbPl2vNhRNpEiDmQ-1; Thu, 17 Mar 2022 04:30:33 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id D74B6185A79C; Thu, 17 Mar 2022 08:30:32 +0000 (UTC) Received: from thuth.com (dhcp-192-232.str.redhat.com [10.33.192.232]) by smtp.corp.redhat.com (Postfix) with ESMTP id 39F572D479; Thu, 17 Mar 2022 08:30:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1647505835; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=W8C+C1EySswPOKYztIddcGcjgbnWKI5gpHFk577VjB0=; b=Ew2Tlh+EbpRAVjP+9qWhNkSjvyIno/po3X02NZeS97XH4IRtg21gnUhQ4tQYPddMMsmPW0 CnqCq1dg2Wy751qmAspvbeC9PRPdrOsTy05MlSys43E6p7x2gaeJ8xbwqJV0/ee77ca8kk XDMq5ptpEdWCcTp87/an9bRmJm3Kf44= X-MC-Unique: jNYusWSbPl2vNhRNpEiDmQ-1 From: Thomas Huth To: qemu-devel@nongnu.org Subject: [PATCH v2 1/3] hw/display/cirrus_vga: Clean up indentation in pci_cirrus_vga_realize() Date: Thu, 17 Mar 2022 09:30:24 +0100 Message-Id: <20220317083027.16688-2-thuth@redhat.com> In-Reply-To: <20220317083027.16688-1-thuth@redhat.com> References: <20220317083027.16688-1-thuth@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=thuth@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" 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=170.10.133.124; envelope-from=thuth@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Gerd Hoffmann , armbru@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1647505948992100002 Most of the code in this function had been indented with 5 spaces instead of 4. Since 4 is our preferred style, remove one space in the bad lines her= e. Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Thomas Huth --- hw/display/cirrus_vga.c | 57 +++++++++++++++++++++-------------------- 1 file changed, 29 insertions(+), 28 deletions(-) diff --git a/hw/display/cirrus_vga.c b/hw/display/cirrus_vga.c index fdca6ca659..7da1be3e12 100644 --- a/hw/display/cirrus_vga.c +++ b/hw/display/cirrus_vga.c @@ -2940,27 +2940,28 @@ void cirrus_init_common(CirrusVGAState *s, Object *= owner, =20 static void pci_cirrus_vga_realize(PCIDevice *dev, Error **errp) { - PCICirrusVGAState *d =3D PCI_CIRRUS_VGA(dev); - CirrusVGAState *s =3D &d->cirrus_vga; - PCIDeviceClass *pc =3D PCI_DEVICE_GET_CLASS(dev); - int16_t device_id =3D pc->device_id; - - /* follow real hardware, cirrus card emulated has 4 MB video memory. - Also accept 8 MB/16 MB for backward compatibility. */ - if (s->vga.vram_size_mb !=3D 4 && s->vga.vram_size_mb !=3D 8 && - s->vga.vram_size_mb !=3D 16) { - error_setg(errp, "Invalid cirrus_vga ram size '%u'", - s->vga.vram_size_mb); - return; - } - /* setup VGA */ - vga_common_init(&s->vga, OBJECT(dev)); - cirrus_init_common(s, OBJECT(dev), device_id, 1, pci_address_space(de= v), - pci_address_space_io(dev)); - s->vga.con =3D graphic_console_init(DEVICE(dev), 0, s->vga.hw_ops, &s= ->vga); - - /* setup PCI */ + PCICirrusVGAState *d =3D PCI_CIRRUS_VGA(dev); + CirrusVGAState *s =3D &d->cirrus_vga; + PCIDeviceClass *pc =3D PCI_DEVICE_GET_CLASS(dev); + int16_t device_id =3D pc->device_id; + + /* + * Follow real hardware, cirrus card emulated has 4 MB video memory. + * Also accept 8 MB/16 MB for backward compatibility. + */ + if (s->vga.vram_size_mb !=3D 4 && s->vga.vram_size_mb !=3D 8 && + s->vga.vram_size_mb !=3D 16) { + error_setg(errp, "Invalid cirrus_vga ram size '%u'", + s->vga.vram_size_mb); + return; + } + /* setup VGA */ + vga_common_init(&s->vga, OBJECT(dev)); + cirrus_init_common(s, OBJECT(dev), device_id, 1, pci_address_space(dev= ), + pci_address_space_io(dev)); + s->vga.con =3D graphic_console_init(DEVICE(dev), 0, s->vga.hw_ops, &s-= >vga); =20 + /* setup PCI */ memory_region_init(&s->pci_bar, OBJECT(dev), "cirrus-pci-bar0", 0x2000= 000); =20 /* XXX: add byte swapping apertures */ @@ -2968,14 +2969,14 @@ static void pci_cirrus_vga_realize(PCIDevice *dev, = Error **errp) memory_region_add_subregion(&s->pci_bar, 0x1000000, &s->cirrus_linear_bitblt_io); =20 - /* setup memory space */ - /* memory #0 LFB */ - /* memory #1 memory-mapped I/O */ - /* XXX: s->vga.vram_size must be a power of two */ - pci_register_bar(&d->dev, 0, PCI_BASE_ADDRESS_MEM_PREFETCH, &s->pci_b= ar); - if (device_id =3D=3D CIRRUS_ID_CLGD5446) { - pci_register_bar(&d->dev, 1, 0, &s->cirrus_mmio_io); - } + /* setup memory space */ + /* memory #0 LFB */ + /* memory #1 memory-mapped I/O */ + /* XXX: s->vga.vram_size must be a power of two */ + pci_register_bar(&d->dev, 0, PCI_BASE_ADDRESS_MEM_PREFETCH, &s->pci_ba= r); + if (device_id =3D=3D CIRRUS_ID_CLGD5446) { + pci_register_bar(&d->dev, 1, 0, &s->cirrus_mmio_io); + } } =20 static Property pci_vga_cirrus_properties[] =3D { --=20 2.27.0 From nobody Sat May 18 12:12:36 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1647505948141328.5847902500226; Thu, 17 Mar 2022 01:32:28 -0700 (PDT) Received: from localhost ([::1]:35682 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nUlYY-0001GQ-Qx for importer@patchew.org; Thu, 17 Mar 2022 04:32:26 -0400 Received: from eggs.gnu.org ([209.51.188.92]:56170) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nUlWp-0007aK-IU for qemu-devel@nongnu.org; Thu, 17 Mar 2022 04:30:39 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:53906) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nUlWn-0006ix-Kj for qemu-devel@nongnu.org; Thu, 17 Mar 2022 04:30:39 -0400 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-282-GZHv6X-bPTGwZsKxIV1nPw-1; Thu, 17 Mar 2022 04:30:34 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id B151C299E756; Thu, 17 Mar 2022 08:30:33 +0000 (UTC) Received: from thuth.com (dhcp-192-232.str.redhat.com [10.33.192.232]) by smtp.corp.redhat.com (Postfix) with ESMTP id 13C1A2EFA3; Thu, 17 Mar 2022 08:30:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1647505837; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=NcJV3a96S7DWx5OGmfO1VIJtmj2V3BKsSXHkVYuRwn8=; b=NCMINtILULY2dY1Ltw1HBhNTENwm1HyUNPdafIHJ/jcuRqP2opUFzqiw8lzHYfoY6UKXE8 o/pZ7CowIwaAqBKM+qbpWIezNgQYAOaPPzGjdsGPjS6EL1/naguOE8eOMYJpOFM7nLj7Mv NrdnzduJUN4miD6IQ/50AMGYpmj5BJ4= X-MC-Unique: GZHv6X-bPTGwZsKxIV1nPw-1 From: Thomas Huth To: qemu-devel@nongnu.org Subject: [PATCH v2 2/3] hw/display: Allow vga_common_init() to return errors Date: Thu, 17 Mar 2022 09:30:25 +0100 Message-Id: <20220317083027.16688-3-thuth@redhat.com> In-Reply-To: <20220317083027.16688-1-thuth@redhat.com> References: <20220317083027.16688-1-thuth@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=thuth@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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=170.10.133.124; envelope-from=thuth@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Gerd Hoffmann , armbru@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1647505949018100004 Content-Type: text/plain; charset="utf-8" The vga_common_init() function currently cannot report errors to its caller. But in the following patch, we'd need this possibility, so let's change it to take an "Error **" as parameter for this. Signed-off-by: Thomas Huth Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- hw/display/vga_int.h | 2 +- hw/display/ati.c | 4 +++- hw/display/cirrus_vga.c | 4 +++- hw/display/cirrus_vga_isa.c | 4 +++- hw/display/qxl.c | 6 +++++- hw/display/vga-isa.c | 5 ++++- hw/display/vga-mmio.c | 5 ++++- hw/display/vga-pci.c | 8 ++++++-- hw/display/vga.c | 11 +++++++++-- hw/display/virtio-vga.c | 4 +++- hw/display/vmware_vga.c | 2 +- 11 files changed, 42 insertions(+), 13 deletions(-) diff --git a/hw/display/vga_int.h b/hw/display/vga_int.h index 847e784ca6..305e700014 100644 --- a/hw/display/vga_int.h +++ b/hw/display/vga_int.h @@ -156,7 +156,7 @@ static inline int c6_to_8(int v) return (v << 2) | (b << 1) | b; } =20 -void vga_common_init(VGACommonState *s, Object *obj); +bool vga_common_init(VGACommonState *s, Object *obj, Error **errp); void vga_init(VGACommonState *s, Object *obj, MemoryRegion *address_space, MemoryRegion *address_space_io, bool init_vga_ports); MemoryRegion *vga_init_io(VGACommonState *s, Object *obj, diff --git a/hw/display/ati.c b/hw/display/ati.c index 31f22754dc..6e38e00502 100644 --- a/hw/display/ati.c +++ b/hw/display/ati.c @@ -955,7 +955,9 @@ static void ati_vga_realize(PCIDevice *dev, Error **err= p) } =20 /* init vga bits */ - vga_common_init(vga, OBJECT(s)); + if (!vga_common_init(vga, OBJECT(s), errp)) { + return; + } vga_init(vga, OBJECT(s), pci_address_space(dev), pci_address_space_io(dev), true); vga->con =3D graphic_console_init(DEVICE(s), 0, s->vga.hw_ops, &s->vga= ); diff --git a/hw/display/cirrus_vga.c b/hw/display/cirrus_vga.c index 7da1be3e12..3bb6a58698 100644 --- a/hw/display/cirrus_vga.c +++ b/hw/display/cirrus_vga.c @@ -2956,7 +2956,9 @@ static void pci_cirrus_vga_realize(PCIDevice *dev, Er= ror **errp) return; } /* setup VGA */ - vga_common_init(&s->vga, OBJECT(dev)); + if (!vga_common_init(&s->vga, OBJECT(dev), errp)) { + return; + } cirrus_init_common(s, OBJECT(dev), device_id, 1, pci_address_space(dev= ), pci_address_space_io(dev)); s->vga.con =3D graphic_console_init(DEVICE(dev), 0, s->vga.hw_ops, &s-= >vga); diff --git a/hw/display/cirrus_vga_isa.c b/hw/display/cirrus_vga_isa.c index 4f6fb1af3b..96144bd690 100644 --- a/hw/display/cirrus_vga_isa.c +++ b/hw/display/cirrus_vga_isa.c @@ -56,7 +56,9 @@ static void isa_cirrus_vga_realizefn(DeviceState *dev, Er= ror **errp) return; } s->global_vmstate =3D true; - vga_common_init(s, OBJECT(dev)); + if (!vga_common_init(s, OBJECT(dev), errp)) { + return; + } cirrus_init_common(&d->cirrus_vga, OBJECT(dev), CIRRUS_ID_CLGD5430, 0, isa_address_space(isadev), isa_address_space_io(isadev)); diff --git a/hw/display/qxl.c b/hw/display/qxl.c index 1f9ad31943..adbdbcaeb6 100644 --- a/hw/display/qxl.c +++ b/hw/display/qxl.c @@ -2215,7 +2215,11 @@ static void qxl_realize_primary(PCIDevice *dev, Erro= r **errp) qxl_init_ramsize(qxl); vga->vbe_size =3D qxl->vgamem_size; vga->vram_size_mb =3D qxl->vga.vram_size / MiB; - vga_common_init(vga, OBJECT(dev)); + vga_common_init(vga, OBJECT(dev), &local_err); + if (local_err) { + error_propagate(errp, local_err); + return; + } vga_init(vga, OBJECT(dev), pci_address_space(dev), pci_address_space_io(dev), false); portio_list_init(&qxl->vga_port_list, OBJECT(dev), qxl_vga_portio_list, diff --git a/hw/display/vga-isa.c b/hw/display/vga-isa.c index 90851e730b..46abbc5653 100644 --- a/hw/display/vga-isa.c +++ b/hw/display/vga-isa.c @@ -62,7 +62,10 @@ static void vga_isa_realizefn(DeviceState *dev, Error **= errp) const MemoryRegionPortio *vga_ports, *vbe_ports; =20 s->global_vmstate =3D true; - vga_common_init(s, OBJECT(dev)); + if (!vga_common_init(s, OBJECT(dev), errp)) { + return; + } + s->legacy_address_space =3D isa_address_space(isadev); vga_io_memory =3D vga_init_io(s, OBJECT(dev), &vga_ports, &vbe_ports); isa_register_portio_list(isadev, &d->portio_vga, diff --git a/hw/display/vga-mmio.c b/hw/display/vga-mmio.c index 4969368081..75dfcedea5 100644 --- a/hw/display/vga-mmio.c +++ b/hw/display/vga-mmio.c @@ -102,7 +102,10 @@ static void vga_mmio_realizefn(DeviceState *dev, Error= **errp) =20 s->vga.bank_offset =3D 0; s->vga.global_vmstate =3D true; - vga_common_init(&s->vga, OBJECT(dev)); + if (!vga_common_init(&s->vga, OBJECT(dev), errp)) { + return; + } + sysbus_init_mmio(sbd, &s->vga.vram); s->vga.con =3D graphic_console_init(dev, 0, s->vga.hw_ops, &s->vga); } diff --git a/hw/display/vga-pci.c b/hw/display/vga-pci.c index 62fb5c38c1..3e5bc259f7 100644 --- a/hw/display/vga-pci.c +++ b/hw/display/vga-pci.c @@ -239,7 +239,9 @@ static void pci_std_vga_realize(PCIDevice *dev, Error *= *errp) bool edid =3D false; =20 /* vga + console init */ - vga_common_init(s, OBJECT(dev)); + if (!vga_common_init(s, OBJECT(dev), errp)) { + return; + } vga_init(s, OBJECT(dev), pci_address_space(dev), pci_address_space_io(= dev), true); =20 @@ -275,7 +277,9 @@ static void pci_secondary_vga_realize(PCIDevice *dev, E= rror **errp) bool edid =3D false; =20 /* vga + console init */ - vga_common_init(s, OBJECT(dev)); + if (!vga_common_init(s, OBJECT(dev), errp)) { + return; + } s->con =3D graphic_console_init(DEVICE(dev), 0, s->hw_ops, s); =20 /* mmio bar */ diff --git a/hw/display/vga.c b/hw/display/vga.c index 9d1f66af40..ae96023596 100644 --- a/hw/display/vga.c +++ b/hw/display/vga.c @@ -2168,9 +2168,10 @@ static inline uint32_t uint_clamp(uint32_t val, uint= 32_t vmin, uint32_t vmax) return val; } =20 -void vga_common_init(VGACommonState *s, Object *obj) +bool vga_common_init(VGACommonState *s, Object *obj, Error **errp) { int i, j, v, b; + Error *local_err =3D NULL; =20 for(i =3D 0;i < 256; i++) { v =3D 0; @@ -2206,7 +2207,11 @@ void vga_common_init(VGACommonState *s, Object *obj) =20 s->is_vbe_vmstate =3D 1; memory_region_init_ram_nomigrate(&s->vram, obj, "vga.vram", s->vram_si= ze, - &error_fatal); + &local_err); + if (local_err) { + error_propagate(errp, local_err); + return false; + } vmstate_register_ram(&s->vram, s->global_vmstate ? NULL : DEVICE(obj)); xen_register_framebuffer(&s->vram); s->vram_ptr =3D memory_region_get_ram_ptr(&s->vram); @@ -2237,6 +2242,8 @@ void vga_common_init(VGACommonState *s, Object *obj) s->default_endian_fb =3D false; #endif vga_dirty_log_start(s); + + return true; } =20 static const MemoryRegionPortio vga_portio_list[] =3D { diff --git a/hw/display/virtio-vga.c b/hw/display/virtio-vga.c index 5a2f7a4540..7b55c8d0e7 100644 --- a/hw/display/virtio-vga.c +++ b/hw/display/virtio-vga.c @@ -108,7 +108,9 @@ static void virtio_vga_base_realize(VirtIOPCIProxy *vpc= i_dev, Error **errp) =20 /* init vga compat bits */ vga->vram_size_mb =3D 8; - vga_common_init(vga, OBJECT(vpci_dev)); + if (!vga_common_init(vga, OBJECT(vpci_dev), errp)) { + return; + } vga_init(vga, OBJECT(vpci_dev), pci_address_space(&vpci_dev->pci_dev), pci_address_space_io(&vpci_dev->pci_dev), true); pci_register_bar(&vpci_dev->pci_dev, 0, diff --git a/hw/display/vmware_vga.c b/hw/display/vmware_vga.c index 0cc43a1f15..98c83474ad 100644 --- a/hw/display/vmware_vga.c +++ b/hw/display/vmware_vga.c @@ -1254,7 +1254,7 @@ static void vmsvga_init(DeviceState *dev, struct vmsv= ga_state_s *s, &error_fatal); s->fifo_ptr =3D memory_region_get_ram_ptr(&s->fifo_ram); =20 - vga_common_init(&s->vga, OBJECT(dev)); + vga_common_init(&s->vga, OBJECT(dev), &error_fatal); vga_init(&s->vga, OBJECT(dev), address_space, io, true); vmstate_register(NULL, 0, &vmstate_vga_common, &s->vga); s->new_depth =3D 32; --=20 2.27.0 From nobody Sat May 18 12:12:36 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1647506059810926.1027921903175; Thu, 17 Mar 2022 01:34:19 -0700 (PDT) Received: from localhost ([::1]:40016 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nUlaM-0004FH-Q9 for importer@patchew.org; Thu, 17 Mar 2022 04:34:18 -0400 Received: from eggs.gnu.org ([209.51.188.92]:56182) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nUlWq-0007bA-Fc for qemu-devel@nongnu.org; Thu, 17 Mar 2022 04:30:40 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:23835) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nUlWo-0006jC-LY for qemu-devel@nongnu.org; Thu, 17 Mar 2022 04:30:40 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-299-v3CSQTwsPI-MjroWysWZ_g-1; Thu, 17 Mar 2022 04:30:34 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 8ADE2811E78; Thu, 17 Mar 2022 08:30:34 +0000 (UTC) Received: from thuth.com (dhcp-192-232.str.redhat.com [10.33.192.232]) by smtp.corp.redhat.com (Postfix) with ESMTP id E1E1C2D479; Thu, 17 Mar 2022 08:30:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1647505838; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=AKF/Uo22hU0IKYo/JuLite6KFD1eTFHCDrURn8orIIM=; b=Rv23G0mBg34wCPPrxaC8UJs3ZA4U2cHAL8BQALBY/8bd/cA37OShBqvqaGH2R4H8cCgJlk Qw0j6aPObpG8zGXs46PFFOW6pTy1WdQYdm9ZUzKuAQ3L7g33EoIyCgDRcD2M/n/NGpcoWf A58zgb3o4SBpx7WQLgNrQh8oXzOh1yE= X-MC-Unique: v3CSQTwsPI-MjroWysWZ_g-1 From: Thomas Huth To: qemu-devel@nongnu.org Subject: [PATCH v2 3/3] hw/display/vga: Report a proper error when adding a 2nd ISA VGA Date: Thu, 17 Mar 2022 09:30:26 +0100 Message-Id: <20220317083027.16688-4-thuth@redhat.com> In-Reply-To: <20220317083027.16688-1-thuth@redhat.com> References: <20220317083027.16688-1-thuth@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=thuth@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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=170.10.129.124; envelope-from=thuth@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Gerd Hoffmann , armbru@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1647506061532100001 Content-Type: text/plain; charset="utf-8" QEMU currently abort()s if the user tries to add a second ISA VGA device, for example: $ ./qemu-system-x86_64 -device isa-vga -device isa-vga RAMBlock "vga.vram" already registered, abort! Aborted (core dumped) $ ./qemu-system-x86_64 -device isa-cirrus-vga -device isa-cirrus-vga RAMBlock "vga.vram" already registered, abort! Aborted (core dumped) $ ./qemu-system-mips64el -M pica61 -device isa-vga RAMBlock "vga.vram" already registered, abort! Aborted (core dumped) Such a crash should never happen just because of giving bad parameters at the command line. Let's return a proper error message instead. (The idea is based on an original patch by Jose R. Ziviani for the isa-vga device, but this now fixes it for the isa-cirrus-vga device, too) Resolves: https://gitlab.com/qemu-project/qemu/-/issues/44 Signed-off-by: Thomas Huth --- hw/display/vga.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/hw/display/vga.c b/hw/display/vga.c index ae96023596..a7a291fa20 100644 --- a/hw/display/vga.c +++ b/hw/display/vga.c @@ -2206,6 +2206,12 @@ bool vga_common_init(VGACommonState *s, Object *obj,= Error **errp) s->vbe_size_mask =3D s->vbe_size - 1; =20 s->is_vbe_vmstate =3D 1; + + if (s->global_vmstate && qemu_ram_block_by_name("vga.vram")) { + error_setg(errp, "Only one global VGA device can be used at a time= "); + return false; + } + memory_region_init_ram_nomigrate(&s->vram, obj, "vga.vram", s->vram_si= ze, &local_err); if (local_err) { --=20 2.27.0