]> xenbits.xensource.com Git - people/sstabellini/xen-unstable.git/.git/commitdiff
vtd: improve IOMMU TLB flush
authorJan Beulich <jbeulich@suse.com>
Tue, 7 Jul 2020 12:37:46 +0000 (14:37 +0200)
committerJan Beulich <jbeulich@suse.com>
Tue, 7 Jul 2020 12:37:46 +0000 (14:37 +0200)
Do not limit PSI flushes to order 0 pages, in order to avoid doing a
full TLB flush if the passed in page has an order greater than 0 and
is aligned. Should increase the performance of IOMMU TLB flushes when
dealing with page orders greater than 0.

This is part of XSA-321.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Roger Pau Monné <roger.pau@citrix.com>
xen/drivers/passthrough/vtd/iommu.c

index 208b33c0e4703d568482d14eeca98c45c1ee7904..dcc9b7a35ed4d67e63512f48fcf0d14b309cf51c 100644 (file)
@@ -576,13 +576,14 @@ static int __must_check iommu_flush_iotlb(struct domain *d, dfn_t dfn,
         if ( iommu_domid == -1 )
             continue;
 
-        if ( page_count != 1 || dfn_eq(dfn, INVALID_DFN) )
+        if ( !page_count || (page_count & (page_count - 1)) ||
+             dfn_eq(dfn, INVALID_DFN) || !IS_ALIGNED(dfn_x(dfn), page_count) )
             rc = iommu_flush_iotlb_dsi(iommu, iommu_domid,
                                        0, flush_dev_iotlb);
         else
             rc = iommu_flush_iotlb_psi(iommu, iommu_domid,
                                        dfn_to_daddr(dfn),
-                                       PAGE_ORDER_4K,
+                                       get_order_from_pages(page_count),
                                        !dma_old_pte_present,
                                        flush_dev_iotlb);