[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-changelog] [xen-unstable] VT-d: Separate VT-d page table from P2M table
# HG changeset patch # User Keir Fraser <keir.fraser@xxxxxxxxxx> # Date 1209632006 -3600 # Node ID 2ab9f85f221fd99507cbca320a6958f377c4fc8d # Parent eb111919e8e0fb97ce14cc64e1dac038934b7878 VT-d: Separate VT-d page table from P2M table Signed-off-by: Weidong Han <weidong.han@xxxxxxxxx> Signed-off-by: Anthony Xu <anthony.xu@xxxxxxxxx> --- tools/python/xen/xend/XendDomainInfo.py | 7 ++++++- xen/arch/x86/mm/p2m.c | 21 ++++----------------- xen/drivers/passthrough/vtd/iommu.c | 19 ++++++++++++++++--- 3 files changed, 26 insertions(+), 21 deletions(-) diff -r eb111919e8e0 -r 2ab9f85f221f tools/python/xen/xend/XendDomainInfo.py --- a/tools/python/xen/xend/XendDomainInfo.py Thu May 01 09:50:58 2008 +0100 +++ b/tools/python/xen/xend/XendDomainInfo.py Thu May 01 09:53:26 2008 +0100 @@ -2135,8 +2135,13 @@ class XendDomainInfo: # set memory limit xc.domain_setmaxmem(self.domid, maxmem) + # Reserve 1 page per MiB of RAM for separate VT-d page table. + vtd_mem = 4 * (self.info['memory_static_max'] / 1024 / 1024) + # Round vtd_mem up to a multiple of a MiB. + vtd_mem = ((vtd_mem + 1023) / 1024) * 1024 + # Make sure there's enough RAM available for the domain - balloon.free(memory + shadow) + balloon.free(memory + shadow + vtd_mem) # Set up the shadow memory shadow_cur = xc.shadow_mem_control(self.domid, shadow / 1024) diff -r eb111919e8e0 -r 2ab9f85f221f xen/arch/x86/mm/p2m.c --- a/xen/arch/x86/mm/p2m.c Thu May 01 09:50:58 2008 +0100 +++ b/xen/arch/x86/mm/p2m.c Thu May 01 09:53:26 2008 +0100 @@ -259,18 +259,10 @@ p2m_set_entry(struct domain *d, unsigned if ( iommu_enabled && is_hvm_domain(d) ) { - if ( boot_cpu_data.x86_vendor == X86_VENDOR_INTEL ) - { - if ( (p2mt == p2m_mmio_direct) ) - iommu_flush(d, gfn, (u64*)p2m_entry); - } - else if ( boot_cpu_data.x86_vendor == X86_VENDOR_AMD ) - { - if ( p2mt == p2m_ram_rw ) - iommu_map_page(d, gfn, mfn_x(mfn)); - else - iommu_unmap_page(d, gfn); - } + if ( p2mt == p2m_ram_rw ) + iommu_map_page(d, gfn, mfn_x(mfn)); + else + iommu_unmap_page(d, gfn); } /* Success */ @@ -528,11 +520,6 @@ int p2m_alloc_table(struct domain *d, && !set_p2m_entry(d, gfn, mfn, p2m_ram_rw) ) goto error; } - -#if CONFIG_PAGING_LEVELS >= 3 - if (vtd_enabled && is_hvm_domain(d)) - iommu_set_pgd(d); -#endif P2M_PRINTK("p2m table initialised (%u pages)\n", page_count); p2m_unlock(p2m); diff -r eb111919e8e0 -r 2ab9f85f221f xen/drivers/passthrough/vtd/iommu.c --- a/xen/drivers/passthrough/vtd/iommu.c Thu May 01 09:50:58 2008 +0100 +++ b/xen/drivers/passthrough/vtd/iommu.c Thu May 01 09:53:26 2008 +0100 @@ -671,11 +671,24 @@ void dma_pte_free_pagetable(struct domai } /* free pgd */ - if ( start == 0 && end == ((((u64)1) << addr_width) - 1) ) + if ( start == 0 && end >= ((((u64)1) << addr_width) - 1) ) { free_pgtable_maddr(hd->pgd_maddr); hd->pgd_maddr = 0; } +} + + /* 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 addr_width = agaw_to_width(hd->agaw); + u64 start, end; + + start = 0; + end = (((u64)1) << addr_width) - 1; + + dma_pte_free_pagetable(domain, start, end); } static int iommu_set_root_entry(struct iommu *iommu) @@ -1472,9 +1485,9 @@ void iommu_domain_teardown(struct domain if ( list_empty(&acpi_drhd_units) ) return; + iommu_free_pagetable(d); + return_devices_to_dom0(d); iommu_domid_release(d); - iommu_free_pgd(d); - return_devices_to_dom0(d); } static int domain_context_mapped(struct pci_dev *pdev) _______________________________________________ Xen-changelog mailing list Xen-changelog@xxxxxxxxxxxxxxxxxxx http://lists.xensource.com/xen-changelog
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |