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] Revert c/s 17975 -- enumerate PCI devices

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] [xen-unstable] Revert c/s 17975 -- enumerate PCI devices in Xen allowing old dom0
From: Xen patchbot-unstable <patchbot-unstable@xxxxxxxxxxxxxxxxxxx>
Date: Mon, 07 Jul 2008 16:50:08 -0700
Delivery-date: Mon, 07 Jul 2008 16:49:54 -0700
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 1215443633 -3600
# Node ID 0d707feab01ed0f6b82f3243363aa248e96d39f8
# Parent  9b35ae586cb8587186f08be9acff2b76024ae65e
Revert c/s 17975 -- enumerate PCI devices in Xen allowing old dom0
kernels to work with iommu-capable platforms.
Signed-off-by: Keir Fraser <keir.fraser@xxxxxxxxxx>
---
 xen/drivers/passthrough/vtd/iommu.c |   60 ++++++++++++++++++++++++++++++++----
 1 files changed, 54 insertions(+), 6 deletions(-)

diff -r 9b35ae586cb8 -r 0d707feab01e xen/drivers/passthrough/vtd/iommu.c
--- a/xen/drivers/passthrough/vtd/iommu.c       Mon Jul 07 10:45:50 2008 +0100
+++ b/xen/drivers/passthrough/vtd/iommu.c       Mon Jul 07 16:13:53 2008 +0100
@@ -40,6 +40,9 @@ static spinlock_t domid_bitmap_lock;    
 static spinlock_t domid_bitmap_lock;    /* protect domain id bitmap */
 static int domid_bitmap_size;           /* domain id bitmap size in bits */
 static unsigned long *domid_bitmap;     /* iommu domain id bitmap */
+
+static void setup_dom0_devices(struct domain *d);
+static void setup_dom0_rmrr(struct domain *d);
 
 #define DID_FIELD_WIDTH 16
 #define DID_HIGH_OFFSET 8
@@ -1042,6 +1045,10 @@ static int intel_iommu_domain_init(struc
 
             iommu_map_page(d, i, i);
         }
+
+        setup_dom0_devices(d);
+        setup_dom0_rmrr(d);
+
         iommu_flush_all();
 
         for_each_drhd_unit ( drhd )
@@ -1326,18 +1333,12 @@ static int domain_context_unmap(u8 bus, 
         break;
 
     case DEV_TYPE_PCIe_ENDPOINT:
-        gdprintk(XENLOG_INFO VTDPREFIX, "domain_context_unmap:PCIe: "
-                 "bdf = %x:%x.%x\n", bus, PCI_SLOT(devfn), PCI_FUNC(devfn));
         ret = domain_context_unmap_one(drhd->iommu, bus, devfn);
         break;
 
     case DEV_TYPE_PCI:
         if ( find_pcie_endpoint(&bus, &devfn) )
-        {
-            gdprintk(XENLOG_INFO VTDPREFIX, "domain_context_unmap:PCI:  "
-                     "bdf = %x:%x.%x\n", bus, PCI_SLOT(devfn), 
PCI_FUNC(devfn));
             ret = domain_context_unmap_one(drhd->iommu, bus, devfn);
-        }
         break;
 
     default:
@@ -1592,6 +1593,38 @@ static int intel_iommu_remove_device(str
     return domain_context_unmap(pdev->bus, pdev->devfn);
 }
 
+static void setup_dom0_devices(struct domain *d)
+{
+    struct hvm_iommu *hd;
+    struct pci_dev *pdev;
+    int bus, dev, func;
+    u32 l;
+
+    hd = domain_hvm_iommu(d);
+
+    write_lock(&pcidevs_lock);
+    for ( bus = 0; bus < 256; bus++ )
+    {
+        for ( dev = 0; dev < 32; dev++ )
+        {
+            for ( func = 0; func < 8; func++ )
+            {
+                l = pci_conf_read32(bus, dev, func, PCI_VENDOR_ID);
+                /* some broken boards return 0 or ~0 if a slot is empty: */
+                if ( (l == 0xffffffff) || (l == 0x00000000) ||
+                     (l == 0x0000ffff) || (l == 0xffff0000) )
+                    continue;
+
+                pdev = alloc_pdev(bus, PCI_DEVFN(dev, func));
+                pdev->domain = d;
+                list_add(&pdev->domain_list, &d->arch.pdev_list);
+                domain_context_mapping(d, pdev->bus, pdev->devfn);
+            }
+        }
+    }
+    write_unlock(&pcidevs_lock);
+}
+
 void clear_fault_bits(struct iommu *iommu)
 {
     u64 val;
@@ -1654,6 +1687,21 @@ static int init_vtd_hw(void)
     }
 
     return 0;
+}
+
+static void setup_dom0_rmrr(struct domain *d)
+{
+    struct acpi_rmrr_unit *rmrr;
+    u16 bdf;
+    int ret, i;
+
+    for_each_rmrr_device ( rmrr, bdf, i )
+    {
+        ret = iommu_prepare_rmrr_dev(d, rmrr, PCI_BUS(bdf), PCI_DEVFN2(bdf));
+        if ( ret )
+            gdprintk(XENLOG_ERR VTDPREFIX,
+                     "IOMMU: mapping reserved region failed\n");
+    }
 }
 
 int intel_vtd_setup(void)

_______________________________________________
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] Revert c/s 17975 -- enumerate PCI devices in Xen allowing old dom0, Xen patchbot-unstable <=