From: Keir Fraser Date: Sat, 24 May 2008 08:27:48 +0000 (+0100) Subject: Fix iommu_unmap_page for VT-d X-Git-Tag: archive/raspbian/4.8.0-1+rpi1~1^2~14207^2~41 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=70a2ba87b7d58eea7227ab508e6a87e442330b70;p=xen.git Fix iommu_unmap_page for VT-d Signed-off-by: Espen Skoglund --- diff --git a/xen/drivers/passthrough/vtd/iommu.c b/xen/drivers/passthrough/vtd/iommu.c index 7791c46110..e7a4824655 100644 --- a/xen/drivers/passthrough/vtd/iommu.c +++ b/xen/drivers/passthrough/vtd/iommu.c @@ -1518,6 +1518,8 @@ int intel_iommu_unmap_page(struct domain *d, unsigned long gfn) { struct acpi_drhd_unit *drhd; struct iommu *iommu; + struct dma_pte *page = NULL, *pte = NULL; + u64 pg_maddr; drhd = list_entry(acpi_drhd_units.next, typeof(*drhd), list); iommu = drhd->iommu; @@ -1528,7 +1530,24 @@ int intel_iommu_unmap_page(struct domain *d, unsigned long gfn) return 0; #endif - dma_pte_clear_one(d, (paddr_t)gfn << PAGE_SHIFT_4K); + pg_maddr = addr_to_dma_page_maddr(d, (paddr_t)gfn << PAGE_SHIFT_4K); + if ( pg_maddr == 0 ) + return -ENOMEM; + page = (struct dma_pte *)map_vtd_domain_page(pg_maddr); + pte = page + (gfn & LEVEL_MASK); + dma_clear_pte(*pte); + iommu_flush_cache_entry(drhd->iommu, pte); + unmap_vtd_domain_page(page); + + for_each_drhd_unit ( drhd ) + { + iommu = drhd->iommu; + if ( cap_caching_mode(iommu->cap) ) + iommu_flush_iotlb_psi(iommu, domain_iommu_domid(d), + (paddr_t)gfn << PAGE_SHIFT_4K, 1, 0); + else if ( cap_rwbf(iommu->cap) ) + iommu_flush_write_buffer(iommu); + } return 0; }