WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-changelog

[Xen-changelog] [xen-unstable] ia64: Enhance vt-d support for ia64.

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] [xen-unstable] ia64: Enhance vt-d support for ia64.
From: Xen patchbot-unstable <patchbot-unstable@xxxxxxxxxxxxxxxxxxx>
Date: Wed, 18 Feb 2009 04:10:15 -0800
Delivery-date: Wed, 18 Feb 2009 04:10:10 -0800
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-changelog-request@lists.xensource.com?subject=help>
List-id: BK change log <xen-changelog.lists.xensource.com>
List-post: <mailto:xen-changelog@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=unsubscribe>
Reply-to: xen-devel@xxxxxxxxxxxxxxxxxxx
Sender: xen-changelog-bounces@xxxxxxxxxxxxxxxxxxx
# HG changeset patch
# User Keir Fraser <keir.fraser@xxxxxxxxxx>
# Date 1234869000 0
# Node ID ac3ecce4502d330232a2691a5c6615044a875246
# Parent  6e9daf1dc5b3ac94f2f01ca02c6f090aca70802c
ia64: Enhance vt-d support for ia64.

This patch targets for enhancing vt-d support for ia64.
1. reserve enough memory for building dom0 vt-d page table.
2. build 1:1 vt-d page table according to system's mem map.
3. enable vt-d interrupt support for ia64.

Signed-off-by: Xiantao Zhang <xiantao.zhang@xxxxxxxxx>
Acked-by: Isaku Yamahata <yamahata@xxxxxxxxxxxxx>
---
 xen/arch/ia64/xen/domain.c             |   10 ++++++++--
 xen/drivers/passthrough/vtd/ia64/vtd.c |   30 ++++++++++++++++++++++++++++++
 xen/drivers/passthrough/vtd/iommu.c    |   22 +++-------------------
 xen/drivers/passthrough/vtd/x86/vtd.c  |   20 ++++++++++++++++++++
 xen/include/asm-ia64/hvm/iommu.h       |    1 +
 xen/include/xen/iommu.h                |    2 ++
 6 files changed, 64 insertions(+), 21 deletions(-)

diff -r 6e9daf1dc5b3 -r ac3ecce4502d xen/arch/ia64/xen/domain.c
--- a/xen/arch/ia64/xen/domain.c        Tue Feb 17 11:08:31 2009 +0000
+++ b/xen/arch/ia64/xen/domain.c        Tue Feb 17 11:10:00 2009 +0000
@@ -2023,6 +2023,7 @@ static void __init calc_dom0_size(void)
        unsigned long p2m_pages;
        unsigned long spare_hv_pages;
        unsigned long max_dom0_size;
+       unsigned long iommu_pg_table_pages = 0;
 
        /* Estimate maximum memory we can safely allocate for dom0
         * by subtracting the p2m table allocation and a chunk of memory
@@ -2033,8 +2034,13 @@ static void __init calc_dom0_size(void)
        domheap_pages = avail_domheap_pages();
        p2m_pages = domheap_pages / PTRS_PER_PTE;
        spare_hv_pages = 8192 + (domheap_pages / 4096);
-       max_dom0_size = (domheap_pages - (p2m_pages + spare_hv_pages))
-                        * PAGE_SIZE;
+
+       if (iommu_enabled)
+               iommu_pg_table_pages = domheap_pages * 4 / 512;
+               /* There are 512 ptes in one 4K vtd page. */
+
+       max_dom0_size = (domheap_pages - (p2m_pages + spare_hv_pages) -
+                       iommu_pg_table_pages) * PAGE_SIZE;
        printk("Maximum permitted dom0 size: %luMB\n",
               max_dom0_size / (1024*1024));
 
