iommu.lists.linux-foundation.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] iommu/vt-d: Fix wrong analysis whether devices share the same bus
@ 2019-08-20  8:53 Nadav Amit via iommu
  2019-08-23 23:06 ` Logan Gunthorpe
  2019-08-30 13:48 ` Joerg Roedel
  0 siblings, 2 replies; 3+ messages in thread
From: Nadav Amit via iommu @ 2019-08-20  8:53 UTC (permalink / raw)
  To: Joerg Roedel
  Cc: David Woodhouse, linux-kernel, stable, iommu, Nadav Amit,
	Logan Gunthorpe

set_msi_sid_cb() is used to determine whether device aliases share the
same bus, but it can provide false indications that aliases use the same
bus when in fact they do not. The reason is that set_msi_sid_cb()
assumes that pdev is fixed, while actually pci_for_each_dma_alias() can
call fn() when pdev is set to a subordinate device.

As a result, running an VM on ESX with VT-d emulation enabled can
results in the log warning such as:

  DMAR: [INTR-REMAP] Request device [00:11.0] fault index 3b [fault reason 38] Blocked an interrupt request due to source-id verification failure

This seems to cause additional ata errors such as:
  ata3.00: qc timeout (cmd 0xa1)
  ata3.00: failed to IDENTIFY (I/O error, err_mask=0x4)

These timeouts also cause boot to be much longer and other errors.

Fix it by checking comparing the alias with the previous one instead.

Fixes: 3f0c625c6ae71 ("iommu/vt-d: Allow interrupts from the entire bus for aliased devices")
Cc: stable@vger.kernel.org
Cc: Logan Gunthorpe <logang@deltatee.com>
Cc: David Woodhouse <dwmw2@infradead.org>
Cc: Joerg Roedel <joro@8bytes.org>
Cc: Jacob Pan <jacob.jun.pan@linux.intel.com>
Signed-off-by: Nadav Amit <namit@vmware.com>
---
 drivers/iommu/intel_irq_remapping.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/iommu/intel_irq_remapping.c b/drivers/iommu/intel_irq_remapping.c
index 4786ca061e31..81e43c1df7ec 100644
--- a/drivers/iommu/intel_irq_remapping.c
+++ b/drivers/iommu/intel_irq_remapping.c
@@ -376,13 +376,13 @@ static int set_msi_sid_cb(struct pci_dev *pdev, u16 alias, void *opaque)
 {
 	struct set_msi_sid_data *data = opaque;
 
+	if (data->count == 0 || PCI_BUS_NUM(alias) == PCI_BUS_NUM(data->alias))
+		data->busmatch_count++;
+
 	data->pdev = pdev;
 	data->alias = alias;
 	data->count++;
 
-	if (PCI_BUS_NUM(alias) == pdev->bus->number)
-		data->busmatch_count++;
-
 	return 0;
 }
 
-- 
2.17.1

_______________________________________________
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] iommu/vt-d: Fix wrong analysis whether devices share the same bus
  2019-08-20  8:53 [PATCH] iommu/vt-d: Fix wrong analysis whether devices share the same bus Nadav Amit via iommu
@ 2019-08-23 23:06 ` Logan Gunthorpe
  2019-08-30 13:48 ` Joerg Roedel
  1 sibling, 0 replies; 3+ messages in thread
From: Logan Gunthorpe @ 2019-08-23 23:06 UTC (permalink / raw)
  To: Nadav Amit, Joerg Roedel; +Cc: iommu, David Woodhouse, linux-kernel, stable



On 2019-08-20 2:53 a.m., Nadav Amit wrote:
> set_msi_sid_cb() is used to determine whether device aliases share the
> same bus, but it can provide false indications that aliases use the same
> bus when in fact they do not. The reason is that set_msi_sid_cb()
> assumes that pdev is fixed, while actually pci_for_each_dma_alias() can
> call fn() when pdev is set to a subordinate device.
> 
> As a result, running an VM on ESX with VT-d emulation enabled can
> results in the log warning such as:
> 
>   DMAR: [INTR-REMAP] Request device [00:11.0] fault index 3b [fault reason 38] Blocked an interrupt request due to source-id verification failure
> 
> This seems to cause additional ata errors such as:
>   ata3.00: qc timeout (cmd 0xa1)
>   ata3.00: failed to IDENTIFY (I/O error, err_mask=0x4)
> 
> These timeouts also cause boot to be much longer and other errors.
> 
> Fix it by checking comparing the alias with the previous one instead.
> 
> Fixes: 3f0c625c6ae71 ("iommu/vt-d: Allow interrupts from the entire bus for aliased devices")
> Cc: stable@vger.kernel.org
> Cc: Logan Gunthorpe <logang@deltatee.com>
> Cc: David Woodhouse <dwmw2@infradead.org>
> Cc: Joerg Roedel <joro@8bytes.org>
> Cc: Jacob Pan <jacob.jun.pan@linux.intel.com>
> Signed-off-by: Nadav Amit <namit@vmware.com>

This looks good to me.

Reviewed-by: Logan Gunthorpe <logang@deltatee.com>

Thanks!

Logan
_______________________________________________
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] iommu/vt-d: Fix wrong analysis whether devices share the same bus
  2019-08-20  8:53 [PATCH] iommu/vt-d: Fix wrong analysis whether devices share the same bus Nadav Amit via iommu
  2019-08-23 23:06 ` Logan Gunthorpe
@ 2019-08-30 13:48 ` Joerg Roedel
  1 sibling, 0 replies; 3+ messages in thread
From: Joerg Roedel @ 2019-08-30 13:48 UTC (permalink / raw)
  To: Nadav Amit; +Cc: Logan Gunthorpe, linux-kernel, stable, iommu, David Woodhouse

On Tue, Aug 20, 2019 at 01:53:17AM -0700, Nadav Amit wrote:
>  drivers/iommu/intel_irq_remapping.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)

Applied, thanks.
_______________________________________________
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2019-08-30 13:49 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-08-20  8:53 [PATCH] iommu/vt-d: Fix wrong analysis whether devices share the same bus Nadav Amit via iommu
2019-08-23 23:06 ` Logan Gunthorpe
2019-08-30 13:48 ` Joerg Roedel

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).