From 0e5c919397ad255442844472573ef50188e3e53c Mon Sep 17 00:00:00 2001
From: Menno Lageman
Date: Thu, 4 Jun 2020 09:42:42 +0200
Subject: [PATCH] conf: add address width attribute to iommu
Add a new aw_bits attribute to the iommu device to control
the address width of the intel-iommu
Signed-off-by Menno Lageman
Signed-off-by: Michal Privoznik
Reviewed-by: Michal Privoznik
---
docs/formatdomain.html.in | 9 +++++
docs/schemas/domaincommon.rng | 5 +++
src/conf/domain_conf.c | 21 +++++++++++
src/conf/domain_conf.h | 1 +
.../qemuxml2argvdata/intel-iommu-aw-bits.xml | 35 +++++++++++++++++++
.../intel-iommu-aw-bits.x86_64-latest.xml | 1 +
tests/qemuxml2xmltest.c | 1 +
7 files changed, 73 insertions(+)
create mode 100644 tests/qemuxml2argvdata/intel-iommu-aw-bits.xml
create mode 120000 tests/qemuxml2xmloutdata/intel-iommu-aw-bits.x86_64-latest.xml
diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
index 07d0fa5c70..83f0008640 100644
--- a/docs/formatdomain.html.in
+++ b/docs/formatdomain.html.in
@@ -9377,6 +9377,15 @@ qemu-kvm -net nic,model=? /dev/null
Since 3.5.0 (QEMU/KVM only)
+ aw_bits
+
+
+ The aw_bits
attribute can be used to set
+ the address width to allow mapping larger iova addresses
+ in the guest.
+ Since 6.5.0 (QEMU/KVM only)
+
+
diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
index e3bf7f5d55..2e65340311 100644
--- a/docs/schemas/domaincommon.rng
+++ b/docs/schemas/domaincommon.rng
@@ -4749,6 +4749,11 @@
+
+
+
+
+
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index e9336fd72d..ef083d4d4d 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -16905,6 +16905,15 @@ virDomainIOMMUDefParseXML(xmlNodePtr node,
}
iommu->eim = val;
}
+
+ VIR_FREE(tmp);
+ if ((tmp = virXMLPropString(driver, "aw_bits"))) {
+ if (virStrToLong_ui(tmp, NULL, 10, &iommu->aw_bits) < 0) {
+ virReportError(VIR_ERR_XML_ERROR, _("unknown aw_bits value: %s"), tmp);
+ return NULL;
+ }
+ }
+
}
return g_steal_pointer(&iommu);
@@ -23989,6 +23998,14 @@ virDomainIOMMUDefCheckABIStability(virDomainIOMMUDefPtr src,
virTristateSwitchTypeToString(src->iotlb));
return false;
}
+ if (src->aw_bits != dst->aw_bits) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+ _("Target domain IOMMU device aw_bits value '%d' "
+ "does not match source '%d'"),
+ dst->aw_bits, src->aw_bits);
+ return false;
+ }
+
return true;
}
@@ -28992,6 +29009,10 @@ virDomainIOMMUDefFormat(virBufferPtr buf,
virBufferAsprintf(&driverAttrBuf, " iotlb='%s'",
virTristateSwitchTypeToString(iommu->iotlb));
}
+ if (iommu->aw_bits > 0) {
+ virBufferAsprintf(&driverAttrBuf, " aw_bits='%d'",
+ iommu->aw_bits);
+ }
virXMLFormatElement(&childBuf, "driver", &driverAttrBuf, NULL);
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index 41715c75f2..bfafd36be3 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -2454,6 +2454,7 @@ struct _virDomainIOMMUDef {
virTristateSwitch caching_mode;
virTristateSwitch eim;
virTristateSwitch iotlb;
+ unsigned int aw_bits;
};
typedef enum {
diff --git a/tests/qemuxml2argvdata/intel-iommu-aw-bits.xml b/tests/qemuxml2argvdata/intel-iommu-aw-bits.xml
new file mode 100644
index 0000000000..23e3ef5816
--- /dev/null
+++ b/tests/qemuxml2argvdata/intel-iommu-aw-bits.xml
@@ -0,0 +1,35 @@
+
+ QEMUGuest1
+ c7a5fdbd-edaf-9455-926a-d65c16db1809
+ 219100
+ 219100
+ 1
+
+ hvm
+
+
+
+
+
+
+ qemu64
+
+
+ destroy
+ restart
+ destroy
+
+ /usr/bin/qemu-system-x86_64
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/tests/qemuxml2xmloutdata/intel-iommu-aw-bits.x86_64-latest.xml b/tests/qemuxml2xmloutdata/intel-iommu-aw-bits.x86_64-latest.xml
new file mode 120000
index 0000000000..dbd1dfd97a
--- /dev/null
+++ b/tests/qemuxml2xmloutdata/intel-iommu-aw-bits.x86_64-latest.xml
@@ -0,0 +1 @@
+../qemuxml2argvdata/intel-iommu-aw-bits.xml
\ No newline at end of file
diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c
index 2b61a6459e..e16ff44ef7 100644
--- a/tests/qemuxml2xmltest.c
+++ b/tests/qemuxml2xmltest.c
@@ -1323,6 +1323,7 @@ mymain(void)
DO_TEST_CAPS_LATEST("intel-iommu-caching-mode");
DO_TEST_CAPS_LATEST("intel-iommu-eim");
DO_TEST_CAPS_LATEST("intel-iommu-device-iotlb");
+ DO_TEST_CAPS_LATEST("intel-iommu-aw-bits");
DO_TEST_CAPS_ARCH_LATEST("iommu-smmuv3", "aarch64");
DO_TEST("cpu-check-none", NONE);
--
GitLab