From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 71926C433C1 for ; Thu, 25 Mar 2021 15:36:15 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id E8C2061A2B for ; Thu, 25 Mar 2021 15:36:14 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E8C2061A2B Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:36958 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lPS1t-00075s-UD for qemu-devel@archiver.kernel.org; Thu, 25 Mar 2021 11:36:13 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42672) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lPRzJ-0005Ew-Fh for qemu-devel@nongnu.org; Thu, 25 Mar 2021 11:33:34 -0400 Received: from mail-wr1-x42d.google.com ([2a00:1450:4864:20::42d]:44785) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lPRz6-000579-Ed for qemu-devel@nongnu.org; Thu, 25 Mar 2021 11:33:33 -0400 Received: by mail-wr1-x42d.google.com with SMTP id c8so2700087wrq.11 for ; Thu, 25 Mar 2021 08:33:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=uZpAMMR+4O26S3vnkFRf0Ab3gTpOaqGRZy2FhEyixw8=; b=uaKeA64G6J1H5qClFpaUGlakuYR3pQWRl6b+/0ARN74Rr0FXpMspgBv8GzgY3uGO4a zACe0ZtSP2BLxvA4UwGnTYEAqhoiovBPrJzETGnkvNjsnXSz653oZyG3+QQWwVfSktPB OI7ljPQp/GJeWkgHvs1J0+WM5bSfymlrNqQKA9EoRrvSXqEdM43WHSnvhJfZ0fDTD1+w 9PuiGavpUtJTqUjg/iYvsWjZ4qQqfPbd87l8VZPwB+uB0m2et5678ywfdmXa3LVpM/C0 bFZHh1Eh/YSJQCLrUE67i+dIr5+drYU2TVcB6FI6yqqO5byRClLx2yO2aFjwNKJlCOmT 9qzA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=uZpAMMR+4O26S3vnkFRf0Ab3gTpOaqGRZy2FhEyixw8=; b=oF4s72gJCuuaAvYXROZF12okmiit2aWWimE6Iz1bx4/3pms6hbnvltpt3rU/pgHFfd H/IDV6kG8tdS62TTFWZPetKaZfVS5SIJXFTFHL5GiSGCSappAqTLB8XS4hTrPKhKu3BN aXaOh2L6bitMmALjZ7M1jTilS7RzkuKQIDidb+GclCPboX9ebW6bRV+HVFS1CJIuO4Yu XUoluFeba1XJMW+Xs65FBBHZryXGOOu1sWxF4EaDnw/TvEsrzeEnq1+WtFr44FneKmzB IdiQB12l0KdemsZHRfQWe9QNpHn81wqAmhVqKiYPGou+KT8ZJYFCwpfZcDfW7CE6bth5 eR1A== X-Gm-Message-State: AOAM531jMqrFEXTxnkWoyq7Ou5prTtkG4TyTlhTQwmxTyQg5tNqTaqI4 2QjjbWq0vSwnwnyP/ThukAZNOw== X-Google-Smtp-Source: ABdhPJzjFj4O46eeqw1u9RoY748bSf/c2CR0XFV3f8TU0xbQfrMlZL8MBn3BM70HKVhZT/J8nAEO9g== X-Received: by 2002:a5d:4bcb:: with SMTP id l11mr6604888wrt.390.1616686397149; Thu, 25 Mar 2021 08:33:17 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id g11sm8004580wrw.89.2021.03.25.08.33.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Mar 2021 08:33:16 -0700 (PDT) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Subject: [PATCH for-6.0 4/4] hw/ppc/e500plat: Only try to add valid dynamic sysbus devices to platform bus Date: Thu, 25 Mar 2021 15:33:10 +0000 Message-Id: <20210325153310.9131-5-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210325153310.9131-1-peter.maydell@linaro.org> References: <20210325153310.9131-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Received-SPF: pass client-ip=2a00:1450:4864:20::42d; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x42d.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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Eduardo Habkost , Mark Cave-Ayland , Greg Kurz , qemu-ppc@nongnu.org, Igor Mammedov , David Gibson Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" The e500plat machine device plug callback currently calls platform_bus_link_device() for any sysbus device. This is overly broad, because platform_bus_link_device() will unconditionally grab the IRQs and MMIOs of the device it is passed, whether it was intended for the platform bus or not. Restrict hotpluggability of sysbus devices to only those devices on the dynamic sysbus whitelist. We were mostly getting away with this because the board creates the platform bus as the last device it creates, and so the hotplug callback did not do anything for all the sysbus devices created by the board itself. However if the user plugged in a device which itself uses a sysbus device internally we would have mishandled this and probably asserted. An example of this is: qemu-system-ppc64 -M ppce500 -device macio-oldworld This isn't a sensible command because the macio-oldworld device is really specific to the 'g3beige' machine, but we now fail with a reasonable error message rather than asserting: qemu-system-ppc64: Device heathrow is not supported by this machine yet. Signed-off-by: Peter Maydell --- hw/ppc/e500plat.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/hw/ppc/e500plat.c b/hw/ppc/e500plat.c index bddd5e7c48f..fc911bbb7bd 100644 --- a/hw/ppc/e500plat.c +++ b/hw/ppc/e500plat.c @@ -48,7 +48,9 @@ static void e500plat_machine_device_plug_cb(HotplugHandler *hotplug_dev, PPCE500MachineState *pms = PPCE500_MACHINE(hotplug_dev); if (pms->pbus_dev) { - if (object_dynamic_cast(OBJECT(dev), TYPE_SYS_BUS_DEVICE)) { + MachineClass *mc = MACHINE_GET_CLASS(pms); + + if (device_is_dynamic_sysbus(mc, dev)) { platform_bus_link_device(pms->pbus_dev, SYS_BUS_DEVICE(dev)); } } @@ -58,7 +60,9 @@ static HotplugHandler *e500plat_machine_get_hotpug_handler(MachineState *machine, DeviceState *dev) { - if (object_dynamic_cast(OBJECT(dev), TYPE_SYS_BUS_DEVICE)) { + MachineClass *mc = MACHINE_GET_CLASS(machine); + + if (device_is_dynamic_sysbus(mc, dev)) { return HOTPLUG_HANDLER(machine); } -- 2.20.1