[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-changelog] [xen-unstable] [VTD] Fix VT-d PAE issues.



# HG changeset patch
# User Keir Fraser <keir.fraser@xxxxxxxxxx>
# Date 1208349646 -3600
# Node ID da4042899fd295ae5258b2f26f374afa3d1e1e17
# Parent  cd5dc735bdf3feac543f54d01ab4a1ce9d5a1292
[VTD] Fix VT-d PAE issues.

Cast unsigned long PFNs to paddr_t before shifting left.

Signed-off-by: Weidong Han <weidong.han@xxxxxxxxx>
---
 xen/drivers/passthrough/vtd/iommu.c   |   15 +++++++--------
 xen/drivers/passthrough/vtd/x86/vtd.c |    8 ++++----
 2 files changed, 11 insertions(+), 12 deletions(-)

diff -r cd5dc735bdf3 -r da4042899fd2 xen/drivers/passthrough/vtd/iommu.c
--- a/xen/drivers/passthrough/vtd/iommu.c       Wed Apr 16 13:36:44 2008 +0100
+++ b/xen/drivers/passthrough/vtd/iommu.c       Wed Apr 16 13:40:46 2008 +0100
@@ -1600,7 +1600,7 @@ int intel_iommu_map_page(
         return 0;
 #endif
 
-    pg_maddr = addr_to_dma_page_maddr(d, 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);
@@ -1643,11 +1643,11 @@ int intel_iommu_unmap_page(struct domain
 }
 
 int iommu_page_mapping(struct domain *domain, paddr_t iova,
-                       void *hpa, size_t size, int prot)
+                       paddr_t hpa, size_t size, int prot)
 {
     struct acpi_drhd_unit *drhd;
     struct iommu *iommu;
-    unsigned long start_pfn, end_pfn;
+    u64 start_pfn, end_pfn;
     struct dma_pte *page = NULL, *pte = NULL;
     int index;
     u64 pg_maddr;
@@ -1657,9 +1657,8 @@ int iommu_page_mapping(struct domain *do
     if ( (prot & (DMA_PTE_READ|DMA_PTE_WRITE)) == 0 )
         return -EINVAL;
     iova = (iova >> PAGE_SHIFT_4K) << PAGE_SHIFT_4K;
-    start_pfn = (unsigned long)(((unsigned long) hpa) >> PAGE_SHIFT_4K);
-    end_pfn = (unsigned long)
-        ((PAGE_ALIGN_4K(((unsigned long)hpa) + size)) >> PAGE_SHIFT_4K);
+    start_pfn = hpa >> PAGE_SHIFT_4K;
+    end_pfn = (PAGE_ALIGN_4K(hpa + size)) >> PAGE_SHIFT_4K;
     index = 0;
     while ( start_pfn < end_pfn )
     {
@@ -1668,7 +1667,7 @@ int iommu_page_mapping(struct domain *do
             return -ENOMEM;
         page = (struct dma_pte *)map_vtd_domain_page(pg_maddr);
         pte = page + (start_pfn & LEVEL_MASK);
-        dma_set_pte_addr(*pte, start_pfn << PAGE_SHIFT_4K);
+        dma_set_pte_addr(*pte, (paddr_t)start_pfn << PAGE_SHIFT_4K);
         dma_set_pte_prot(*pte, prot);
         iommu_flush_cache_entry(iommu, pte);
         unmap_vtd_domain_page(page);
@@ -1727,7 +1726,7 @@ static int iommu_prepare_rmrr_dev(
     /* page table init */
     size = rmrr->end_address - rmrr->base_address + 1;
     ret = iommu_page_mapping(d, rmrr->base_address,
-                             (void *)rmrr->base_address, size,
+                             rmrr->base_address, size,
                              DMA_PTE_READ|DMA_PTE_WRITE);
     if ( ret )
         return ret;
diff -r cd5dc735bdf3 -r da4042899fd2 xen/drivers/passthrough/vtd/x86/vtd.c
--- a/xen/drivers/passthrough/vtd/x86/vtd.c     Wed Apr 16 13:36:44 2008 +0100
+++ b/xen/drivers/passthrough/vtd/x86/vtd.c     Wed Apr 16 13:40:46 2008 +0100
@@ -153,12 +153,12 @@ void iommu_set_pgd(struct domain *d)
                 return;
             }
             pgd_mfn = _mfn(dma_pte_addr(*dpte) >> PAGE_SHIFT_4K);
-            hd->pgd_maddr = mfn_x(pgd_mfn) << PAGE_SHIFT_4K;
+            hd->pgd_maddr = (paddr_t)(mfn_x(pgd_mfn)) << PAGE_SHIFT_4K;
             unmap_domain_page(dpte);
             break;
         case VTD_PAGE_TABLE_LEVEL_4:
             pgd_mfn = _mfn(p2m_table);
-            hd->pgd_maddr = mfn_x(pgd_mfn) << PAGE_SHIFT_4K;
+            hd->pgd_maddr = (paddr_t)(mfn_x(pgd_mfn)) << PAGE_SHIFT_4K;
             break;
         default:
             gdprintk(XENLOG_ERR VTDPREFIX,
@@ -250,12 +250,12 @@ void iommu_set_pgd(struct domain *d)
             }
 
             pgd_mfn = _mfn(l3e_get_pfn(*l3e));
-            hd->pgd_maddr = mfn_x(pgd_mfn) << PAGE_SHIFT_4K;
+            hd->pgd_maddr = (paddr_t)(mfn_x(pgd_mfn)) << PAGE_SHIFT_4K;
             unmap_domain_page(l3e);
             break;
         case VTD_PAGE_TABLE_LEVEL_4:
             pgd_mfn = _mfn(p2m_table);
-            hd->pgd_maddr = mfn_x(pgd_mfn) << PAGE_SHIFT_4K;
+            hd->pgd_maddr = (paddr_t)(mfn_x(pgd_mfn)) << PAGE_SHIFT_4K;
             break;
         default:
             gdprintk(XENLOG_ERR VTDPREFIX,

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.