]> xenbits.xensource.com Git - xen.git/commitdiff
AMD/IOMMU: consider hidden devices when flushing device I/O TLBs
authorJan Beulich <jbeulich@suse.com>
Tue, 12 Oct 2021 09:54:34 +0000 (11:54 +0200)
committerJan Beulich <jbeulich@suse.com>
Tue, 12 Oct 2021 09:54:34 +0000 (11:54 +0200)
Hidden devices are associated with DomXEN but usable by the
hardware domain. Hence they need flushing as well when all devices are
to have flushes invoked.

While there drop a redundant ATS-enabled check and constify the first
parameter of the involved function.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Paul Durrant <paul@xen.org>
xen/drivers/passthrough/amd/iommu_cmd.c

index 4db8e1651fde9ca94941439ca38fce12ef0cff22..a73830386bf47d514f5cbc4670b2c85b80e3f113 100644 (file)
@@ -308,14 +308,11 @@ void amd_iommu_flush_iotlb(u8 devfn, const struct pci_dev *pdev,
     flush_command_buffer(iommu, iommu_dev_iotlb_timeout);
 }
 
-static void amd_iommu_flush_all_iotlbs(struct domain *d, daddr_t daddr,
+static void amd_iommu_flush_all_iotlbs(const struct domain *d, daddr_t daddr,
                                        unsigned int order)
 {
     struct pci_dev *pdev;
 
-    if ( !ats_enabled )
-        return;
-
     for_each_pdev( d, pdev )
     {
         u8 devfn = pdev->devfn;
@@ -343,7 +340,16 @@ static void _amd_iommu_flush_pages(struct domain *d,
     }
 
     if ( ats_enabled )
+    {
         amd_iommu_flush_all_iotlbs(d, daddr, order);
+
+        /*
+         * Hidden devices are associated with DomXEN but usable by the
+         * hardware domain. Hence they need dealing with here as well.
+         */
+        if ( is_hardware_domain(d) )
+            amd_iommu_flush_all_iotlbs(dom_xen, daddr, order);
+    }
 }
 
 void amd_iommu_flush_all_pages(struct domain *d)