From patchwork Wed Oct 18 14:11:50 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: 735066 Delivered-To: patch@linaro.org Received: by 2002:adf:f0cd:0:b0:32d:baff:b0ca with SMTP id x13csp1017177wro; Wed, 18 Oct 2023 07:13:49 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEGu2HcfHjnqFY4eNwkSKGrd+0CUK6RFoRDK1T7/QWen4Un/mUz8LG+xJH1irvguUBXScFV X-Received: by 2002:a05:620a:8398:b0:76f:5b9:3f32 with SMTP id pb24-20020a05620a839800b0076f05b93f32mr5283201qkn.19.1697638428852; 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=LFJK9BI4D77mJT3eeEnNe5vWlYIIGF9JetizRXDuvIdqw7IaFe4QSqqfafbgHcDsrd hdkutHethEpcUqbA5gG/5BHNeOpPZrITGbEg6yKz5R7D+6WpZxbcqIshbnCYax8JlcQN kxqeJuaAESHosYC7MjKaJHUl4TyZAJgAYGT6keejPl8hYkxAdLFviFSUyuD7hADlTths o52iJBVcYfYrAs0swpr2YOAFF7hNDJfCK7KFiAOazGe3KAI7cWcQMTJ/byPP5O+79O2L 7mfOvG0UikJ3HQPS8hExTgsU1NIwmn+oAgqx3c58X/Hw+m/8rhSuN9Y14lthJzF3HDyY /5PA== 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=III6J63m6TXPzGkHNGeaIlMVjIpH5ItVsLY/wuEjMjM=; fh=ANIikQnX6ADG7FYuHYnQUKFZKV9+VnxLLzGv0RFOlfg=; b=k3imiLlehlP3XGDSmGjZFpXII3myXS+hVG45zXfvkZ2lXPGUCwlPYLHgE3iTmRUKvT tal5yyRbFjQOq+pYZcfMrKeBa3b8EB8PXLRZpx51qBEhs55mj7UQ1sDfQskuEaEh8DjA 2ECNtIiJu4l5H5zFgWlqNpaRKuyjeWH+sYv3J9hhKnk+hJ4DOAJl9da+exOdXJNs5/pJ 2VZ0czjlc2yfJ7TcrBFMaTc43C8wMqAAGWL3HlYkdslUt1uyROvhj52SpRqwAZZ9Bm2k jdntexYu3QSXu76bUj8yc6mqwzVNYM+dtyn2QaEuLoUjvxdKQcSsigmotNbbLsqdtD6j tRDA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=WcRJDmg5; 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 f15-20020a05620a408f00b00775b023f298si3050388qko.139.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=WcRJDmg5; 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 1qt7Io-00036V-26; Wed, 18 Oct 2023 10:13:38 -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 1qt7Im-0002qq-F1 for qemu-devel@nongnu.org; Wed, 18 Oct 2023 10:13:36 -0400 Received: from mail-ed1-x52e.google.com ([2a00:1450:4864:20::52e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qt7Ik-0004yy-KR for qemu-devel@nongnu.org; Wed, 18 Oct 2023 10:13:36 -0400 Received: by mail-ed1-x52e.google.com with SMTP id 4fb4d7f45d1cf-53e16f076b3so13148830a12.0 for ; Wed, 18 Oct 2023 07:13:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1697638411; x=1698243211; 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=III6J63m6TXPzGkHNGeaIlMVjIpH5ItVsLY/wuEjMjM=; b=WcRJDmg5KTLuWJ+FhW+WLf2lwM8zZ7S5OCn+ylDZi2SN2LF5LLPC2QRBnIdb5FD/KA Rj1JEuVx3GVAihiK8Le+AL9WbqkIOWTEnUyHxP9wsTssX/cLAY+xvozGZdYMref/x33F +7g/rUzDGK7K1UL7fMIkb6ylwF9Var05F423cyJYDbcyjkv9nOCq0vdKZWyAaexTi9Yw ynH4z1cNH9F2yOP9yks9r9NZX/F9mTGbaAMPPbPl4B4l8AmU5Z7NYcjqusYKg/5+WIKl wJiz4lRQEvDeJSrTxhL7WQtgSLw+53M+OnfsCOtdWrFGivHp292Hr2isKJmen4sdli2q o3SA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697638411; x=1698243211; 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=III6J63m6TXPzGkHNGeaIlMVjIpH5ItVsLY/wuEjMjM=; b=Rpasx2LDxTzh7VfoPDPUTa9YEL0pOtkto2Lr0GcgEJMfeVftZ5Z9ERyMpTiEC7Pi2C lL/GJ/2OLfcoR/Sz4g/tup1ESz3VW6Ug6fDbH0fMxWKIe7Uf+BHmFGBaxIFo0I87at5A fK+IxfGj1GZAENaDqzApCwGw42d177ueZ16AsRAJj7treKwb3I3CTJXZhz4rzG0yiYkA LUqOCIgU4wLqy40wJZUr6lTf0wOtKd5cyk+sDFWiK8xqUQSzU4KDtYmoqaQ2juGyBqTl 30XVrItllggx6qCjonVnfFOVNF8lymLyJw/w5xvAJlxrTi9A1jXJ/UdGw0T1KFeWUzTa f8mA== X-Gm-Message-State: AOJu0YwZpE/Eir0Kzm/BzS5+HgV8JB2qtLZI4FmwNctiVUqaF5HQW/jw iADscy6um82CI3mGp6P6XbcmT/b9LfmLAOZxAMs= X-Received: by 2002:a17:907:ea1:b0:9bf:c00f:654a with SMTP id ho33-20020a1709070ea100b009bfc00f654amr4948996ejc.24.1697638411390; Wed, 18 Oct 2023 07:13:31 -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 t3-20020a1709064f0300b009c3f1b3e988sm1734423eju.90.2023.10.18.07.13.28 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Wed, 18 Oct 2023 07:13:31 -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 12/12] hw/sysbus: Ensure device is realized before mapping it Date: Wed, 18 Oct 2023 16:11:50 +0200 Message-ID: <20231018141151.87466-13-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::52e; envelope-from=philmd@linaro.org; helo=mail-ed1-x52e.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_mmio_map() should not be called on unrealized device. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Thomas Huth --- hw/core/sysbus.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/hw/core/sysbus.c b/hw/core/sysbus.c index ce54e2c416..a46828a808 100644 --- a/hw/core/sysbus.c +++ b/hw/core/sysbus.c @@ -20,6 +20,7 @@ #include "qemu/osdep.h" #include "qapi/error.h" #include "qemu/module.h" +#include "qemu/error-report.h" #include "hw/sysbus.h" #include "monitor/monitor.h" #include "exec/address-spaces.h" @@ -132,6 +133,13 @@ static void sysbus_mmio_map_common(SysBusDevice *dev, int n, hwaddr addr, { assert(n >= 0 && n < dev->num_mmio); + if (!DEVICE(dev)->realized) { + error_report("sysbus_mmio_map(type:%s, index:%d, addr:0x%"HWADDR_PRIx"," + " prio:%d) but object is not realized", + object_get_typename(OBJECT(dev)), n, addr, priority); + abort(); + } + if (dev->mmio[n].addr == addr) { /* ??? region already mapped here. */ return;