* [PATCH] VTd: Fix VTd page table teardown on domain destroy
@ 2008-06-02 6:26 Yang, Xiaowei
0 siblings, 0 replies; only message in thread
From: Yang, Xiaowei @ 2008-06-02 6:26 UTC (permalink / raw)
To: xen-devel
[-- Attachment #1: Type: text/plain, Size: 71 bytes --]
Signed-off-by: Xiaowei Yang <xiaowei.yang@intel.com>
Thanks,
Xiaowei
[-- Attachment #2: vtd_pagetable_teardown.patch --]
[-- Type: text/x-patch, Size: 2572 bytes --]
diff -r 6e688d5a936b xen/drivers/passthrough/vtd/iommu.c
--- a/xen/drivers/passthrough/vtd/iommu.c Fri May 30 19:31:18 2008 +0100
+++ b/xen/drivers/passthrough/vtd/iommu.c Sun Jun 01 10:09:25 2008 +0800
@@ -587,50 +587,32 @@ static void dma_pte_clear_range(struct d
}
}
-static void iommu_free_next_pagetable(u64 pt_maddr, unsigned long index,
- int level)
-{
- unsigned long next_index;
- struct dma_pte *pt_vaddr, *pde;
- int next_level;
+static void iommu_free_pagetable(u64 pt_maddr, int level)
+{
+ int i;
+ struct dma_pte *pt_vaddr, *pte;
+ int next_level = level - 1;
if ( pt_maddr == 0 )
return;
pt_vaddr = (struct dma_pte *)map_vtd_domain_page(pt_maddr);
- pde = &pt_vaddr[index];
- if ( dma_pte_addr(*pde) == 0 )
- goto out;
-
- next_level = level - 1;
- if ( next_level > 1 )
- {
- for ( next_index = 0; next_index < PTE_NUM; next_index++ )
- iommu_free_next_pagetable(pde->val, next_index, next_level);
- }
-
- dma_clear_pte(*pde);
- iommu_flush_cache_entry(pde);
- free_pgtable_maddr(pde->val);
-
- out:
+
+ for ( i = 0; i < PTE_NUM; i++ )
+ {
+ pte = &pt_vaddr[i];
+ if ( !dma_pte_present(*pte) )
+ continue;
+
+ if ( next_level >= 1 )
+ iommu_free_pagetable(dma_pte_addr(*pte), next_level);
+
+ dma_clear_pte(*pte);
+ iommu_flush_cache_entry(pte);
+ }
+
unmap_vtd_domain_page(pt_vaddr);
-}
-
-/* free all VT-d page tables when shut down or destroy domain. */
-static void iommu_free_pagetable(struct domain *domain)
-{
- struct hvm_iommu *hd = domain_hvm_iommu(domain);
- int i, total_level = agaw_to_level(hd->agaw);
-
- if ( hd->pgd_maddr == 0 )
- return;
-
- for ( i = 0; i < PTE_NUM; i++ )
- iommu_free_next_pagetable(hd->pgd_maddr, i, total_level + 1);
-
- free_pgtable_maddr(hd->pgd_maddr);
- hd->pgd_maddr = 0;
+ free_pgtable_maddr(pt_maddr);
}
static int iommu_set_root_entry(struct iommu *iommu)
@@ -1456,11 +1438,14 @@ void return_devices_to_dom0(struct domai
void iommu_domain_teardown(struct domain *d)
{
+ struct hvm_iommu *hd = domain_hvm_iommu(d);
+
if ( list_empty(&acpi_drhd_units) )
return;
- iommu_free_pagetable(d);
return_devices_to_dom0(d);
+ iommu_free_pagetable(hd->pgd_maddr, agaw_to_level(hd->agaw));
+ hd->pgd_maddr = 0;
iommu_domid_release(d);
}
[-- Attachment #3: Type: text/plain, Size: 138 bytes --]
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2008-06-02 6:26 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-06-02 6:26 [PATCH] VTd: Fix VTd page table teardown on domain destroy Yang, Xiaowei
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.