]> xenbits.xensource.com Git - xen.git/commitdiff
IOMMU/EPT: avoid double flushing in shared page table case
authorJan Beulich <jbeulich@suse.com>
Fri, 23 Oct 2020 08:06:53 +0000 (10:06 +0200)
committerJan Beulich <jbeulich@suse.com>
Fri, 23 Oct 2020 08:06:53 +0000 (10:06 +0200)
While the flush coalescing optimization has been helping the non-shared
case, it has actually lead to double flushes in the shared case (which
ought to be the more common one nowadays at least): Once from
*_set_entry() and a second time up the call tree from wherever the
overriding flag gets played with. In alignment with XSA-346 suppress
flushing in this case.

Similarly avoid excessive setting of IOMMU_FLUSHF_added on the batched
flushes: "idx" hasn't been added a new mapping for.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Kevin Tian <kevin.tian@intel.com>
xen/arch/x86/mm/p2m-ept.c
xen/common/memory.c

index 12cf38f6eb8fbcb4350a2b4ad938c90f5340ed5c..476458b1e0b699de569df9dee676c0107d310739 100644 (file)
@@ -842,7 +842,7 @@ out:
     if ( rc == 0 && p2m_is_hostp2m(p2m) &&
          need_modify_vtd_table )
     {
-        if ( iommu_use_hap_pt(d) )
+        if ( iommu_use_hap_pt(d) && !this_cpu(iommu_dont_flush_iotlb) )
             rc = iommu_iotlb_flush(d, _dfn(gfn), 1ul << order,
                                    (iommu_flags ? IOMMU_FLUSHF_added : 0) |
                                    (vtd_pte_present ? IOMMU_FLUSHF_modified
index 7075e233aaa18aa7795b208560c213e6fc98e9e1..df85b550a1b17baa18da0d30f3c4d539b4716c43 100644 (file)
@@ -870,7 +870,7 @@ int xenmem_add_to_physmap(struct domain *d, struct xen_add_to_physmap *xatp,
         this_cpu(iommu_dont_flush_iotlb) = 0;
 
         ret = iommu_iotlb_flush(d, _dfn(xatp->idx - done), done,
-                                IOMMU_FLUSHF_added | IOMMU_FLUSHF_modified);
+                                IOMMU_FLUSHF_modified);
         if ( unlikely(ret) && rc >= 0 )
             rc = ret;