@@ -274,6 +274,10 @@ int iommu_map(struct domain *d, dfn_t dfn, mfn_t mfn,
break;
}
+ /* Something went wrong so flush everything and clear flush flags */
+ if ( unlikely(rc) && iommu_iotlb_flush_all(d, *flush_flags) )
+ flush_flags = 0;
+
return rc;
}
@@ -283,14 +287,8 @@ int iommu_legacy_map(struct domain *d, dfn_t dfn, mfn_t mfn,
unsigned int flush_flags = 0;
int rc = iommu_map(d, dfn, mfn, page_order, flags, &flush_flags);
- if ( !this_cpu(iommu_dont_flush_iotlb) )
- {
- int err = iommu_iotlb_flush(d, dfn, (1u << page_order),
- flush_flags);
-
- if ( !rc )
- rc = err;
- }
+ if ( !this_cpu(iommu_dont_flush_iotlb) && !rc )
+ rc = iommu_iotlb_flush(d, dfn, (1u << page_order), flush_flags);
return rc;
}
@@ -330,6 +328,10 @@ int iommu_unmap(struct domain *d, dfn_t dfn, unsigned int page_order,
}
}
+ /* Something went wrong so flush everything and clear flush flags */
+ if ( unlikely(rc) && iommu_iotlb_flush_all(d, *flush_flags) )
+ flush_flags = 0;
+
return rc;
}
@@ -338,14 +340,8 @@ int iommu_legacy_unmap(struct domain *d, dfn_t dfn, unsigned int page_order)
unsigned int flush_flags = 0;
int rc = iommu_unmap(d, dfn, page_order, &flush_flags);
- if ( !this_cpu(iommu_dont_flush_iotlb) )
- {
- int err = iommu_iotlb_flush(d, dfn, (1u << page_order),
- flush_flags);
-
- if ( !rc )
- rc = err;
- }
+ if ( !this_cpu(iommu_dont_flush_iotlb) && ! rc )
+ rc = iommu_iotlb_flush(d, dfn, (1u << page_order), flush_flags);
return rc;
}