diff --git a/xen/drivers/passthrough/vtd/iommu.c b/xen/drivers/passthrough/vtd/iommu.c index 26401c7e64..77cdc21837 100644 --- a/xen/drivers/passthrough/vtd/iommu.c +++ b/xen/drivers/passthrough/vtd/iommu.c @@ -570,13 +570,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);