From patchwork Wed Oct 18 14:11:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 735065 Delivered-To: patch@linaro.org Received: by 2002:adf:f0cd:0:b0:32d:baff:b0ca with SMTP id x13csp1017173wro; Wed, 18 Oct 2023 07:13:48 -0700 (PDT) X-Google-Smtp-Source: AGHT+IG9lNubBfG1vlcw1SQtB2RST/isPbrCwWjPbv6JH2cECty+Pkjvq7rdeAyVEdgrdYL8c3fq X-Received: by 2002:ad4:5fce:0:b0:66d:4a22:d7cd with SMTP id jq14-20020ad45fce000000b0066d4a22d7cdmr7011420qvb.60.1697638428464; Wed, 18 Oct 2023 07:13:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697638428; cv=none; d=google.com; s=arc-20160816; b=wUKfhaVE3PcurL9p8dcqx1ozuN3leJzKuED0xECR+9y38ondu01RMd2eGmUjlMeE5v ESseflTVHmIzAfj1K2nb4uwxPvzgAA379mj+pF8Qvug+VT7Fu6RAr4zw7bZCiCharMT4 BTrMqj79bg6BQK/JDzwwXFknMojGeCDzonGJYScaaxKDHyIRDfpEWIf71yQCUCTaYwRl jGrDjZPhpIhopnM0r3VGI0zP+wWZOCrg/qLDWS+iYf0tlmzj9nf/e4MVLSMyi+SwGcs5 pu85sg0gjn3DwwvnBjyDaxVTMgXsawuhBhiClpR86S23pn40LgxssqXqi2DZhAubmqX/ IfGg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=H6bLxBklXqCA6pp1eqkZHUbqa8cn5QQGHgcnGcbF5xE=; fh=ANIikQnX6ADG7FYuHYnQUKFZKV9+VnxLLzGv0RFOlfg=; b=Lc+dCbxsqVHcbFtCWTJep+OwDKBsj3/qcI4xAePGSdBDX/IDvOKqt9SMAmTXIPEfTi fDS3/RWTLOZC5jIJgd3KJLmQX7RsYGW4NTGoZE6WQMlEzxFDSXObtAPqYQBR27toGXUy MWO5VLf3N+MHxHs8Fx2VXa4f1XqP1ZjimsT84RBnejFL47P9hXLmGBdqCRHVS9+BM3r6 9gFXTa60VaUt9EJ3WtxluQZDOnAiJ89Rijnn/U5UZEPuSocbHxPM+WJLkaAe4aI/qmdO FM9ItbccPqvSb3fhBSS0ELCvMkyg3ZrxR2ZryvnRWOnYrwizmwonb61IyuigOTzm+/FR Yq2A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=pr7rXlRz; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id u12-20020a0ced2c000000b00655e4826736si2608180qvq.69.2023.10.18.07.13.48 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 18 Oct 2023 07:13:48 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=pr7rXlRz; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qt7Ig-0002OR-Te; Wed, 18 Oct 2023 10:13: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 1qt7Ie-00020C-Ce for qemu-devel@nongnu.org; Wed, 18 Oct 2023 10:13:28 -0400 Received: from mail-ej1-x631.google.com ([2a00:1450:4864:20::631]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qt7Ib-0004xI-LJ for qemu-devel@nongnu.org; Wed, 18 Oct 2023 10:13:28 -0400 Received: by mail-ej1-x631.google.com with SMTP id a640c23a62f3a-9bda758748eso822338566b.2 for ; Wed, 18 Oct 2023 07:13:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1697638403; x=1698243203; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=H6bLxBklXqCA6pp1eqkZHUbqa8cn5QQGHgcnGcbF5xE=; b=pr7rXlRzw/5V1Q8g12Xg/OAdV/9ZNftxz898sD/B9jJ7X6WoLormgH5nXixN+UsR6Z GIvO3XGw/YhZR5cCwhLFYMtPx3lYPsf5Ea8NYLNiz1lH2UTBpJmeRR2MaQkW7GdRWByl nv+e01OmDT9zDQa3br6Za8NN9ZT8NNK+MouAvsfQ7n5xQrS7UnjtBuuH1iuwY0epRMCE KNV7elM11EfAlp4vzL0dq3oyiZqz/XB9RZALSCKzOTQ3Jida1xZAjeVvSdJX6Kbcpx9Y gZW8QrgX1t8koH+ME19XZlQSCkTW7fvI20ZR1kBNQxpaWXp+POe73fh6TLigakgzygR/ GQ8w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697638403; x=1698243203; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=H6bLxBklXqCA6pp1eqkZHUbqa8cn5QQGHgcnGcbF5xE=; b=ZXA08am9Zk7DoyoStUV2CTBet+RPiPFHSMMUiEAbIC1KB6jy8w079M2ZS867XKWuNJ AY78LMw9T7Pq6/RjjOI7Y5PAQFKJnOJJvslvkb3E25TOaMexwN/jxKtCOGOy35gqnx17 yx7nAhp89dYkWIebqSEKrp6lNS7fwerVUqKmsa9aJcViC9N+7UAtCAdfucN8qRYM+FW8 5XJY8zwjFH9fmB2mwTMi4Fw6CNBMSkPSqF7OfmxzTrLBN6Nt910KTWzMBBM1ks17QyM3 J0nfnd0kcL0WZwrKrez6bRnB1ijrYEW5RLXvT2P0erMI6sXJDhRFux4T1cgIh9m/yMiG KTdw== X-Gm-Message-State: AOJu0YyBCK1hqiaEOdzYbfQ3eKPPBtu4dYBHBO/Ls2i/CLmnbojoPoNf OZH3duJPDbSNzYORw5qJzZx6DgL+URGdg+G3R68= X-Received: by 2002:a17:907:968c:b0:9bf:30e8:5bfd with SMTP id hd12-20020a170907968c00b009bf30e85bfdmr4613711ejc.48.1697638403486; Wed, 18 Oct 2023 07:13:23 -0700 (PDT) Received: from m1x-phil.lan (gyl59-h01-176-171-218-149.dsl.sta.abo.bbox.fr. [176.171.218.149]) by smtp.gmail.com with ESMTPSA id j14-20020a170906104e00b009c5c5c2c5a4sm1738187ejj.219.2023.10.18.07.13.20 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Wed, 18 Oct 2023 07:13:23 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Richard Henderson , Eric Farman , Peter Xu , "Michael S. Tsirkin" , Halil Pasic , Jiaxun Yang , Strahinja Jankovic , Eduardo Habkost , Sergio Lopez , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Peter Maydell , Marcel Apfelbaum , Jason Wang , qemu-arm@nongnu.org, qemu-s390x@nongnu.org, Ilya Leoshkevich , Song Gao , Huacai Chen , Beniamino Galvani , Christian Borntraeger , Thomas Huth , David Hildenbrand , =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , Paolo Bonzini Subject: [PATCH 11/12] hw/sysbus: Ensure device is not realized before adding MMIO region Date: Wed, 18 Oct 2023 16:11:49 +0200 Message-ID: <20231018141151.87466-12-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231018141151.87466-1-philmd@linaro.org> References: <20231018141151.87466-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::631; envelope-from=philmd@linaro.org; helo=mail-ej1-x631.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org sysbus_init_mmio() should not be called on realized device. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Thomas Huth --- hw/core/sysbus.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/hw/core/sysbus.c b/hw/core/sysbus.c index 35f902b582..ce54e2c416 100644 --- a/hw/core/sysbus.c +++ b/hw/core/sysbus.c @@ -192,6 +192,11 @@ void sysbus_init_mmio(SysBusDevice *dev, MemoryRegion *memory) int n; assert(dev->num_mmio < QDEV_MAX_MMIO); + if (DEVICE(dev)->realized) { + error_report("sysbus_init_mmio(type:%s) but object is realized", + object_get_typename(OBJECT(dev))); + abort(); + } n = dev->num_mmio++; dev->mmio[n].addr = -1; dev->mmio[n].memory = memory;