From nobody Sat May 4 16:51:22 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1616686743; cv=none; d=zohomail.com; s=zohoarc; b=j8uocY3u/pBZR8+VqXgnYme/Ju7JYYZjc2alh/qVCpJmPbSO3+mZHKX8cpZhxYuxOAkYOWO+J/n9/ewuIaim4KCKWxRv03wD3BwpKfdKBtF/+XP+u/2h5YvZNy1jmntr/9rr3elRs1OcYxcLPLuIpK1asnXEb96V3op459GB1x8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1616686743; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=HBUJPboo8vzvo+P46JoUkwrV2UGz/XowQ0iwB317xoU=; b=j+J/frmlT6vF25W4TGSYHHhSD33YzFVN0/8SHA2Uxc4aqP06I7DsYjUwSSD99aTPyNh+8BylePnChc99SyRGAaSx03XaQiH3cP1apARriLC/QetXEIV997cK/UBEWHSRKZXw61cjmxTEsEmmoWXV4++Stx4PxziQy5DsoskNytU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1616686743673288.1996485542012; Thu, 25 Mar 2021 08:39:03 -0700 (PDT) Received: from localhost ([::1]:46206 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lPS4c-0002PD-JL for importer@patchew.org; Thu, 25 Mar 2021 11:39:02 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42610) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lPRzA-0005E7-PN for qemu-devel@nongnu.org; Thu, 25 Mar 2021 11:33:24 -0400 Received: from mail-wm1-x32c.google.com ([2a00:1450:4864:20::32c]:37558) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lPRz1-00055o-Js for qemu-devel@nongnu.org; Thu, 25 Mar 2021 11:33:24 -0400 Received: by mail-wm1-x32c.google.com with SMTP id f22-20020a7bc8d60000b029010c024a1407so3349514wml.2 for ; Thu, 25 Mar 2021 08:33:15 -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.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Mar 2021 08:33:13 -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=HBUJPboo8vzvo+P46JoUkwrV2UGz/XowQ0iwB317xoU=; b=Vyomhw+uoEfnfc3INjXZvtatCkD9AZ+Opmpsxz4Ayz/lLNEIW23EKRXk5T+AQcKtIb oMWueOa/vaUXwMvD/5CHV8KKyCE2NJlc+BsowTrWsdSLzwn3ESUK9y1aYkvqJQGyOyFA jXVwzjoc4O2IlTeSX0lF//lvZI3Az9T8M7PfZyyp3eL1dzHkS45wwUruJnuE/70oiuXT fX3GDMQAb6gpso2j7dxTiHurmQiztMgt1W7yKwKyweskstdeFeeBeU2X7nodJs1JEAI+ NKifyw9k57osxYpHsHjrgvnEn9dNH/NYFfoiketadgZVI5iD9yRQ4ZOTsOkr0FgQganA dEkg== 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=HBUJPboo8vzvo+P46JoUkwrV2UGz/XowQ0iwB317xoU=; b=riEQ+1DjIqz5tHooxVMx9xg1RwLQTFCOe+V1QjtdmEyGsZ1V12Rz00HPIuV+WGVsWL W0ROAujqwR+2Xn2oylU9ai7qzPPQevbd5sxc3X+FrHWvCsq+Mo/IhOCNuOYyTRyUJJCU JWMfSHoI9SJ3fb0jYmZMctHoBJGqbP5Iaq7OyBpJaAMGSToucEdTzV5GrrepK/3YqsTz V3n8h0EF3CFalKnK7FJcrpeWWnwKa3N2xGlc+2TXHkurV8Jo+qmUnAORM0hCUnWHi8Sf B9d86VfPc8Jsn68GHqAITKWX0pkJoSf+oSwEcLjeFce0IUPQCJVylRfcaUaHwHu4pA4e gqww== X-Gm-Message-State: AOAM531S+H8/9BNQ96cvvSzmOH3YL/Z0dIJQxXwzm/T6LtUwm1yknl1u f+8uE2+2fSQXWXcXACcLaowWhA== X-Google-Smtp-Source: ABdhPJzbIjFaXH+PiAma1oF124FAcfjBh54b/wQPMTih7fzU40B+sBAel7eItBrzRnVQjMFZ9euK/A== X-Received: by 2002:a1c:f305:: with SMTP id q5mr8524371wmq.96.1616686394040; Thu, 25 Mar 2021 08:33:14 -0700 (PDT) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Subject: [PATCH for-6.0 1/4] include/hw/boards.h: Document machine_class_allow_dynamic_sysbus_dev() Date: Thu, 25 Mar 2021 15:33:07 +0000 Message-Id: <20210325153310.9131-2-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: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::32c; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x32c.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=ham 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" The function machine_class_allow_dynamic_sysbus_dev() is currently undocumented; add a doc comment. Signed-off-by: Peter Maydell Reviewed-by: Eric Auger Reviewed-by: Mark Cave-Ayland Reviewed-by: Richard Henderson --- include/hw/boards.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/include/hw/boards.h b/include/hw/boards.h index 4a90549ad85..27106abc11d 100644 --- a/include/hw/boards.h +++ b/include/hw/boards.h @@ -36,7 +36,21 @@ void machine_set_cpu_numa_node(MachineState *machine, const CpuInstanceProperties *props, Error **errp); =20 +/** + * machine_class_allow_dynamic_sysbus_dev: Add type to list of valid devic= es + * @mc: Machine class + * @type: type to whitelist (should be a subtype of TYPE_SYS_BUS_DEVICE) + * + * Add the QOM type @type to the list of devices of which are subtypes + * of TYPE_SYS_BUS_DEVICE but which are still permitted to be dynamically + * created (eg by the user on the command line with -device). + * By default if the user tries to create any devices on the command line + * that are subtypes of TYPE_SYS_BUS_DEVICE they will get an error message; + * for the special cases which are permitted for this machine model, the + * machine model class init code must call this function to whitelist them. + */ void machine_class_allow_dynamic_sysbus_dev(MachineClass *mc, const char *= type); + /* * Checks that backend isn't used, preps it for exclusive usage and * returns migratable MemoryRegion provided by backend. --=20 2.20.1 From nobody Sat May 4 16:51:22 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1616686763; cv=none; d=zohomail.com; s=zohoarc; b=lHekZI3sn+uMeT4aMQap2n0apMizen0dVe4LThGVdKn3R+S0bqRQWMqiAwaUTzE2uZXZOozgN/hxWkip7clpz5a78Lj9zyvX6JueCbJZr3N6g8mV46gue/9HeKOCVGzIOf+aduWiUr0YRhofdP0Cy+i1QEPIuKTsoK8jlhLbSxA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1616686763; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=qsbZ3WwBIAsRBGcGHbyvNlewlN2P0E/qqzYZ7ye59xs=; b=cRtUBbyFLQqSGvcRJPhIe4WXmtWGLtbFowHuZtbL9bmkWJNpCTEU9hUqBwHR+jpJfw36S/fKGaEX9eSkOKBkUoTUqCH40LfK0kQDolDYi7Ja39liFPh4/HkzEtnQt18PAGpy9mSxPoI/OsANEQoPbMo1MnyUCaBb6Kutv/N8/8M= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 161668676350528.202459156530608; Thu, 25 Mar 2021 08:39:23 -0700 (PDT) Received: from localhost ([::1]:47366 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lPS4w-0002tT-0T for importer@patchew.org; Thu, 25 Mar 2021 11:39:22 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42658) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lPRzI-0005Eu-4d for qemu-devel@nongnu.org; Thu, 25 Mar 2021 11:33:34 -0400 Received: from mail-wm1-x32d.google.com ([2a00:1450:4864:20::32d]:54107) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lPRz6-000562-CK for qemu-devel@nongnu.org; Thu, 25 Mar 2021 11:33:31 -0400 Received: by mail-wm1-x32d.google.com with SMTP id g20so1414174wmk.3 for ; Thu, 25 Mar 2021 08:33:15 -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.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Mar 2021 08:33:14 -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=qsbZ3WwBIAsRBGcGHbyvNlewlN2P0E/qqzYZ7ye59xs=; b=Z0PnyL0OgB70hT+woVqg8D4e8BzLbvaOplIzx5NzFRWKMNMXNkyi1rGkdwoVRoDhah 7knOo1YMezs1xVpXEogcqE9SKrrrznUtYpxV7hKXiMrpAHz4FgQepNvaiq3vImXE/ZD9 g+LVxaRZpTza4yvxWL4oGem8y9Hc84FcYiC9Ouw6zBRTupTEXaeh3OqvCthYccj/IHC0 0dRThM/QyxnAc9O3pnYodMJ45XGq0Ga2dk6RXMeLVcyy9knlUFmAfnXHWgvRLVI8LKiF OuZsBXnDLkpnUj7YdQx5Ajer4lCH52KiOYpkr32Pb+KbhY8qupdY4YFUyJKeDeJmeRn/ yvoA== 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=qsbZ3WwBIAsRBGcGHbyvNlewlN2P0E/qqzYZ7ye59xs=; b=I8eksytWaoxKbeeW/kZy1Jltvccma/xTgMFYx6yUqyuihDcIKsYaPCl+V8Temdx8Bk g1OkwLhrgB5hvG3eHYZrpfDz1JxDvv3qfod4q8UkxLz+We7i3GGhm3880MaDGBVaaEn5 xrRq6qAEqMF2W2+5C/729ChdGrUqv3p8crsddAjvLCtlIulUKjAsEunomu39GGYHgbrz AeTDNpGSn7dU8uWeqyFO5EGoSik8CgIhI5ZeeLCrkUvOdRqaVvIzR+NvYoOf7AhU9sLY UYI6QdGxHBHTJYwV4I8J4Hgx9MMyPDzJMFD9pNKjg9yzN0V200UGRBb1a21XyOcXKFhm ORAQ== X-Gm-Message-State: AOAM532f3s/yjBvD7k32lTZe6pKhFHUXjjbDZeXT/5gJ1pmO9F4JM2uI PFDMXt1pkBl9ngcCLXu34PZoLw== X-Google-Smtp-Source: ABdhPJwA48dQzzisxZILpRcNNbQeOeid4OX0ZHBB4D/zkUU7W+xfx3Fstnbb7/Z1Jnvmt4PfzNo9Bg== X-Received: by 2002:a7b:c04d:: with SMTP id u13mr8489521wmc.83.1616686395042; Thu, 25 Mar 2021 08:33:15 -0700 (PDT) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Subject: [PATCH for-6.0 2/4] machine: Provide a function to check the dynamic sysbus whitelist Date: Thu, 25 Mar 2021 15:33:08 +0000 Message-Id: <20210325153310.9131-3-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: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::32d; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x32d.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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Provide a new function dynamic_sysbus_dev_allowed() which checks the per-machine whitelist of dynamic sysbus devices and returns a boolean result indicating whether the device is whitelisted. We can use this in the implementation of validate_sysbus_device(), but we will also need it so that machine hotplug callbacks can validate devices rather than assuming that any sysbus device might be hotpluggable into the platform bus. Signed-off-by: Peter Maydell Reviewed-by: Eric Auger Reviewed-by: Mark Cave-Ayland Reviewed-by: Richard Henderson --- include/hw/boards.h | 24 ++++++++++++++++++++++++ hw/core/machine.c | 21 ++++++++++++++++----- 2 files changed, 40 insertions(+), 5 deletions(-) diff --git a/include/hw/boards.h b/include/hw/boards.h index 27106abc11d..609112a4e1a 100644 --- a/include/hw/boards.h +++ b/include/hw/boards.h @@ -51,6 +51,30 @@ void machine_set_cpu_numa_node(MachineState *machine, */ void machine_class_allow_dynamic_sysbus_dev(MachineClass *mc, const char *= type); =20 +/** + * device_is_dynamic_sysbus: test whether device is a dynamic sysbus device + * @mc: Machine class + * @dev: device to check + * + * Returns: true if @dev is a sysbus device on the machine's whitelist + * of dynamically pluggable sysbus devices; otherwise false. + * + * This function checks whether @dev is a valid dynamic sysbus device, + * by first confirming that it is a sysbus device and then checking it + * against the whitelist of permitted dynamic sysbus devices which has + * been set up by the machine using machine_class_allow_dynamic_sysbus_dev= (). + * + * It is valid to call this with something that is not a subclass of + * TYPE_SYS_BUS_DEVICE; the function will return false in this case. + * This allows hotplug callback functions to be written as: + * if (device_is_dynamic_sysbus(mc, dev)) { + * handle dynamic sysbus case; + * } else if (some other kind of hotplug) { + * handle that; + * } + */ +bool device_is_dynamic_sysbus(MachineClass *mc, DeviceState *dev); + /* * Checks that backend isn't used, preps it for exclusive usage and * returns migratable MemoryRegion provided by backend. diff --git a/hw/core/machine.c b/hw/core/machine.c index 9935c6ddd56..8d97094736a 100644 --- a/hw/core/machine.c +++ b/hw/core/machine.c @@ -529,20 +529,31 @@ void machine_class_allow_dynamic_sysbus_dev(MachineCl= ass *mc, const char *type) QAPI_LIST_PREPEND(mc->allowed_dynamic_sysbus_devices, g_strdup(type)); } =20 -static void validate_sysbus_device(SysBusDevice *sbdev, void *opaque) +bool device_is_dynamic_sysbus(MachineClass *mc, DeviceState *dev) { - MachineState *machine =3D opaque; - MachineClass *mc =3D MACHINE_GET_CLASS(machine); bool allowed =3D false; strList *wl; + Object *obj =3D OBJECT(dev); + + if (!object_dynamic_cast(obj, TYPE_SYS_BUS_DEVICE)) { + return false; + } =20 for (wl =3D mc->allowed_dynamic_sysbus_devices; !allowed && wl; wl =3D wl->next) { - allowed |=3D !!object_dynamic_cast(OBJECT(sbdev), wl->value); + allowed |=3D !!object_dynamic_cast(obj, wl->value); } =20 - if (!allowed) { + return allowed; +} + +static void validate_sysbus_device(SysBusDevice *sbdev, void *opaque) +{ + MachineState *machine =3D opaque; + MachineClass *mc =3D MACHINE_GET_CLASS(machine); + + if (!device_is_dynamic_sysbus(mc, DEVICE(sbdev))) { error_report("Option '-device %s' cannot be handled by this machin= e", object_class_get_name(object_get_class(OBJECT(sbdev))= )); exit(1); --=20 2.20.1 From nobody Sat May 4 16:51:22 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1616686604; cv=none; d=zohomail.com; s=zohoarc; b=fXVxtZAv9H9/226B2oQEIY3fwWVRol/0eBNnAzWiOuT2mnp9mVeKsz51UrDp+p5m/O+cLKNMM222EnLc7xgqMh9jLYbheY4qS5pXUfEVz62+vsikoBCiF36NF6bXwCKfkD3xw+wOEKaS4wLtPvrbqyOZlghaEBzEZVSC08JPS5c= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1616686604; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=HC5HU11GOp9X3zRRsVLrOYWQjmWw07GcRvQz1EkLmlE=; b=fxHF0S1Vo93KBoWcQ79T3BeZQ2B8ln+NMEvuRYOLnJmTG9dp7QFqbFCirP9ZqAtbFayDFl7v8GfeWv2RtZDFbCIo6OlUmSyg59/pePj4nTUuqeIOzCI+WhjPSqzsiBKr84/C3Vx3npQXY4KpMzlrgd1hKKRQoOx1/7GDy+f8M+o= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1616686604568981.7937497639768; Thu, 25 Mar 2021 08:36:44 -0700 (PDT) Received: from localhost ([::1]:38484 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lPS2N-0007gv-DN for importer@patchew.org; Thu, 25 Mar 2021 11:36:43 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42632) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lPRzD-0005Ek-6D for qemu-devel@nongnu.org; Thu, 25 Mar 2021 11:33:32 -0400 Received: from mail-wm1-x330.google.com ([2a00:1450:4864:20::330]:41747) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lPRz6-00056g-Dc for qemu-devel@nongnu.org; Thu, 25 Mar 2021 11:33:26 -0400 Received: by mail-wm1-x330.google.com with SMTP id t5-20020a1c77050000b029010e62cea9deso1441703wmi.0 for ; 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.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Mar 2021 08:33:15 -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=HC5HU11GOp9X3zRRsVLrOYWQjmWw07GcRvQz1EkLmlE=; b=L6Kocalab/lTaEXyfOhkUIbDq7ZckJv+rXc3IphCRcbgCs0wCxoGbiYE/QKk881O06 K8YLNfpEOeeIwDwwp0fdQAST4elG8XuZmWui+Bl7CK5AWaS1xN1XCDrWyiPOuWuk2ZzD 6P28QWVAj4SsB9S7dS3As2J5FWzeBI+K8WIDA5HHXStHNtOUmEP6X7BXiGvUAaabHlbV lPHSlMGPL1YMPvyzmBqUgX6Kc6HcABTz6/Pbv4XX24fOZmUKWdOCB1D0Rmg6/qSbQzPn 9JefqZR+5O2vRrDJkZ5doYKQSX+AWL2m7Gp2CCos2yJXDfoYlZ6356CFrR6qKxoRFtcQ fDRg== 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=HC5HU11GOp9X3zRRsVLrOYWQjmWw07GcRvQz1EkLmlE=; b=m/WjCpnZ9ifdJO5MyYeKFuczyuFLRE2F25xS696iOjlduNISS2ug00UVtZkp09DbYo hOuq+4Nn0vylc2JrZi6Jwh4L4uI7OrE09/zzgAIDBfta9OeLRHEcGURWNTQk6DEiRFt0 PY5KWkXZkYbfjSL1Xf0vlfWjbaq/13zQ12+8ahM9qM/veCbA3X7VklxRACK+kmqb7knk esCq5eAr905Um5BXw72RVORXqB3iEbGbbu9009IpFQLqWXh38SQu0A/iEnkRkw91XB2L haYagVx5NOMPn7qTDyY0pal2JEwA++NUlBzjOoabP6ykEnaX8qKlrx+uT2dlVKxviGub RNlA== X-Gm-Message-State: AOAM532gvnHPr+gkJIyXsxPQHp4IXg4fc8NFyxzDppHzBiezw5b4bHr8 Hy+9Aqsgox+bVl1DA8TQdUIDMXVZqO+GsskK X-Google-Smtp-Source: ABdhPJwm3YMPzieH5u03v9xRDMyLzPsjqpdOWwOgwM7V6q80agrst0ABYHpLhNFZOsUQPG3YBWOkzQ== X-Received: by 2002:a05:600c:b57:: with SMTP id k23mr8386586wmr.145.1616686396022; 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 3/4] hw/arm/virt: Only try to add valid dynamic sysbus devices to platform bus Date: Thu, 25 Mar 2021 15:33:09 +0000 Message-Id: <20210325153310.9131-4-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: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::330; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x330.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=ham 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" The virt 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. Signed-off-by: Peter Maydell Reviewed-by: Eric Auger Reviewed-by: Mark Cave-Ayland Reviewed-by: Richard Henderson --- hw/arm/virt.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/hw/arm/virt.c b/hw/arm/virt.c index aa2bbd14e09..8625152a735 100644 --- a/hw/arm/virt.c +++ b/hw/arm/virt.c @@ -2443,7 +2443,9 @@ static void virt_machine_device_plug_cb(HotplugHandle= r *hotplug_dev, VirtMachineState *vms =3D VIRT_MACHINE(hotplug_dev); =20 if (vms->platform_bus_dev) { - if (object_dynamic_cast(OBJECT(dev), TYPE_SYS_BUS_DEVICE)) { + MachineClass *mc =3D MACHINE_GET_CLASS(vms); + + if (device_is_dynamic_sysbus(mc, dev)) { platform_bus_link_device(PLATFORM_BUS_DEVICE(vms->platform_bus= _dev), SYS_BUS_DEVICE(dev)); } @@ -2527,7 +2529,9 @@ static void virt_machine_device_unplug_cb(HotplugHand= ler *hotplug_dev, static HotplugHandler *virt_machine_get_hotplug_handler(MachineState *mach= ine, DeviceState *dev) { - if (object_dynamic_cast(OBJECT(dev), TYPE_SYS_BUS_DEVICE) || + MachineClass *mc =3D MACHINE_GET_CLASS(machine); + + if (device_is_dynamic_sysbus(mc, dev) || (object_dynamic_cast(OBJECT(dev), TYPE_PC_DIMM))) { return HOTPLUG_HANDLER(machine); } --=20 2.20.1 From nobody Sat May 4 16:51:22 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1616686585; cv=none; d=zohomail.com; s=zohoarc; b=RCRcXT22NMnaOPmhsqqIFEMHmtZ/EMya0UqcwuNZKs3v8L4KXqXpJ3MC+hl7J+VRlR1Q6ovcU3nWE/eU59MaHHqChqLcw4sjNjUZ6rqAc5kKPjur0pz0OAdb3WiKdLR+955RMB8VtsMknsCBeiNjoGk6FS+gJiecXBGMRPXj2xA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1616686585; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=uZpAMMR+4O26S3vnkFRf0Ab3gTpOaqGRZy2FhEyixw8=; b=OxFckZGQJZYNFF3x2wuN+oeqqkvI+4s1T20Kl9p1hQ0u0Jsz1RwAPDCs3wB5OCXhfxpGUiOnP1WnOyhlgyCvKOdtOFRT7njG2QhQosu3MOpmCfcvcWYiaki/6Bvujx95lensFIdbd1uO4/pCSBGuBfq0DTjbAoqQw4+Tvaumxik= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1616686585904558.911038007165; Thu, 25 Mar 2021 08:36:25 -0700 (PDT) Received: from localhost ([::1]:36958 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lPS24-00075s-7n for importer@patchew.org; Thu, 25 Mar 2021 11:36:24 -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) 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) 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) 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: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" 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 Acked-by: David Gibson Reviewed-by: Eric Auger Reviewed-by: Mark Cave-Ayland Reviewed-by: Richard Henderson --- 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(HotplugHandle= r *hotplug_dev, PPCE500MachineState *pms =3D PPCE500_MACHINE(hotplug_dev); =20 if (pms->pbus_dev) { - if (object_dynamic_cast(OBJECT(dev), TYPE_SYS_BUS_DEVICE)) { + MachineClass *mc =3D 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 =3D MACHINE_GET_CLASS(machine); + + if (device_is_dynamic_sysbus(mc, dev)) { return HOTPLUG_HANDLER(machine); } =20 --=20 2.20.1