From: Michal Privoznik <[email protected]> Introduced in QEMU commit of v9.0.0-rc0~9^2~7 the virtio-iommu device is also capable of using different addres width. The corresponding attribute is also called 'aw-bits', just like in case of intel-iommu. Wire up the missing pieces.
Signed-off-by: Michal Privoznik <[email protected]> --- docs/formatdomain.rst | 2 +- src/conf/domain_validate.c | 9 +++++++-- src/qemu/qemu_validate.c | 7 +++++-- .../virtio-iommu-aarch64.aarch64-latest.xml | 1 + tests/qemuxmlconfdata/virtio-iommu-aarch64.xml | 4 +++- .../virtio-iommu-dma-translation.x86_64-latest.err | 2 +- 6 files changed, 18 insertions(+), 7 deletions(-) diff --git a/docs/formatdomain.rst b/docs/formatdomain.rst index 04ef319a73..4b34a8a963 100644 --- a/docs/formatdomain.rst +++ b/docs/formatdomain.rst @@ -9243,7 +9243,7 @@ Example: ``aw_bits`` The ``aw_bits`` attribute can be used to set the address width to allow mapping larger iova addresses in the guest. :since:`Since 6.5.0` (QEMU/KVM - and ``intel`` model only) + and ``intel`` or ``virtio`` models only) ``dma_translation`` The ``dma_translation`` attribute with possible values ``on`` and ``off`` can diff --git a/src/conf/domain_validate.c b/src/conf/domain_validate.c index 4482203087..440f23d726 100644 --- a/src/conf/domain_validate.c +++ b/src/conf/domain_validate.c @@ -3206,14 +3206,19 @@ virDomainIOMMUDefValidate(const virDomainIOMMUDef *iommu) iommu->caching_mode != VIR_TRISTATE_SWITCH_ABSENT || iommu->eim != VIR_TRISTATE_SWITCH_ABSENT || iommu->iotlb != VIR_TRISTATE_SWITCH_ABSENT || - iommu->aw_bits != 0 || iommu->dma_translation != VIR_TRISTATE_SWITCH_ABSENT || iommu->pci_bus >= 0) { virReportError(VIR_ERR_XML_ERROR, - _("iommu model '%1$s' doesn't support additional attributes"), + _("iommu model '%1$s' doesn't support some additional attributes"), virDomainIOMMUModelTypeToString(iommu->model)); return -1; } + + if (iommu->aw_bits != 0 && (iommu->aw_bits < 32 || iommu->aw_bits > 64)) { + virReportError(VIR_ERR_XML_ERROR, "%s", + _("aw-bits must be within [32,64]")); + return -1; + } break; case VIR_DOMAIN_IOMMU_MODEL_AMD: diff --git a/src/qemu/qemu_validate.c b/src/qemu/qemu_validate.c index 184c23d307..ab8a1938c1 100644 --- a/src/qemu/qemu_validate.c +++ b/src/qemu/qemu_validate.c @@ -5551,6 +5551,8 @@ qemuValidateDomainDeviceDefIOMMU(const virDomainIOMMUDef *iommu, const virDomainDef *def, virQEMUCaps *qemuCaps) { + bool aw_bits_supported = false; + switch (iommu->model) { case VIR_DOMAIN_IOMMU_MODEL_INTEL: if (!qemuDomainIsQ35(def)) { @@ -5565,6 +5567,7 @@ qemuValidateDomainDeviceDefIOMMU(const virDomainIOMMUDef *iommu, virDomainIOMMUModelTypeToString(iommu->model)); return -1; } + aw_bits_supported = virQEMUCapsGet(qemuCaps, QEMU_CAPS_INTEL_IOMMU_AW_BITS); break; case VIR_DOMAIN_IOMMU_MODEL_SMMUV3: @@ -5610,6 +5613,7 @@ qemuValidateDomainDeviceDefIOMMU(const virDomainIOMMUDef *iommu, virDomainIOMMUModelTypeToString(iommu->model)); return -1; } + aw_bits_supported = virQEMUCapsGet(qemuCaps, QEMU_CAPS_VIRTIO_IOMMU_AW_BITS); break; case VIR_DOMAIN_IOMMU_MODEL_AMD: @@ -5669,8 +5673,7 @@ qemuValidateDomainDeviceDefIOMMU(const virDomainIOMMUDef *iommu, _("iommu: device IOTLB is not supported with this QEMU binary")); return -1; } - if (iommu->aw_bits > 0 && - !virQEMUCapsGet(qemuCaps, QEMU_CAPS_INTEL_IOMMU_AW_BITS)) { + if (iommu->aw_bits > 0 && !aw_bits_supported) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", _("iommu: aw_bits is not supported with this QEMU binary")); return -1; diff --git a/tests/qemuxmlconfdata/virtio-iommu-aarch64.aarch64-latest.xml b/tests/qemuxmlconfdata/virtio-iommu-aarch64.aarch64-latest.xml index 3cb794cbc9..4ae628ab5a 100644 --- a/tests/qemuxmlconfdata/virtio-iommu-aarch64.aarch64-latest.xml +++ b/tests/qemuxmlconfdata/virtio-iommu-aarch64.aarch64-latest.xml @@ -29,6 +29,7 @@ <audio id='1' type='none'/> <memballoon model='none'/> <iommu model='virtio'> + <driver aw_bits='48'/> <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x0'/> </iommu> </devices> diff --git a/tests/qemuxmlconfdata/virtio-iommu-aarch64.xml b/tests/qemuxmlconfdata/virtio-iommu-aarch64.xml index 8d252bfcf9..96e5ea05ae 100644 --- a/tests/qemuxmlconfdata/virtio-iommu-aarch64.xml +++ b/tests/qemuxmlconfdata/virtio-iommu-aarch64.xml @@ -13,6 +13,8 @@ <emulator>/usr/bin/qemu-system-aarch64</emulator> <controller type='usb' model='none'/> <memballoon model='none'/> - <iommu model='virtio'/> + <iommu model='virtio'> + <driver aw_bits='48'/> + </iommu> </devices> </domain> diff --git a/tests/qemuxmlconfdata/virtio-iommu-dma-translation.x86_64-latest.err b/tests/qemuxmlconfdata/virtio-iommu-dma-translation.x86_64-latest.err index 2c3a272725..f4405a9b7d 100644 --- a/tests/qemuxmlconfdata/virtio-iommu-dma-translation.x86_64-latest.err +++ b/tests/qemuxmlconfdata/virtio-iommu-dma-translation.x86_64-latest.err @@ -1 +1 @@ -XML error: iommu model 'virtio' doesn't support additional attributes +XML error: iommu model 'virtio' doesn't support some additional attributes -- 2.52.0
