[PATCH 1/2] conf: add address width attribute to iommu

Menno Lageman menno.lageman at oracle.com
Thu Jun 4 07:42:42 UTC 2020


Add a new aw_bits attribute to the iommu device to control
the address width of the intel-iommu

Signed-off-by Menno Lageman <menno.lageman at oracle.com>
---
 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 33cec1e6dd9f..64d4100dcd92 100644
--- a/docs/formatdomain.html.in
+++ b/docs/formatdomain.html.in
@@ -9326,6 +9326,15 @@ qemu-kvm -net nic,model=? /dev/null
               <span class="since">Since 3.5.0</span> (QEMU/KVM only)
             </p>
           </dd>
+          <dt><code>aw_bits</code></dt>
+          <dd>
+            <p>
+              The <code>aw_bits</code> attribute can be used to set
+              the address width to allow mapping larger iova addresses
+              in the guest.
+              <span class="since">Since 2.12.2</span> (QEMU/KVM only)
+            </p>
+          </dd>
         </dl>
       </dd>
     </dl>
diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
index 6727cd743b7e..91addcbcee52 100644
--- a/docs/schemas/domaincommon.rng
+++ b/docs/schemas/domaincommon.rng
@@ -4749,6 +4749,11 @@
               <ref name="virOnOff"/>
             </attribute>
           </optional>
+          <optional>
+            <attribute name="aw_bits">
+              <ref name="uint8"/>
+            </attribute>
+          </optional>
         </element>
       </optional>
     </element>
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 1cdc7971fca6..9bae30152c0f 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -16814,6 +16814,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);
@@ -23891,6 +23900,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;
 }
 
@@ -28886,6 +28903,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 e152c599cac3..53c941364122 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 000000000000..23e3ef581677
--- /dev/null
+++ b/tests/qemuxml2argvdata/intel-iommu-aw-bits.xml
@@ -0,0 +1,35 @@
+<domain type='kvm'>
+  <name>QEMUGuest1</name>
+  <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
+  <memory unit='KiB'>219100</memory>
+  <currentMemory unit='KiB'>219100</currentMemory>
+  <vcpu placement='static'>1</vcpu>
+  <os>
+    <type arch='x86_64' machine='q35'>hvm</type>
+    <boot dev='hd'/>
+  </os>
+  <features>
+    <ioapic driver='qemu'/>
+  </features>
+  <cpu mode='custom' match='exact' check='none'>
+    <model fallback='forbid'>qemu64</model>
+  </cpu>
+  <clock offset='utc'/>
+  <on_poweroff>destroy</on_poweroff>
+  <on_reboot>restart</on_reboot>
+  <on_crash>destroy</on_crash>
+  <devices>
+    <emulator>/usr/bin/qemu-system-x86_64</emulator>
+    <controller type='pci' index='0' model='pcie-root'/>
+    <controller type='usb' index='0' model='none'/>
+    <controller type='sata' index='0'>
+      <address type='pci' domain='0x0000' bus='0x00' slot='0x1f' function='0x2'/>
+    </controller>
+    <input type='mouse' bus='ps2'/>
+    <input type='keyboard' bus='ps2'/>
+    <memballoon model='none'/>
+    <iommu model='intel'>
+      <driver intremap='on' aw_bits='48'/>
+    </iommu>
+  </devices>
+</domain>
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 000000000000..dbd1dfd97a66
--- /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 dcc7b29ded3e..81d5669293b1 100644
--- a/tests/qemuxml2xmltest.c
+++ b/tests/qemuxml2xmltest.c
@@ -1336,6 +1336,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);
-- 
2.26.2




More information about the libvir-list mailing list