summaryrefslogtreecommitdiff
path: root/hw
diff options
context:
space:
mode:
authorPeter Maydell <peter.maydell@linaro.org>2021-04-06 16:04:33 +0100
committerPeter Maydell <peter.maydell@linaro.org>2021-04-06 16:04:33 +0100
commit4216ba1b2279a3922814d96e6acfb81a85d2dee2 (patch)
tree2055abea5dd75c59fcf5e68cb123aa1cf8d0570c /hw
parent259e909790c83995436938a2b7af464b5d63d4c3 (diff)
parent49bc76550c37f4a2b92a05cb3e6989a739d56ac9 (diff)
downloadqemu-4216ba1b2279a3922814d96e6acfb81a85d2dee2.zip
Merge remote-tracking branch 'remotes/pmaydell/tags/pull-target-arm-20210406' into staging
target-arm queue: * ppc/e500 and arm/virt: only add valid dynamic sysbus devices to the platform bus * update i.mx31 maintainer list * Revert "target/arm: Make number of counters in PMCR follow the CPU" # gpg: Signature made Tue 06 Apr 2021 13:25:54 BST # gpg: using RSA key E1A5C593CD419DE28E8315CF3C2525ED14360CDE # gpg: issuer "peter.maydell@linaro.org" # gpg: Good signature from "Peter Maydell <peter.maydell@linaro.org>" [ultimate] # gpg: aka "Peter Maydell <pmaydell@gmail.com>" [ultimate] # gpg: aka "Peter Maydell <pmaydell@chiark.greenend.org.uk>" [ultimate] # Primary key fingerprint: E1A5 C593 CD41 9DE2 8E83 15CF 3C25 25ED 1436 0CDE * remotes/pmaydell/tags/pull-target-arm-20210406: Remove myself as i.mx31 maintainer Revert "target/arm: Make number of counters in PMCR follow the CPU" hw/ppc/e500plat: Only try to add valid dynamic sysbus devices to platform bus hw/arm/virt: Only try to add valid dynamic sysbus devices to platform bus machine: Provide a function to check the dynamic sysbus allowlist include/hw/boards.h: Document machine_class_allow_dynamic_sysbus_dev() Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Diffstat (limited to 'hw')
-rw-r--r--hw/arm/virt.c8
-rw-r--r--hw/core/machine.c21
-rw-r--r--hw/ppc/e500plat.c8
3 files changed, 28 insertions, 9 deletions
diff --git a/hw/arm/virt.c b/hw/arm/virt.c
index bc5f948367..9f01d9041b 100644
--- a/hw/arm/virt.c
+++ b/hw/arm/virt.c
@@ -2443,7 +2443,9 @@ static void virt_machine_device_plug_cb(HotplugHandler *hotplug_dev,
VirtMachineState *vms = VIRT_MACHINE(hotplug_dev);
if (vms->platform_bus_dev) {
- if (object_dynamic_cast(OBJECT(dev), TYPE_SYS_BUS_DEVICE)) {
+ MachineClass *mc = 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(HotplugHandler *hotplug_dev,
static HotplugHandler *virt_machine_get_hotplug_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) ||
(object_dynamic_cast(OBJECT(dev), TYPE_PC_DIMM))) {
return HOTPLUG_HANDLER(machine);
}
diff --git a/hw/core/machine.c b/hw/core/machine.c
index a50f2d5f0a..40def78183 100644
--- a/hw/core/machine.c
+++ b/hw/core/machine.c
@@ -530,20 +530,31 @@ void machine_class_allow_dynamic_sysbus_dev(MachineClass *mc, const char *type)
QAPI_LIST_PREPEND(mc->allowed_dynamic_sysbus_devices, g_strdup(type));
}
-static void validate_sysbus_device(SysBusDevice *sbdev, void *opaque)
+bool device_is_dynamic_sysbus(MachineClass *mc, DeviceState *dev)
{
- MachineState *machine = opaque;
- MachineClass *mc = MACHINE_GET_CLASS(machine);
bool allowed = false;
strList *wl;
+ Object *obj = OBJECT(dev);
+
+ if (!object_dynamic_cast(obj, TYPE_SYS_BUS_DEVICE)) {
+ return false;
+ }
for (wl = mc->allowed_dynamic_sysbus_devices;
!allowed && wl;
wl = wl->next) {
- allowed |= !!object_dynamic_cast(OBJECT(sbdev), wl->value);
+ allowed |= !!object_dynamic_cast(obj, wl->value);
}
- if (!allowed) {
+ return allowed;
+}
+
+static void validate_sysbus_device(SysBusDevice *sbdev, void *opaque)
+{
+ MachineState *machine = opaque;
+ MachineClass *mc = MACHINE_GET_CLASS(machine);
+
+ if (!device_is_dynamic_sysbus(mc, DEVICE(sbdev))) {
error_report("Option '-device %s' cannot be handled by this machine",
object_class_get_name(object_get_class(OBJECT(sbdev))));
exit(1);
diff --git a/hw/ppc/e500plat.c b/hw/ppc/e500plat.c
index bddd5e7c48..fc911bbb7b 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);
}