Message ID | 20230918101736.23905-3-philmd@linaro.org |
---|---|
State | New |
Headers | show
Delivered-To: patch@linaro.org Received: by 2002:adf:f0d1:0:b0:31d:da82:a3b4 with SMTP id x17csp1601096wro; Mon, 18 Sep 2023 03:18:39 -0700 (PDT) X-Google-Smtp-Source: AGHT+IE1nXfNKXz1B6WlNcEtCiQDkUirQHDxv0vogF30O5plvxzdIzuyX1hdl0aR+HR32kTp+tZ9 X-Received: by 2002:a05:620a:226:b0:76f:1d46:8511 with SMTP id u6-20020a05620a022600b0076f1d468511mr8221956qkm.44.1695032319030; Mon, 18 Sep 2023 03:18:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695032319; cv=none; d=google.com; s=arc-20160816; b=izythBnGuysBbFgLQ1fnvwD2CVbCHbEGOdzCmPU/CWoHEKaFvy3mU2V4z4pWbnysLo QD6vrTmj2NmvryCQCLS9Ye9N76FlJoruHEXheo3b3fvbdAWxML2tjDe20dQLHtrHZHSE rPyegLVWgPMFMo4k1/Ng9iUjMhI0TmdEu6jZJbYbhH2miYPd6xtJNnSWDiSuh5oUIKuC AV5IhAf/hS7f6zsrKmrD9hWjXPdm7yp4dRdxGYWlA81db1eAaTkwniUOf6JbRSTD2hM4 MdmvsKa4QSX1vssMCEJa4gmmhY68HQGCFF7TEAP6b2pq55U7rL4Wrq1aGF1nVHGvfVUS ISqA== 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=8I52HFJ7JIIVf6/kc1x9A3KkqjzDotpu4ox1BgoUxm4=; fh=9n/Cm2KnMX6Qk7SoVbKt4LcEa/gSBuZo6NwnCSpbrp4=; b=k+NvX50CDSPDYIAN2hdtSAyn0WJxZhkRwNyjKERYBeZbvFcQPBk1JpTWN9dZ4aFJBw sPiJgepJNSjQmkHybF7NNDy7e2kT94DeBPXbX+Ol4FmuvclEHEh/UJGUDOwMwq9Dv2ch vaKLdLSWxMy2jqC9mjoI6+NT5BaA0nmOhZC6ldmL9j6ZpcVRoGyiwhm1gFiG7tzZHjAv 9k8xCj0BLRcOGfBuRSDsv7ejBTIcUM3bHiW+F6YfA+V99s022Gf6/n5RC7Ad504xX6pJ Kq7vJ420YIcfjOq14HxUp6PGMLDCm8fzKEq7oE6VL4/x82lfKtTGd8YcMO9fFsITnbWO o9OA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="NO/fDZs9"; 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: <qemu-devel-bounces+patch=linaro.org@nongnu.org> Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id o29-20020a05620a0d5d00b0076da9a5c93dsi5687375qkl.335.2023.09.18.03.18.38 for <patch@linaro.org> (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 18 Sep 2023 03:18:39 -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="NO/fDZs9"; 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 <qemu-devel-bounces@nongnu.org>) id 1qiBKM-0006JW-TD; Mon, 18 Sep 2023 06:18:02 -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 <philmd@linaro.org>) id 1qiBKJ-0006Iq-Tw for qemu-devel@nongnu.org; Mon, 18 Sep 2023 06:17:59 -0400 Received: from mail-wm1-x32f.google.com ([2a00:1450:4864:20::32f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from <philmd@linaro.org>) id 1qiBKH-0006ou-DW for qemu-devel@nongnu.org; Mon, 18 Sep 2023 06:17:58 -0400 Received: by mail-wm1-x32f.google.com with SMTP id 5b1f17b1804b1-4050bd2e33aso7090895e9.2 for <qemu-devel@nongnu.org>; Mon, 18 Sep 2023 03:17:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1695032276; x=1695637076; 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=8I52HFJ7JIIVf6/kc1x9A3KkqjzDotpu4ox1BgoUxm4=; b=NO/fDZs9W5HiqDat34WSBqcyUio2okr25QwI6p7cCubnPGxOYMSjJUAt6dy3hh81YH 21btOA8H3QDOeJMQiOQJrcfVVBbwsabxmWdKnrYBmVjrYbBypTVyT91Reaot9vk5GXE9 vw2aExYzkuIQf34C+wzcRQeeCm3O+IheKsWK7OKRUFJb9RDyLxW0EWp8HkQ5ONLtT920 gC8Fgli4TFKpfFdiBzr4JHiYJRegpW5c1CA1LzzRBziKvFoaaTiM7O3WBrCmkuT1njUY +jS1BSbqAHIlCMCxQqWpMtCQXsQZgULpDODi8XLKpDRdDBszwsGIYGjPcW8bGSQX7hz3 FDPA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695032276; x=1695637076; 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=8I52HFJ7JIIVf6/kc1x9A3KkqjzDotpu4ox1BgoUxm4=; b=qP05ST8y5ktED1AoDxBVrZDAdk+2svM4fA1+Yn718h2qTq7dxrh7hcQAEDhNKAP4uk XJ6WMIpvpI+jbuAAjSfO0fJcfg2rjbbYGOxigqadZQDXk0x3xm4q7raFF9JrVQrxgunm yLenaYpKfR3t0U/Ia96vkaD6ebPYbWAruzGV0JwZIHSf+HvTBKxgcxE9WS/8pqcJ0pGu STh5ZlaHkgWrinPin/E4w1n5qg4RA0OgX9M2WwkI/fDXx0ypJJlwzeOY7dgCGs8dbq4H fa9TyYIqd+NiO+P2wzuXPG4p+2fNWLFW+AMbCg23aKzXGjWXpA5qZOHWyg9NjCGBCA4e 5wWA== X-Gm-Message-State: AOJu0YykxyHCHpATNckaMOQR6oQAQsngWo5yHWN/oJie/Wg0khw6E0YJ 8taBcqj8bnn5esdOzYeFc2a9T3nCE2WlyNouNCPRpNZh X-Received: by 2002:a05:600c:2901:b0:401:906b:7e9d with SMTP id i1-20020a05600c290100b00401906b7e9dmr7999543wmd.18.1695032275800; Mon, 18 Sep 2023 03:17:55 -0700 (PDT) Received: from localhost.localdomain (5.red-88-29-175.dynamicip.rima-tde.net. [88.29.175.5]) by smtp.gmail.com with ESMTPSA id c4-20020a05600c0ac400b004030c778396sm14945294wmr.4.2023.09.18.03.17.53 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 18 Sep 2023 03:17:55 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= <philmd@linaro.org> To: qemu-devel@nongnu.org Cc: Richard Henderson <richard.henderson@linaro.org>, "Daniel P . Berrange" <berrange@redhat.com>, Eduardo Habkost <eduardo@habkost.net>, Alistair Francis <alistair@alistair23.me>, Paolo Bonzini <pbonzini@redhat.com>, Anton Johansson <anjo@rev.ng>, "Edgar E . Iglesias" <edgar.iglesias@gmail.com>, Markus Armbruster <armbru@redhat.com>, =?utf-8?q?Alex_Benn=C3=A9e?= <alex.bennee@linaro.org>, =?utf-8?q?C=C3=A9dri?= =?utf-8?q?c_Le_Goater?= <clg@kaod.org>, Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>, Bernhard Beschow <shentey@gmail.com>, Peter Maydell <peter.maydell@linaro.org>, Alessandro Di Federico <ale@rev.ng>, qemu-arm@nongnu.org, Luc Michel <luc@lmichel.fr>, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= <philmd@linaro.org> Subject: [PATCH 2/2] qdev: Ensure devices are fully realized when calling DeviceReset handler Date: Mon, 18 Sep 2023 12:17:36 +0200 Message-ID: <20230918101736.23905-3-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230918101736.23905-1-philmd@linaro.org> References: <20230918101736.23905-1-philmd@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Received-SPF: pass client-ip=2a00:1450:4864:20::32f; envelope-from=philmd@linaro.org; helo=mail-wm1-x32f.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: <qemu-devel.nongnu.org> List-Unsubscribe: <https://lists.nongnu.org/mailman/options/qemu-devel>, <mailto:qemu-devel-request@nongnu.org?subject=unsubscribe> List-Archive: <https://lists.nongnu.org/archive/html/qemu-devel> List-Post: <mailto:qemu-devel@nongnu.org> List-Help: <mailto:qemu-devel-request@nongnu.org?subject=help> List-Subscribe: <https://lists.nongnu.org/mailman/listinfo/qemu-devel>, <mailto:qemu-devel-request@nongnu.org?subject=subscribe> Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org |
Series |
qdev: Ensure devices are fully realized when calling DeviceReset handler
|
expand
|
diff --git a/hw/core/qdev.c b/hw/core/qdev.c index 43d863b0c5..c51b4c98de 100644 --- a/hw/core/qdev.c +++ b/hw/core/qdev.c @@ -252,6 +252,8 @@ void qdev_set_legacy_instance_id(DeviceState *dev, int alias_id, void device_cold_reset(DeviceState *dev) { + /* TODO: Also cover CPUs once we removed manual calls to cpu_reset() */ + assert(object_dynamic_cast(OBJECT(dev), TYPE_CPU) || dev->realized); resettable_reset(OBJECT(dev), RESET_TYPE_COLD); } @@ -280,6 +282,7 @@ static void device_reset_child_foreach(Object *obj, ResettableChildCallback cb, bool qdev_realize(DeviceState *dev, BusState *bus, Error **errp) { assert(!dev->realized && !dev->parent_bus); + assert(!device_is_in_reset(dev)); if (bus) { if (!qdev_set_parent_bus(dev, bus, errp)) {
We shouldn't call a DeviceReset() handler on unrealized device. In order to enforce that, add an assertion. CPU devices are a bit particular because we manually reset them in various places, so corner case them out for now. Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> --- hw/core/qdev.c | 3 +++ 1 file changed, 3 insertions(+)