Introduce an “accel” property to enable accelerator mode. Live migration is currently unsupported when accelerator mode is enabled, so a migration blocker is added.
Because this mode relies on IORT RMR for MSI support, accelerator mode is not supported for device tree boot. Signed-off-by: Shameer Kolothum <[email protected]> --- hw/arm/smmuv3.c | 28 ++++++++++++++++++++++++++++ hw/arm/virt.c | 19 ++++++++++++------- include/hw/arm/smmuv3.h | 1 + 3 files changed, 41 insertions(+), 7 deletions(-) diff --git a/hw/arm/smmuv3.c b/hw/arm/smmuv3.c index 94b2bbc374..a0f704fc35 100644 --- a/hw/arm/smmuv3.c +++ b/hw/arm/smmuv3.c @@ -20,6 +20,7 @@ #include "qemu/bitops.h" #include "hw/irq.h" #include "hw/sysbus.h" +#include "migration/blocker.h" #include "migration/vmstate.h" #include "hw/qdev-properties.h" #include "hw/qdev-core.h" @@ -1916,6 +1917,17 @@ static void smmu_reset_exit(Object *obj, ResetType type) smmuv3_accel_attach_bypass_hwpt(s); } +static bool smmu_validate_property(SMMUv3State *s, Error **errp) +{ +#ifndef CONFIG_ARM_SMMUV3_ACCEL + if (s->accel) { + error_setg(errp, "accel=on support not compiled in"); + return false; + } +#endif + return true; +} + static void smmu_realize(DeviceState *d, Error **errp) { SMMUState *sys = ARM_SMMU(d); @@ -1924,8 +1936,17 @@ static void smmu_realize(DeviceState *d, Error **errp) SysBusDevice *dev = SYS_BUS_DEVICE(d); Error *local_err = NULL; + if (!smmu_validate_property(s, errp)) { + return; + } + if (s->accel) { smmuv3_accel_init(s); + error_setg(&s->migration_blocker, "Migration not supported with SMMUv3 " + "accelerator mode enabled"); + if (migrate_add_blocker(&s->migration_blocker, errp) < 0) { + return; + } } c->parent_realize(d, &local_err); @@ -2025,6 +2046,7 @@ static const Property smmuv3_properties[] = { * Defaults to stage 1 */ DEFINE_PROP_STRING("stage", SMMUv3State, stage), + DEFINE_PROP_BOOL("accel", SMMUv3State, accel, false), }; static void smmuv3_instance_init(Object *obj) @@ -2046,6 +2068,12 @@ static void smmuv3_class_init(ObjectClass *klass, const void *data) device_class_set_props(dc, smmuv3_properties); dc->hotpluggable = false; dc->user_creatable = true; + + object_class_property_set_description(klass, + "accel", + "Enable SMMUv3 accelerator support." + "Allows host SMMUv3 to be configured " + "in nested mode for vfio-pci dev assignment"); } static int smmuv3_notify_flag_changed(IOMMUMemoryRegion *iommu, diff --git a/hw/arm/virt.c b/hw/arm/virt.c index 6467d7cfc8..6b789fd7b5 100644 --- a/hw/arm/virt.c +++ b/hw/arm/virt.c @@ -1474,8 +1474,8 @@ static void create_smmuv3_dt_bindings(const VirtMachineState *vms, hwaddr base, g_free(node); } -static void create_smmuv3_dev_dtb(VirtMachineState *vms, - DeviceState *dev, PCIBus *bus) +static void create_smmuv3_dev_dtb(VirtMachineState *vms, DeviceState *dev, + PCIBus *bus, Error **errp) { PlatformBusDevice *pbus = PLATFORM_BUS_DEVICE(vms->platform_bus_dev); SysBusDevice *sbdev = SYS_BUS_DEVICE(dev); @@ -1483,10 +1483,15 @@ static void create_smmuv3_dev_dtb(VirtMachineState *vms, hwaddr base = platform_bus_get_mmio_addr(pbus, sbdev, 0); MachineState *ms = MACHINE(vms); - if (!(vms->bootinfo.firmware_loaded && virt_is_acpi_enabled(vms)) && - strcmp("pcie.0", bus->qbus.name)) { - warn_report("SMMUv3 device only supported with pcie.0 for DT"); - return; + if (!(vms->bootinfo.firmware_loaded && virt_is_acpi_enabled(vms))) { + if (object_property_get_bool(OBJECT(dev), "accel", &error_abort)) { + error_setg(errp, "SMMUv3 with accel=on not supported for DT"); + return; + } + if (strcmp("pcie.0", bus->qbus.name)) { + warn_report("SMMUv3 device only supported with pcie.0 for DT"); + return; + } } base += vms->memmap[VIRT_PLATFORM_BUS].base; irq += vms->irqmap[VIRT_PLATFORM_BUS]; @@ -3086,7 +3091,7 @@ static void virt_machine_device_plug_cb(HotplugHandler *hotplug_dev, } } - create_smmuv3_dev_dtb(vms, dev, bus); + create_smmuv3_dev_dtb(vms, dev, bus, errp); if (object_property_get_bool(OBJECT(dev), "accel", &error_abort) && !vms->pci_preserve_config) { vms->pci_preserve_config = true; diff --git a/include/hw/arm/smmuv3.h b/include/hw/arm/smmuv3.h index 5f3e9089a7..874cbaaf32 100644 --- a/include/hw/arm/smmuv3.h +++ b/include/hw/arm/smmuv3.h @@ -67,6 +67,7 @@ struct SMMUv3State { /* SMMU has HW accelerator support for nested S1 + s2 */ bool accel; struct SMMUv3AccelState *s_accel; + Error *migration_blocker; }; typedef enum { -- 2.43.0
