File xsa321-1.patch of Package xen.25143

From: Jan Beulich <jbeulich@suse.com>
Subject: vtd: improve IOMMU TLB flush

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>

--- a/xen/drivers/passthrough/vtd/iommu.c
+++ b/xen/drivers/passthrough/vtd/iommu.c
@@ -582,7 +582,8 @@ static void __intel_iommu_iotlb_flush(st
         if ( iommu_domid == -1 )
             continue;
 
-        if ( page_count != 1 || gfn == INVALID_GFN )
+        if ( !page_count || (page_count & (page_count - 1)) ||
+             gfn == INVALID_GFN || !IS_ALIGNED(gfn, page_count) )
         {
             if ( iommu_flush_iotlb_dsi(iommu, iommu_domid,
                         0, flush_dev_iotlb) )
@@ -591,7 +592,8 @@ static void __intel_iommu_iotlb_flush(st
         else
         {
             if ( iommu_flush_iotlb_psi(iommu, iommu_domid,
-                        (paddr_t)gfn << PAGE_SHIFT_4K, PAGE_ORDER_4K,
+                        (paddr_t)gfn << PAGE_SHIFT_4K,
+                        get_order_from_pages(page_count),
                         !dma_old_pte_present, flush_dev_iotlb) )
                 iommu_flush_write_buffer(iommu);
         }
openSUSE Build Service is sponsored by