From: Nathan Chen <[email protected]>

The arm-smmuv3 accel device property, used for HW-accelerated nested
SMMUv3, was added in QEMU 11.0.0 on top of the pluggable device
introduced in 10.2. Probe it alongside smmu_per_bus via
device-list-properties.

Validate the domain iommu accel attribute in qemu_validate.c when
QEMU lacks this capability. Checking accel is sufficient because ats,
ril, ssidsize, and oas were introduced in the same QEMU release, and
it only makes sense to backport accel, ats, ril, ssidsize, and oas
all together.

Signed-off-by: Nathan Chen <[email protected]>
---
 src/qemu/qemu_capabilities.c                       |  2 ++
 src/qemu/qemu_capabilities.h                       |  1 +
 src/qemu/qemu_validate.c                           | 12 ++++++++++++
 tests/qemucapabilitiesdata/caps_11.0.0_aarch64.xml |  1 +
 tests/qemucapabilitiesdata/caps_11.1.0_aarch64.xml |  1 +
 5 files changed, 17 insertions(+)

diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
index c98023bbe2..db146688f6 100644
--- a/src/qemu/qemu_capabilities.c
+++ b/src/qemu/qemu_capabilities.c
@@ -768,6 +768,7 @@ VIR_ENUM_IMPL(virQEMUCaps,
               /* 495 */
               "blockdev-mirror.target-is-zero", /* 
QEMU_CAPS_BLOCKDEV_MIRROR_TARGET_IS_ZERO */
               "arm-smmuv3.smmu_per_bus", /* QEMU_CAPS_ARM_SMMUV3 */
+              "arm-smmuv3.accel", /* QEMU_CAPS_ARM_SMMUV3_ACCEL */
     );
 
 
@@ -1646,6 +1647,7 @@ static struct virQEMUCapsDevicePropsFlags 
virQEMUCapsDevicePropsAMDIOMMU[] = {
 
 static struct virQEMUCapsDevicePropsFlags virQEMUCapsDevicePropsArmSmmuv3[] = {
     { "smmu_per_bus", QEMU_CAPS_ARM_SMMUV3, NULL },
+    { "accel", QEMU_CAPS_ARM_SMMUV3_ACCEL, NULL },
 };
 
 /* see documentation for virQEMUQAPISchemaPathGet for the query format */
diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h
index c03c32389b..4efea95a8d 100644
--- a/src/qemu/qemu_capabilities.h
+++ b/src/qemu/qemu_capabilities.h
@@ -742,6 +742,7 @@ typedef enum { /* virQEMUCapsFlags grouping marker for 
syntax-check */
     /* 495 */
     QEMU_CAPS_BLOCKDEV_MIRROR_TARGET_IS_ZERO, /* 'blockdev-mirror' supports 
'target-is-zero' */
     QEMU_CAPS_ARM_SMMUV3, /* arm-smmuv3.smmu_per_bus */
+    QEMU_CAPS_ARM_SMMUV3_ACCEL, /* arm-smmuv3.accel */
 
     QEMU_CAPS_LAST /* this must always be the last item */
 } virQEMUCapsFlags;
diff --git a/src/qemu/qemu_validate.c b/src/qemu/qemu_validate.c
index 500b8ee680..0c7f2a0fc3 100644
--- a/src/qemu/qemu_validate.c
+++ b/src/qemu/qemu_validate.c
@@ -5826,6 +5826,18 @@ qemuValidateDomainDeviceDefIOMMU(const virDomainIOMMUDef 
*iommu,
         return -1;
     }
 
+    /* While QEMU_CAPS_ARM_SMMUV3_ACCEL tracks the .accel attribute of
+     * arm-smmuv3 it is also a good indicator of .ats, .ril, .ssidsize, and
+     * .oas attributes as all of them were introduced in the same release,
+     * and these features are meant to be backported all together. */
+    if (iommu->model == VIR_DOMAIN_IOMMU_MODEL_SMMUV3 &&
+        iommu->accel != VIR_TRISTATE_SWITCH_ABSENT &&
+        !virQEMUCapsGet(qemuCaps, QEMU_CAPS_ARM_SMMUV3_ACCEL)) {
+        virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+                       _("iommu: accel is not supported with this QEMU 
binary"));
+        return -1;
+    }
+
     if (iommu->granule > 0) {
         /* QEMU supports only 4KiB, 8KiB, 16KiB and 64KiB granule size */
         if (!(iommu->granule == 4 ||
diff --git a/tests/qemucapabilitiesdata/caps_11.0.0_aarch64.xml 
b/tests/qemucapabilitiesdata/caps_11.0.0_aarch64.xml
index b5f43d9be5..097e13fbe6 100644
--- a/tests/qemucapabilitiesdata/caps_11.0.0_aarch64.xml
+++ b/tests/qemucapabilitiesdata/caps_11.0.0_aarch64.xml
@@ -189,6 +189,7 @@
   <flag name='query-block-flat'/>
   <flag name='blockdev-mirror.target-is-zero'/>
   <flag name='arm-smmuv3.smmu_per_bus'/>
+  <flag name='arm-smmuv3.accel'/>
   <version>11000000</version>
   <microcodeVersion>61700286</microcodeVersion>
   <package>v11.0.0</package>
diff --git a/tests/qemucapabilitiesdata/caps_11.1.0_aarch64.xml 
b/tests/qemucapabilitiesdata/caps_11.1.0_aarch64.xml
index 28bf1aff57..76d03d3269 100644
--- a/tests/qemucapabilitiesdata/caps_11.1.0_aarch64.xml
+++ b/tests/qemucapabilitiesdata/caps_11.1.0_aarch64.xml
@@ -189,6 +189,7 @@
   <flag name='query-block-flat'/>
   <flag name='blockdev-mirror.target-is-zero'/>
   <flag name='arm-smmuv3.smmu_per_bus'/>
+  <flag name='arm-smmuv3.accel'/>
   <version>11000050</version>
   <microcodeVersion>61700287</microcodeVersion>
   <package>v11.0.0-1600-g5611a9268d</package>
-- 
2.43.0

Reply via email to