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-3.4-testing] Passthrough: disable bus-mastering on

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] [xen-3.4-testing] Passthrough: disable bus-mastering on any card that causes an IOMMU
From: Xen patchbot-3.4-testing <patchbot@xxxxxxx>
Date: Fri, 30 Sep 2011 23:44:12 +0100
Delivery-date: Fri, 30 Sep 2011 15:45:24 -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 Keith Coleman <keith.coleman@xxxxxxxxxxxxx>
# Date 1317422262 14400
# Node ID 901a0c68af916b7c88264c17843ce0e9b23caca5
# Parent  6d780b6d41319890cbd4390d7427c9cb909a0ee1
Passthrough: disable bus-mastering on any card that causes an IOMMU
fault.

This stops the card from raising back-to-back faults and live-locking
the CPU that handles them.

Signed-off-by: Tim Deegan <tim@xxxxxxx>
Acked-by: Wei Wang2 <wei.wang2@xxxxxxx>
Acked-by: Allen M Kay <allen.m.kay@xxxxxxxxx>
xen-unstable changeset: 23762:537ed3b74b3f
xen-unstable date: Fri Aug 12 11:29:24 2011 +0100
Committed-by: Keith Coleman <keith.coleman@xxxxxxxxxxxxx>
---


diff -r 6d780b6d4131 -r 901a0c68af91 xen/drivers/passthrough/amd/iommu_init.c
--- a/xen/drivers/passthrough/amd/iommu_init.c  Fri Sep 30 18:37:13 2011 -0400
+++ b/xen/drivers/passthrough/amd/iommu_init.c  Fri Sep 30 18:37:42 2011 -0400
@@ -453,7 +453,7 @@
 
 static void parse_event_log_entry(u32 entry[])
 {
-    u16 domain_id, device_id;
+    u16 domain_id, device_id, bdf, cword;
     u32 code;
     u64 *addr;
     char * event_str[] = {"ILLEGAL_DEV_TABLE_ENTRY",
@@ -487,6 +487,20 @@
         printk(XENLOG_ERR "AMD-Vi: "
             "%s: domain:%d, device id:0x%04x, fault address:0x%016"PRIx64"\n",
             event_str[code-1], domain_id, device_id, *addr);
+
+        /* Tell the device to stop DMAing; we can't rely on the guest to
+         * control it for us. */
+        for ( bdf = 0; bdf < ivrs_bdf_entries; bdf++ )
+        {
+            if ( get_dma_requestor_id(bdf) == device_id ) 
+            {
+                cword = pci_conf_read16(PCI_BUS(bdf), PCI_SLOT(bdf), 
+                                PCI_FUNC(bdf), PCI_COMMAND);
+                pci_conf_write16(PCI_BUS(bdf), PCI_SLOT(bdf), 
+                                 PCI_FUNC(bdf), PCI_COMMAND, 
+                                 cword & ~PCI_COMMAND_MASTER);
+            }
+        }
     }
 }
 
diff -r 6d780b6d4131 -r 901a0c68af91 xen/drivers/passthrough/vtd/iommu.c
--- a/xen/drivers/passthrough/vtd/iommu.c       Fri Sep 30 18:37:13 2011 -0400
+++ b/xen/drivers/passthrough/vtd/iommu.c       Fri Sep 30 18:37:42 2011 -0400
@@ -737,7 +737,7 @@
     while (1)
     {
         u8 fault_reason;
-        u16 source_id;
+        u16 source_id, cword;
         u32 data;
         u64 guest_addr;
         int type;
@@ -770,6 +770,14 @@
         iommu_page_fault_do_one(iommu, type, fault_reason,
                                 source_id, guest_addr);
 
+        /* Tell the device to stop DMAing; we can't rely on the guest to
+         * control it for us. */
+        cword = pci_conf_read16(PCI_BUS(source_id), PCI_SLOT(source_id), 
+                                PCI_FUNC(source_id), PCI_COMMAND);
+        pci_conf_write16(PCI_BUS(source_id), PCI_SLOT(source_id), 
+                         PCI_FUNC(source_id), PCI_COMMAND, 
+                         cword & ~PCI_COMMAND_MASTER);
+
         fault_index++;
         if ( fault_index > cap_num_fault_regs(iommu->cap) )
             fault_index = 0;

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

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-changelog] [xen-3.4-testing] Passthrough: disable bus-mastering on any card that causes an IOMMU, Xen patchbot-3 . 4-testing <=