@@ -274,6 +274,13 @@ int iommu_map(struct domain *d, dfn_t dfn, mfn_t mfn,
break;
}
+ /*
+ * Something went wrong so, if we were dealing with more than a single
+ * page, flush everything and clear flush flags.
+ */
+ if ( page_order && unlikely(rc) && !iommu_iotlb_flush_all(d, *flush_flags) )
+ *flush_flags = 0;
+
return rc;
}
@@ -283,14 +290,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 +331,13 @@ int iommu_unmap(struct domain *d, dfn_t dfn, unsigned int page_order,
}
}
+ /*
+ * Something went wrong so, if we were dealing with more than a single
+ * page, flush everything and clear flush flags.
+ */
+ if ( page_order && unlikely(rc) && !iommu_iotlb_flush_all(d, *flush_flags) )
+ *flush_flags = 0;
+
return rc;
}
@@ -338,14 +346,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;
}