]> xenbits.xensource.com Git - libvirt.git/commitdiff
conf: add address width attribute to iommu
authorMenno Lageman <menno.lageman@oracle.com>
Thu, 4 Jun 2020 07:42:42 +0000 (09:42 +0200)
committerMichal Privoznik <mprivozn@redhat.com>
Tue, 23 Jun 2020 13:51:49 +0000 (15:51 +0200)
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@oracle.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
docs/formatdomain.html.in
docs/schemas/domaincommon.rng
src/conf/domain_conf.c
src/conf/domain_conf.h
tests/qemuxml2argvdata/intel-iommu-aw-bits.xml [new file with mode: 0644]
tests/qemuxml2xmloutdata/intel-iommu-aw-bits.x86_64-latest.xml [new symlink]
tests/qemuxml2xmltest.c

index 07d0fa5c70b3ccad864e8d5ac3167ec1377a4011..83f00086406c8d3840fc2942f537e165bc61115d 100644 (file)
@@ -9377,6 +9377,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 6.5.0</span> (QEMU/KVM only)
+            </p>
+          </dd>
         </dl>
       </dd>
     </dl>
index e3bf7f5d5585de9ebbcc186499ff5aa70279a5f3..2e65340311beb0ebdb145803bab5e9c218cd7dc4 100644 (file)
               <ref name="virOnOff"/>
             </attribute>
           </optional>
+          <optional>
+            <attribute name="aw_bits">
+              <ref name="uint8"/>
+            </attribute>
+          </optional>
         </element>
       </optional>
     </element>
index e9336fd72d791f5ad090617ef15b4f86655e1db1..ef083d4d4da3b02967b130fe6cf02807ba3857cc 100644 (file)
@@ -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);
 
index 41715c75f2733af5bf58293c859385e28bce7328..bfafd36be31f8a037b624d06f2c55b589bfbce1e 100644 (file)
@@ -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 (file)
index 0000000..23e3ef5
--- /dev/null
@@ -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 (symlink)
index 0000000..dbd1dfd
--- /dev/null
@@ -0,0 +1 @@
+../qemuxml2argvdata/intel-iommu-aw-bits.xml
\ No newline at end of file
index 2b61a6459e2731bd683d4515ce34c128b4dc5ef5..e16ff44ef7b9bf87100bc024c780adcc5d7a9568 100644 (file)
@@ -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);