From nobody Mon Feb 9 14:33:12 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1637263236; cv=none; d=zohomail.com; s=zohoarc; b=JxJ8r5PcYf5zD80YMQoxwx5TpMi09MeA2T5mCOG+vPbPEzBfK/1hoAb6S4fs1vv61pMEPIeflh3Ka+qc8MoNPJp60X37PNav0M7aLB+DN8b64Ngv3smy9XYXtEPqvEWGf3a4JCKfw+VzjdXs+gWrErVVbj0+QdkRB/uGj1nCJC4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1637263236; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=BS3zUsplw/cddARHJF9KyG2TRGK5Hoy8tUIn5HvjRk8=; b=l+JonL2Da9na03jh+1VFftGvkIGjvWxkl57kL0+uiErrbru8hs4IwyRQSz0cGig93dJs/kH3iC1HrLaHoEChWkVwHMn+NiMO1aAomxN4m/HHAdld5kwLAZa3r/oFZ/ftVVu3s6GDILwFrbcJu/KOOTVG078t54cqpfylHwdObww= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass header.from= (p=none dis=none) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.zohomail.com with SMTPS id 1637263236486284.2253427038668; Thu, 18 Nov 2021 11:20:36 -0800 (PST) Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-161-iGRsMNpIOzWwBSnfzC_Jew-1; Thu, 18 Nov 2021 14:20:34 -0500 Received: by mail-wm1-f70.google.com with SMTP id o18-20020a05600c511200b00332fa17a02eso3593124wms.5 for ; Thu, 18 Nov 2021 11:20:33 -0800 (PST) Return-Path: Return-Path: Received: from x1w.. (62.red-83-57-168.dynamicip.rima-tde.net. [83.57.168.62]) by smtp.gmail.com with ESMTPSA id u14sm679584wrt.49.2021.11.18.11.20.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Nov 2021 11:20:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1637263235; 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=BS3zUsplw/cddARHJF9KyG2TRGK5Hoy8tUIn5HvjRk8=; b=Zjd1q4GRxj4XNUjWvj6RO1sTiBN/7f5ISiW1yX80K1R8yPB078/NQtztv8rHkZZsxLaoGb TLD5MKg7wmo1gHEhJ1J5fu0uXKVdshlcxgvK7x8OSL3x2riUvnwY6p7HFdk5ZZCGgDJFrl SGKgn+1A/9QkjbZOOicVMgmG4FYoK20= X-MC-Unique: iGRsMNpIOzWwBSnfzC_Jew-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=BS3zUsplw/cddARHJF9KyG2TRGK5Hoy8tUIn5HvjRk8=; b=tEm10FFAdvlsksKjEm1/Hy2MnTl9elrchHSdyTdszDOk+/Nu6YKJrTYBXYyKeSm4u5 7QuEiGfdNVUQPtIP2PUqAxIM1pti78du9InmYkcwkTMBqIYlxABWS3R19N4xlqhaY3dK NqOkBLo0L1r8Gr1xwEQN45ZECAldgqkhQRVz1uxE+d8PaPSLx3q0HQgK21lPkdIICKcH 8KlUB4s7H2Kgh1AV2g0Ex9ypzXu+78WEb9NoXyDQlqFcTDQYafw1TnQFradviWwf5iUP wyskfQtOpZvrALk//bKRfYZWaqIwTG2Hb07WiKBXhBSRkKwSV+HxBCSmqE4spIMGL4pM dZQQ== X-Gm-Message-State: AOAM532VcIlNwe+Q0xpZRh7pW+/z0jwy7r+Yu1uXN9QdmxHQt8OGn2KH F360MetB1adW02WEJOfzcBDBoYe2sQvRlR5pLOBsguJagEA6NYERl8/jxtID0UZNpoH/d4gngYs tVK+NOO3VzrbcLw== X-Received: by 2002:a05:600c:2252:: with SMTP id a18mr13369583wmm.133.1637263232416; Thu, 18 Nov 2021 11:20:32 -0800 (PST) X-Google-Smtp-Source: ABdhPJwbiH+GAbOugjqSDdjSe0fk3jnOexxhrCeIIdpHsw4Ix0UwugXHk8a2HHULKDh34nPUn7UDjA== X-Received: by 2002:a05:600c:2252:: with SMTP id a18mr13369561wmm.133.1637263232276; Thu, 18 Nov 2021 11:20:32 -0800 (PST) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Thomas Huth , "Jose R . Ziviani" , John Snow , "Michael S. Tsirkin" , Gerd Hoffmann , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH-for-6.2 2/2] hw/display: Do not allow multiple identical VGA devices Date: Thu, 18 Nov 2021 20:20:20 +0100 Message-Id: <20211118192020.61245-3-philmd@redhat.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211118192020.61245-1-philmd@redhat.com> References: <20211118192020.61245-1-philmd@redhat.com> MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=philmd@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1637263237817100001 vga_common_init() create a MemoryRegion named "vga.vram", used as a singleton for the device class. When creating the same device type multiple times, we get: $ qemu-system-mips64 -M pica61 -device isa-cirrus-vga RAMBlock "vga.vram" already registered, abort! Aborted (core dumped) Commit 7852a77f598 ("vga: don't abort when adding a duplicate isa-vga device") added a check for a single device, generalize it to all VGA devices which call vga_common_init(): $ qemu-system-mips64 -M pica61 -device isa-cirrus-vga qemu-system-mips64: -device isa-cirrus-vga: at most one isa-cirrus-vga de= vice is permitted Reported-by: John Snow Resolves: https://gitlab.com/qemu-project/qemu/-/issues/44 Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- hw/display/vga-isa.c | 9 --------- hw/display/vga.c | 13 +++++++++++++ 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/hw/display/vga-isa.c b/hw/display/vga-isa.c index 2782012196a..b930c8d2667 100644 --- a/hw/display/vga-isa.c +++ b/hw/display/vga-isa.c @@ -62,15 +62,6 @@ static void vga_isa_realizefn(DeviceState *dev, Error **= errp) MemoryRegion *vga_io_memory; const MemoryRegionPortio *vga_ports, *vbe_ports; =20 - /* - * make sure this device is not being added twice, if so - * exit without crashing qemu - */ - if (object_resolve_path_type("", TYPE_ISA_VGA, NULL)) { - error_setg(errp, "at most one %s device is permitted", TYPE_ISA_VG= A); - return; - } - s->global_vmstate =3D true; if (!vga_common_init(s, OBJECT(dev), errp)) { return; diff --git a/hw/display/vga.c b/hw/display/vga.c index a6759c7e934..8f0d5cc9019 100644 --- a/hw/display/vga.c +++ b/hw/display/vga.c @@ -2172,6 +2172,19 @@ bool vga_common_init(VGACommonState *s, Object *obj,= Error **errp) { int i, j, v, b; =20 + if (obj) { + const char *typename =3D object_get_typename(obj); + + /* + * make sure this device is not being added twice, + * if so exit without crashing qemu + */ + if (object_resolve_path_type("", typename, NULL)) { + error_setg(errp, "at most one %s device is permitted", typenam= e); + return false; + } + } + for(i =3D 0;i < 256; i++) { v =3D 0; for(j =3D 0; j < 8; j++) { --=20 2.31.1