vtd: Enable pass-through translation for Dom0
authorKeir Fraser <keir.fraser@citrix.com>
Tue, 9 Sep 2008 13:50:29 +0000 (14:50 +0100)
committerKeir Fraser <keir.fraser@citrix.com>
Tue, 9 Sep 2008 13:50:29 +0000 (14:50 +0100)
If pass-through field in extended capability register is set, set
pass-through translation type for Dom0, that means DMA requests with
Untranslated addresses are processed as pass-through in Dom0, needn't
translate DMA requests through a multi-level page-table.

Signed-off-by: Anthony Xu <anthony.xu@intel.com>
Signed-off-by: Weidong Han <weidong.han@intel.com>
xen/drivers/passthrough/vtd/iommu.c

index 201b80ab31a32da7ed7d0a91c4a69dd08f129e22..5af9b4771a437cf20e0d1235f9fcd73040f56901 100644 (file)
@@ -1090,12 +1090,12 @@ static int domain_context_mapping_one(
     }
 
     spin_lock_irqsave(&iommu->lock, flags);
-
-#ifdef CONTEXT_PASSTHRU
     if ( ecap_pass_thru(iommu->ecap) && (domain->domain_id == 0) )
+    {
         context_set_translation_type(*context, CONTEXT_TT_PASS_THRU);
+        agaw = level_to_agaw(iommu->nr_pt_levels);
+    }
     else
-#endif
     {
         /* Ensure we have pagetables allocated down to leaf PTE. */
         if ( hd->pgd_maddr == 0 )
@@ -1459,11 +1459,12 @@ int intel_iommu_map_page(
     u64 pg_maddr;
     int pte_present;
 
-#ifdef CONTEXT_PASSTHRU
+    drhd = list_entry(acpi_drhd_units.next, typeof(*drhd), list);
+    iommu = drhd->iommu;
+
     /* do nothing if dom0 and iommu supports pass thru */
     if ( ecap_pass_thru(iommu->ecap) && (d->domain_id == 0) )
         return 0;
-#endif
 
     pg_maddr = addr_to_dma_page_maddr(d, (paddr_t)gfn << PAGE_SHIFT_4K, 1);
     if ( pg_maddr == 0 )
@@ -1500,11 +1501,9 @@ int intel_iommu_unmap_page(struct domain *d, unsigned long gfn)
     drhd = list_entry(acpi_drhd_units.next, typeof(*drhd), list);
     iommu = drhd->iommu;
 
-#ifdef CONTEXT_PASSTHRU
     /* do nothing if dom0 and iommu supports pass thru */
     if ( ecap_pass_thru(iommu->ecap) && (d->domain_id == 0) )
         return 0;
-#endif
 
     dma_pte_clear_one(d, (paddr_t)gfn << PAGE_SHIFT_4K);