[PATCH v8 18/37] hw/arm/virt: Set msi-gpa property

Shameer Kolothum posted 37 patches 2 weeks, 4 days ago
Maintainers: Yi Liu <yi.l.liu@intel.com>, Eric Auger <eric.auger@redhat.com>, Zhenzhong Duan <zhenzhong.duan@intel.com>, Paolo Bonzini <pbonzini@redhat.com>, Peter Maydell <peter.maydell@linaro.org>, "Michael S. Tsirkin" <mst@redhat.com>, Igor Mammedov <imammedo@redhat.com>, Ani Sinha <anisinha@redhat.com>, Shannon Zhao <shannon.zhaosl@gmail.com>, Marcel Apfelbaum <marcel.apfelbaum@gmail.com>, Alex Williamson <alex@shazbot.org>, "Cédric Le Goater" <clg@redhat.com>
There is a newer version of this series
[PATCH v8 18/37] hw/arm/virt: Set msi-gpa property
Posted by Shameer Kolothum 2 weeks, 4 days ago
Set the MSI doorbell GPA property for accelerated SMMUv3 devices for use
by KVM MSI setup. Also, since any meaningful use of vfio-pci devices with
an accelerated SMMUv3 requires both KVM and a kernel irqchip, ensure
those are specified when accel=on is selected.

Reviewed-by: Nicolin Chen <nicolinc@nvidia.com>
Tested-by: Eric Auger <eric.auger@redhat.com>
Tested-by: Zhangfei Gao <zhangfei.gao@linaro.org>
Signed-off-by: Shameer Kolothum <skolothumtho@nvidia.com>
---
 hw/arm/virt.c | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/hw/arm/virt.c b/hw/arm/virt.c
index 4badc1a734..1bbc5d94db 100644
--- a/hw/arm/virt.c
+++ b/hw/arm/virt.c
@@ -3061,6 +3061,26 @@ static void virt_machine_device_pre_plug_cb(HotplugHandler *hotplug_dev,
             object_property_set_link(OBJECT(dev), "secure-memory",
                                      OBJECT(vms->secure_sysmem), NULL);
         }
+        if (object_property_find(OBJECT(dev), "accel") &&
+            object_property_get_bool(OBJECT(dev), "accel", &error_abort)) {
+            hwaddr db_start = 0;
+
+            if (!kvm_enabled() || !kvm_irqchip_in_kernel()) {
+                error_setg(errp, "SMMUv3 accel=on requires KVM with "
+                           "kernel-irqchip=on support");
+                    return;
+            }
+
+            if (vms->msi_controller == VIRT_MSI_CTRL_ITS) {
+                /* GITS_TRANSLATER page + offset */
+                db_start = base_memmap[VIRT_GIC_ITS].base + 0x10000 + 0x40;
+            } else if (vms->msi_controller == VIRT_MSI_CTRL_GICV2M) {
+                /* MSI_SETSPI_NS page + offset */
+                db_start = base_memmap[VIRT_GIC_V2M].base + 0x40;
+            }
+            object_property_set_uint(OBJECT(dev), "msi-gpa", db_start,
+                                     &error_abort);
+        }
     }
 }
 
-- 
2.43.0
Re: [PATCH v8 18/37] hw/arm/virt: Set msi-gpa property
Posted by Jonathan Cameron via qemu development 2 weeks, 2 days ago
On Wed, 21 Jan 2026 17:52:23 +0000
Shameer Kolothum <skolothumtho@nvidia.com> wrote:

> Set the MSI doorbell GPA property for accelerated SMMUv3 devices for use
> by KVM MSI setup. Also, since any meaningful use of vfio-pci devices with
> an accelerated SMMUv3 requires both KVM and a kernel irqchip, ensure
> those are specified when accel=on is selected.
> 
> Reviewed-by: Nicolin Chen <nicolinc@nvidia.com>
> Tested-by: Eric Auger <eric.auger@redhat.com>
> Tested-by: Zhangfei Gao <zhangfei.gao@linaro.org>
> Signed-off-by: Shameer Kolothum <skolothumtho@nvidia.com>

Formatting issue I think. With that fixed up
Reviewed-by: Jonathan Cameron <jonathan.cameron@huawei.com>

> ---
>  hw/arm/virt.c | 20 ++++++++++++++++++++
>  1 file changed, 20 insertions(+)
> 
> diff --git a/hw/arm/virt.c b/hw/arm/virt.c
> index 4badc1a734..1bbc5d94db 100644
> --- a/hw/arm/virt.c
> +++ b/hw/arm/virt.c
> @@ -3061,6 +3061,26 @@ static void virt_machine_device_pre_plug_cb(HotplugHandler *hotplug_dev,
>              object_property_set_link(OBJECT(dev), "secure-memory",
>                                       OBJECT(vms->secure_sysmem), NULL);
>          }
> +        if (object_property_find(OBJECT(dev), "accel") &&
> +            object_property_get_bool(OBJECT(dev), "accel", &error_abort)) {
> +            hwaddr db_start = 0;
> +
> +            if (!kvm_enabled() || !kvm_irqchip_in_kernel()) {
> +                error_setg(errp, "SMMUv3 accel=on requires KVM with "
> +                           "kernel-irqchip=on support");
> +                    return;
What happened here width indent?

> +            }
> +
> +            if (vms->msi_controller == VIRT_MSI_CTRL_ITS) {
> +                /* GITS_TRANSLATER page + offset */
> +                db_start = base_memmap[VIRT_GIC_ITS].base + 0x10000 + 0x40;
> +            } else if (vms->msi_controller == VIRT_MSI_CTRL_GICV2M) {
> +                /* MSI_SETSPI_NS page + offset */
> +                db_start = base_memmap[VIRT_GIC_V2M].base + 0x40;
> +            }
> +            object_property_set_uint(OBJECT(dev), "msi-gpa", db_start,
> +                                     &error_abort);
> +        }
>      }
>  }
>