From: Nathan Chen <nathanc@nvidia.com> Introduce support for a "cmdqv" IOMMU attribute which enables NVIDIA Tegra241 CMDQV, an extension for ARM SMMUv3. This supports passthrough of physical SMMU-CMDQ linked command queue from host space to a VM. Signed-off-by: Nathan Chen <nathanc@nvidia.com> --- docs/formatdomain.rst | 6 ++++++ src/conf/domain_conf.c | 15 +++++++++++++++ src/conf/domain_conf.h | 1 + src/conf/domain_validate.c | 5 ++++- src/conf/schemas/domaincommon.rng | 5 +++++ src/qemu/qemu_command.c | 1 + 6 files changed, 32 insertions(+), 1 deletion(-) diff --git a/docs/formatdomain.rst b/docs/formatdomain.rst index 9f245293e6..5e0c7a8ea4 100644 --- a/docs/formatdomain.rst +++ b/docs/formatdomain.rst @@ -9366,6 +9366,12 @@ Examples: The ``pciBus`` attribute notes the index of the controller that an IOMMU device is attached to. (QEMU/KVM and ``smmuv3`` model only) + ``cmdqv`` + The ``cmdqv`` attribute with possible values ``on`` and ``off`` can be used + to enable NVIDIA Tegra241 CMDQV, an extension for ARM SMMUv3 that supports + passthrough of physical SMMU-CMDQ linked command queue from host space to VM. + :since:`Since 12.1.0` (QEMU/KVM and ``smmuv3`` model only) + In case of ``virtio`` IOMMU device, the ``driver`` element can optionally contain ``granule`` subelement that allows to choose which granule will be used by default. It is useful when running guests with different page size diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 8090becdcf..693af1b518 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -14721,6 +14721,10 @@ virDomainIOMMUDefParseXML(virDomainXMLOption *xmlopt, &iommu->pci_bus, -1) < 0) return NULL; + if (virXMLPropTristateSwitch(driver, "cmdqv", VIR_XML_PROP_NONE, + &iommu->cmdqv) < 0) + return NULL; + if ((granule = virXPathNode("./driver/granule", ctxt))) { g_autofree char *mode = virXMLPropString(granule, "mode"); unsigned long long size; @@ -16824,6 +16828,7 @@ virDomainIOMMUDefEquals(const virDomainIOMMUDef *a, a->iotlb != b->iotlb || a->aw_bits != b->aw_bits || a->dma_translation != b->dma_translation || + a->cmdqv != b->cmdqv || a->granule != b->granule) return false; @@ -22604,6 +22609,12 @@ virDomainIOMMUDefCheckABIStability(virDomainIOMMUDef *src, dst->pci_bus, src->pci_bus); return false; } + if (src->cmdqv != dst->cmdqv) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("Target domain IOMMU device cmdqv value '%1$d' does not match source '%2$d'"), + dst->cmdqv, src->cmdqv); + return false; + } if (src->dma_translation != dst->dma_translation) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("Target domain IOMMU device dma translation '%1$s' does not match source '%2$s'"), @@ -29022,6 +29033,10 @@ virDomainIOMMUDefFormat(virBuffer *buf, virBufferAsprintf(&driverAttrBuf, " pciBus='%d'", iommu->pci_bus); } + if (iommu->cmdqv != VIR_TRISTATE_SWITCH_ABSENT) { + virBufferAsprintf(&driverAttrBuf, " cmdqv='%s'", + virTristateSwitchTypeToString(iommu->cmdqv)); + } if (iommu->granule != 0) { if (iommu->granule == -1) { virBufferAddLit(&driverChildBuf, "<granule mode='host'/>\n"); diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index e63230beec..d796d17947 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -3084,6 +3084,7 @@ struct _virDomainIOMMUDef { virTristateSwitch xtsup; virTristateSwitch pt; int granule; /* -1 means 'host', 0 unset, page size in KiB otherwise */ + virTristateSwitch cmdqv; }; typedef enum { diff --git a/src/conf/domain_validate.c b/src/conf/domain_validate.c index 7e3da84767..bcd12bb705 100644 --- a/src/conf/domain_validate.c +++ b/src/conf/domain_validate.c @@ -3186,7 +3186,8 @@ virDomainIOMMUDefValidate(const virDomainIOMMUDef *iommu) iommu->eim != VIR_TRISTATE_SWITCH_ABSENT || iommu->iotlb != VIR_TRISTATE_SWITCH_ABSENT || iommu->dma_translation != VIR_TRISTATE_SWITCH_ABSENT || - iommu->pci_bus >= 0) { + iommu->pci_bus >= 0 || + iommu->cmdqv != VIR_TRISTATE_SWITCH_ABSENT) { virReportError(VIR_ERR_XML_ERROR, _("iommu model '%1$s' doesn't support some additional attributes"), virDomainIOMMUModelTypeToString(iommu->model)); @@ -3209,6 +3210,7 @@ virDomainIOMMUDefValidate(const virDomainIOMMUDef *iommu) iommu->aw_bits != 0 || iommu->dma_translation != VIR_TRISTATE_SWITCH_ABSENT || iommu->pci_bus >= 0 || + iommu->cmdqv != VIR_TRISTATE_SWITCH_ABSENT || iommu->granule != 0) { virReportError(VIR_ERR_XML_ERROR, _("iommu model '%1$s' doesn't support some additional attributes"), @@ -3221,6 +3223,7 @@ virDomainIOMMUDefValidate(const virDomainIOMMUDef *iommu) if (iommu->pt != VIR_TRISTATE_SWITCH_ABSENT || iommu->xtsup != VIR_TRISTATE_SWITCH_ABSENT || iommu->pci_bus >= 0 || + iommu->cmdqv != VIR_TRISTATE_SWITCH_ABSENT || iommu->granule != 0) { virReportError(VIR_ERR_XML_ERROR, _("iommu model '%1$s' doesn't support some additional attributes"), diff --git a/src/conf/schemas/domaincommon.rng b/src/conf/schemas/domaincommon.rng index 376218118d..5540ed7b5b 100644 --- a/src/conf/schemas/domaincommon.rng +++ b/src/conf/schemas/domaincommon.rng @@ -6376,6 +6376,11 @@ <data type="unsignedInt"/> </attribute> </optional> + <optional> + <attribute name="cmdqv"> + <ref name="virOnOff"/> + </attribute> + </optional> <optional> <element name="granule"> <choice> diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index d0df7b7826..57370153ce 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -6330,6 +6330,7 @@ qemuBuildPCINestedSmmuv3DevProps(const virDomainDef *def, "s:driver", "arm-smmuv3", "s:primary-bus", bus, "s:id", iommu->info.alias, + "S:cmdqv", qemuOnOffAuto(iommu->cmdqv), NULL) < 0) return NULL; -- 2.43.0