[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH 5/9] VT-d: clear_fault_bits() should clear all fault bits


  • To: "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Wed, 9 Jun 2021 11:28:42 +0200
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=txVdk0hVPwWU6U7vm39WYjxerByLtrHY/Ueo8afMxSA=; b=MkleqzeUjE2JJiIKTstSyHNy4+I0hczL9XH9MQ6j5jlyIUuGly5BJaaWOXtk30F7p6uiRbhoM5CfrS4a5nt8R50E4IkSNANdGOkFGP6Rbb3xyAPUQ8UyFwkPhAJtm4xmYEvadw5p6JX4tr8e3c6w2NJIjcH/5/P6ZvDd/SsknjGDtHc6eOlX42MDGCtV3tKq2+7rVmoRZiP1b+vW1pipIjBoGjy4AN/Z+HcNweGlj1J4iTuLQ5aBp3VNj+2p+izGclAS+HhRdQLwcaS/nOeGPMeTcfE0DptgtS/A9SCOFZ1pE8BwfmdaIO6M5GgNxwNpDT+NFgHYrHqEJiM/vubhvQ==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=BalcyRP884+twz+aBkZDTFM82Kvyjxi04FtYerzBBokUf/wzgZA6KQCL7f2FOe+zkebvQ2debhJiPA/kQgVM82O+QaNFMQUbHRJ/+uskSJ2M1W/Ig8J/RTTsLIncu75x3tW5YO/sxuhGClm2q+uKAcncPwwe6kIpxVw8+6hqL3doAeeDOwfGYvKcuO+/+vI9jVgi/pihgPjdWe6hb8uJ48crTGskNgyNNeRPekCkh/nsFkbFk9QJaLAC84T95QJgTMA3x7V5SH0c+Z7j9oSArEgC0t+ixabtHB81b2EnUmYbtAg4fwVEGEjHgkXR1cTKbfAIsIzt6e8uEfV+npk8dQ==
  • Authentication-results: intel.com; dkim=none (message not signed) header.d=none;intel.com; dmarc=none action=none header.from=suse.com;
  • Cc: Paul Durrant <paul@xxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Kevin Tian <kevin.tian@xxxxxxxxx>
  • Delivery-date: Wed, 09 Jun 2021 09:28:49 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

If there is any way for one fault to be left set in the recording
registers, there's no reason there couldn't also be multiple ones. If
PPF set set (being the OR or all F fields), simply loop over the entire
range of fault recording registers, clearing F everywhere.

Since PPF is a r/o bit, also remove it from DMA_FSTS_FAULTS (arguably
the constant's name is ambiguous as well).

Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>

--- a/xen/drivers/passthrough/vtd/iommu.c
+++ b/xen/drivers/passthrough/vtd/iommu.c
@@ -2094,13 +2094,23 @@ static int __hwdom_init setup_hwdom_devi
 
 void clear_fault_bits(struct vtd_iommu *iommu)
 {
-    u64 val;
     unsigned long flags;
 
     spin_lock_irqsave(&iommu->register_lock, flags);
-    val = dmar_readq(iommu->reg, cap_fault_reg_offset(iommu->cap) + 8);
-    dmar_writeq(iommu->reg, cap_fault_reg_offset(iommu->cap) + 8, val);
+
+    if ( dmar_readl(iommu->reg, DMAR_FSTS_REG) & DMA_FSTS_PPF )
+    {
+        unsigned int reg = cap_fault_reg_offset(iommu->cap);
+        unsigned int end = reg + cap_num_fault_regs(iommu->cap);
+
+        do {
+           dmar_writel(iommu->reg, reg + 12, DMA_FRCD_F);
+           reg += PRIMARY_FAULT_REG_LEN;
+        } while ( reg < end );
+    }
+
     dmar_writel(iommu->reg, DMAR_FSTS_REG, DMA_FSTS_FAULTS);
+
     spin_unlock_irqrestore(&iommu->register_lock, flags);
 }
 
--- a/xen/drivers/passthrough/vtd/iommu.h
+++ b/xen/drivers/passthrough/vtd/iommu.h
@@ -174,9 +174,8 @@
 #define DMA_FSTS_IQE (1u << 4)
 #define DMA_FSTS_ICE (1u << 5)
 #define DMA_FSTS_ITE (1u << 6)
-#define DMA_FSTS_FAULTS (DMA_FSTS_PFO | DMA_FSTS_PPF | DMA_FSTS_AFO | \
-                         DMA_FSTS_APF | DMA_FSTS_IQE | DMA_FSTS_ICE | \
-                         DMA_FSTS_ITE)
+#define DMA_FSTS_FAULTS (DMA_FSTS_PFO | DMA_FSTS_AFO | DMA_FSTS_APF | \
+                         DMA_FSTS_IQE | DMA_FSTS_ICE | DMA_FSTS_ITE)
 #define dma_fsts_fault_record_index(s) (((s) >> 8) & 0xff)
 
 /* FRCD_REG, 32 bits access */




 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.