aboutsummaryrefslogtreecommitdiff
path: root/hw/arm
diff options
context:
space:
mode:
authorPeter Maydell <peter.maydell@linaro.org>2021-03-25 15:33:09 +0000
committerPeter Maydell <peter.maydell@linaro.org>2021-04-06 11:49:14 +0100
commit37fce4dde15f7f7891be89972629d96f851f9815 (patch)
treed93c49878ae54b4384cca5332549765f7b550082 /hw/arm
parent0fb124dbfa135945fb892d0d2b7a427cdc59220d (diff)
downloadqemu-37fce4dde15f7f7891be89972629d96f851f9815.zip
qemu-37fce4dde15f7f7891be89972629d96f851f9815.tar.gz
qemu-37fce4dde15f7f7891be89972629d96f851f9815.tar.bz2
hw/arm/virt: Only try to add valid dynamic sysbus devices to platform bus
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 allowlist. 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 <peter.maydell@linaro.org> Reviewed-by: Richard Henderson <richard.henderson@linaro.org> Reviewed-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk> Reviewed-by: Eric Auger <eric.auger@redhat.com> Message-id: 20210325153310.9131-4-peter.maydell@linaro.org
Diffstat (limited to 'hw/arm')
-rw-r--r--hw/arm/virt.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/hw/arm/virt.c b/hw/arm/virt.c
index aa2bbd1..8625152 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);
}