Add dma_translation attribute to iommu to enable/disable dma traslation for intel-iommu Signed-off-by: Sandesh Patel <sandesh.patel@xxxxxxxxxxx> --- docs/formatdomain.rst | 7 +++++++ src/conf/domain_conf.c | 15 +++++++++++++++ src/conf/domain_conf.h | 1 + src/conf/schemas/domaincommon.rng | 5 +++++ 4 files changed, 28 insertions(+) diff --git a/docs/formatdomain.rst b/docs/formatdomain.rst index c56b739b23..a037ab65e4 100644 --- a/docs/formatdomain.rst +++ b/docs/formatdomain.rst @@ -8611,6 +8611,13 @@ Example: mapping larger iova addresses in the guest. :since:`Since 6.5.0` (QEMU/KVM only) + ``dma_translation`` + The ``dma_translation`` attribute with possible values ``on`` and ``off`` can + be used to turn off the dma translation for IOMMU. It is useful when only + interrupt remapping is required but dma translation overhead is unwanted, for + example to efficiently enable more than 255 vCPUs. + :since:`Since 10.6.1` (QEMU/KVM only) + The ``virtio`` IOMMU devices can further have ``address`` element as described in `Device addresses`_ (address has to by type of ``pci``). diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 86b563fbfb..d950921667 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -13931,6 +13931,10 @@ virDomainIOMMUDefParseXML(virDomainXMLOption *xmlopt, if (virXMLPropUInt(driver, "aw_bits", 10, VIR_XML_PROP_NONE, &iommu->aw_bits) < 0) return NULL; + + if (virXMLPropTristateSwitch(driver, "dma_translation", VIR_XML_PROP_NONE, + &iommu->dma_translation) < 0) + return NULL; } if (virDomainDeviceInfoParseXML(xmlopt, node, ctxt, @@ -21467,6 +21471,13 @@ virDomainIOMMUDefCheckABIStability(virDomainIOMMUDef *src, dst->aw_bits, src->aw_bits); 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'"), + virTristateSwitchTypeToString(dst->dma_translation), + virTristateSwitchTypeToString(src->dma_translation)); + return false; + } return virDomainDeviceInfoCheckABIStability(&src->info, &dst->info); } @@ -27451,6 +27462,10 @@ virDomainIOMMUDefFormat(virBuffer *buf, virBufferAsprintf(&driverAttrBuf, " aw_bits='%d'", iommu->aw_bits); } + if (iommu->dma_translation != VIR_TRISTATE_SWITCH_ABSENT) { + virBufferAsprintf(&driverAttrBuf, " dma_translation='%s'", + virTristateSwitchTypeToString(iommu->dma_translation)); + } virXMLFormatElement(&childBuf, "driver", &driverAttrBuf, NULL); diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 95ddf5470e..eae621f900 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -2928,6 +2928,7 @@ struct _virDomainIOMMUDef { virTristateSwitch iotlb; unsigned int aw_bits; virDomainDeviceInfo info; + virTristateSwitch dma_translation; }; typedef enum { diff --git a/src/conf/schemas/domaincommon.rng b/src/conf/schemas/domaincommon.rng index 7d58dce465..05ba697924 100644 --- a/src/conf/schemas/domaincommon.rng +++ b/src/conf/schemas/domaincommon.rng @@ -6100,6 +6100,11 @@ <ref name="uint8"/> </attribute> </optional> + <optional> + <attribute name="dma_translation"> + <ref name="virOnOff"/> + </attribute> + </optional> </element> </optional> <optional> -- 2.22.3