diff -r 6e9daf1dc5b3 -r ac3ecce4502d xen/drivers/passthrough/vtd/ia64/vtd.c
--- a/xen/drivers/passthrough/vtd/ia64/vtd.c    Tue Feb 17 11:08:31 2009 +0000
+++ b/xen/drivers/passthrough/vtd/ia64/vtd.c    Tue Feb 17 11:10:00 2009 +0000
@@ -114,3 +114,33 @@ void hvm_dpci_isairq_eoi(struct domain *
 {
     /* dummy */
 }
+
+static int do_dom0_iommu_mapping(unsigned long start, unsigned long end,
+                               void *arg)
+{
+    unsigned long tmp, pfn, j, page_addr = start;
+    struct domain *d = (struct domain *)arg;
+
+    extern int xen_in_range(paddr_t start, paddr_t end);
+    /* Set up 1:1 page table for dom0 for all Ram except Xen bits.*/
+
+    while (page_addr < end)
+    {
+       if (xen_in_range(page_addr, page_addr + PAGE_SIZE))
+            continue;
+
+        pfn = page_addr >> PAGE_SHIFT;
+        tmp = 1 << (PAGE_SHIFT - PAGE_SHIFT_4K);
+        for ( j = 0; j < tmp; j++ )
+            iommu_map_page(d, (pfn*tmp+j), (pfn*tmp+j));
+
+       page_addr += PAGE_SIZE;
+    }
+    return 0;
+}
+
+void iommu_set_dom0_mapping(struct domain *d)
+{
+       BUG_ON(d != dom0);
+       efi_memmap_walk(do_dom0_iommu_mapping, d);
+}
diff -r 6e9daf1dc5b3 -r ac3ecce4502d xen/drivers/passthrough/vtd/iommu.c
--- a/xen/drivers/passthrough/vtd/iommu.c       Tue Feb 17 11:08:31 2009 +0000
+++ b/xen/drivers/passthrough/vtd/iommu.c       Tue Feb 17 11:10:00 2009 +0000
@@ -30,6 +30,7 @@
 #include <xen/pci.h>
 #include <xen/pci_regs.h>
 #include <xen/keyhandler.h>
+#include <asm/msi.h>
 #include "iommu.h"
 #include "dmar.h"
 #include "extern.h"
@@ -829,7 +830,6 @@ static void dma_msi_data_init(struct iom
     spin_unlock_irqrestore(&iommu->register_lock, flags);
 }
 
-#ifdef SUPPORT_MSI_REMAPPING
 static void dma_msi_addr_init(struct iommu *iommu, int phy_cpu)
 {
     u64 msi_address;
@@ -846,12 +846,6 @@ static void dma_msi_addr_init(struct iom
     dmar_writel(iommu->reg, DMAR_FEUADDR_REG, (u32)(msi_address >> 32));
     spin_unlock_irqrestore(&iommu->register_lock, flags);
 }
-#else
-static void dma_msi_addr_init(struct iommu *iommu, int phy_cpu)
-{
-    /* ia64: TODO */
-}
-#endif
 
 static void dma_msi_set_affinity(unsigned int vector, cpumask_t dest)
 {
@@ -988,7 +982,6 @@ static int intel_iommu_domain_init(struc
 {
     struct hvm_iommu *hd = domain_hvm_iommu(d);
     struct iommu *iommu = NULL;
-    u64 i, j, tmp;
     struct acpi_drhd_unit *drhd;
 
     drhd = list_entry(acpi_drhd_units.next, typeof(*drhd), list);
@@ -1000,17 +993,8 @@ static int intel_iommu_domain_init(struc
     {
         extern int xen_in_range(paddr_t start, paddr_t end);
 
-        /* Set up 1:1 page table for dom0 for all RAM except Xen bits. */
-        for ( i = 0; i < max_page; i++ )
-        {
-            if ( !page_is_conventional_ram(i) ||
-                 xen_in_range(i << PAGE_SHIFT, (i + 1) << PAGE_SHIFT) )
-                continue;
-
-            tmp = 1 << (PAGE_SHIFT - PAGE_SHIFT_4K);
-            for ( j = 0; j < tmp; j++ )
-                iommu_map_page(d, (i*tmp+j), (i*tmp+j));
-        }
+        /* Set up 1:1 page table for dom0 */
+        iommu_set_dom0_mapping(d);
 
         setup_dom0_devices(d);
         setup_dom0_rmrr(d);
diff -r 6e9daf1dc5b3 -r ac3ecce4502d xen/drivers/passthrough/vtd/x86/vtd.c
--- a/xen/drivers/passthrough/vtd/x86/vtd.c     Tue Feb 17 11:08:31 2009 +0000
+++ b/xen/drivers/passthrough/vtd/x86/vtd.c     Tue Feb 17 11:10:00 2009 +0000
@@ -143,3 +143,23 @@ void hvm_dpci_isairq_eoi(struct domain *
     }
     spin_unlock(&d->event_lock);
 }
+
+void iommu_set_dom0_mapping(struct domain *d)
+{
+    u64 i, j, tmp;
+    extern int xen_in_range(paddr_t start, paddr_t end);
+
+    BUG_ON(d != dom0);
+
+    for ( i = 0; i < max_page; i++ )
+    {
+        /* Set up 1:1 mapping for dom0 for all RAM except Xen bits. */
+        if ( !page_is_conventional_ram(i) ||
+             xen_in_range(i << PAGE_SHIFT, (i + 1) << PAGE_SHIFT) )
+            continue;
+
+        tmp = 1 << (PAGE_SHIFT - PAGE_SHIFT_4K);
+        for ( j = 0; j < tmp; j++ )
+            iommu_map_page(d, (i*tmp+j), (i*tmp+j));
+    }
+}
diff -r 6e9daf1dc5b3 -r ac3ecce4502d xen/include/asm-ia64/hvm/iommu.h
--- a/xen/include/asm-ia64/hvm/iommu.h  Tue Feb 17 11:08:31 2009 +0000
+++ b/xen/include/asm-ia64/hvm/iommu.h  Tue Feb 17 11:10:00 2009 +0000
@@ -6,6 +6,7 @@
 #include <public/arch-ia64/hvm/save.h>
 #include <asm/linux/asm/hw_irq.h>
 #include <asm/linux-xen/asm/iosapic.h>
+#include <asm/hw_irq.h>
 
 struct iommu_ops;
 extern struct iommu_ops intel_iommu_ops;
diff -r 6e9daf1dc5b3 -r ac3ecce4502d xen/include/xen/iommu.h
--- a/xen/include/xen/iommu.h   Tue Feb 17 11:08:31 2009 +0000
+++ b/xen/include/xen/iommu.h   Tue Feb 17 11:10:00 2009 +0000
@@ -114,4 +114,6 @@ void iommu_suspend(void);
 void iommu_suspend(void);
 void iommu_resume(void);
 
+void iommu_set_dom0_mapping(struct domain *d);
+
 #endif /* _IOMMU_H_ */

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

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-changelog] [xen-unstable] ia64: Enhance vt-d support for ia64., Xen patchbot-unstable <=