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] vtd: Move dom0 RMRR check to intel_iommu_

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] [xen-unstable] vtd: Move dom0 RMRR check to intel_iommu_remove_device()
From: Xen patchbot-unstable <patchbot-unstable@xxxxxxxxxxxxxxxxxxx>
Date: Wed, 30 Jul 2008 08:40:16 -0700
Delivery-date: Wed, 30 Jul 2008 08:40:39 -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 1217406307 -3600
# Node ID b9edc46279445bad0088a61f0c4d63500a4c9f6a
# Parent  eba86724cc074c47d261a48f281d116ccfdc8ce5
vtd: Move dom0 RMRR check to intel_iommu_remove_device()

If put dom0 RMRR check in domain_context_unmap_one(), the devices with
RMRR cannot be assigned to other domain, becuase
domain_context_unmap_one() won't unmap context for them, and dom0
always owns them. This patch moves the check to intel_iommu_remove_device()
which is only called by dom0 hypercall.  This not only guarantees
keeping RMRR mappings for dom0 during its booting, but also won't
impact device assignment.

Signed-off-by: Weidong Han <weidong.han@xxxxxxxxx>
---
 xen/drivers/passthrough/vtd/iommu.c |   46 ++++++++++++++++++------------------
 1 files changed, 23 insertions(+), 23 deletions(-)

diff -r eba86724cc07 -r b9edc4627944 xen/drivers/passthrough/vtd/iommu.c
--- a/xen/drivers/passthrough/vtd/iommu.c       Wed Jul 30 09:23:47 2008 +0100
+++ b/xen/drivers/passthrough/vtd/iommu.c       Wed Jul 30 09:25:07 2008 +0100
@@ -1302,10 +1302,6 @@ static int domain_context_unmap_one(
     struct context_entry *context, *context_entries;
     unsigned long flags;
     u64 maddr;
-    struct acpi_rmrr_unit *rmrr;
-    u16 bdf;
-    int i;
-    unsigned int is_rmrr_device = 0;
 
     maddr = bus_to_context_maddr(iommu, bus);
     context_entries = (struct context_entry *)map_vtd_domain_page(maddr);
@@ -1318,25 +1314,11 @@ static int domain_context_unmap_one(
     }
 
     spin_lock_irqsave(&iommu->lock, flags);
-    if ( domain->domain_id == 0 )
-    {
-        for_each_rmrr_device ( rmrr, bdf, i )
-        {
-            if ( PCI_BUS(bdf) == bus && PCI_DEVFN2(bdf) == devfn )
-            {
-                is_rmrr_device = 1;
-                break;
-            }
-        }
-    }
-    if ( !is_rmrr_device )
-    {
-        context_clear_present(*context);
-        context_clear_entry(*context);
-        iommu_flush_cache_entry(context);
-        iommu_flush_context_domain(iommu, domain_iommu_domid(domain), 0);
-        iommu_flush_iotlb_dsi(iommu, domain_iommu_domid(domain), 0);
-    }
+    context_clear_present(*context);
+    context_clear_entry(*context);
+    iommu_flush_cache_entry(context);
+    iommu_flush_context_domain(iommu, domain_iommu_domid(domain), 0);
+    iommu_flush_iotlb_dsi(iommu, domain_iommu_domid(domain), 0);
     unmap_vtd_domain_page(context_entries);
     spin_unlock_irqrestore(&iommu->lock, flags);
 
@@ -1619,8 +1601,26 @@ static int intel_iommu_add_device(struct
 
 static int intel_iommu_remove_device(struct pci_dev *pdev)
 {
+    struct acpi_rmrr_unit *rmrr;
+    u16 bdf;
+    int i;
+
     if ( !pdev->domain )
         return -EINVAL;
+
+    /* If the device belongs to dom0, and it has RMRR, don't remove it
+     * from dom0, because BIOS may use RMRR at booting time.
+     */
+    if ( pdev->domain->domain_id == 0 )
+    {
+        for_each_rmrr_device ( rmrr, bdf, i )
+        {
+            if ( PCI_BUS(bdf) == pdev->bus &&
+                 PCI_DEVFN2(bdf) == pdev->devfn )
+                return 0;
+        }
+    }
+
     return domain_context_unmap(pdev->domain, pdev->bus, pdev->devfn);
 }
 

_______________________________________________
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] vtd: Move dom0 RMRR check to intel_iommu_remove_device(), Xen patchbot-unstable <=