Skip to contentSkip to conversation

iommu/vt-d: Fix wrong analysis whether devices share the same bus

PATCH Applied Nadav Amit 3 participants 3 messages Aug 20, 2019 – Aug 30, 2019

Subsystems (2)
lore
Share & tools
lore

Nadav Amit

author
#0 lore raw

PATCH 1/1 iommu/vt-d: Fix wrong analysis whether devices share the same bus

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 Logan Gunthorpe <[email protected]>
Cc David Woodhouse <[email protected]>
Cc Joerg Roedel <[email protected]>
Cc Jacob Pan <[email protected]>
---
 drivers/iommu/intel_irq_remapping.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/iommu/intel_irq_remapping.c +3 -3
index 4786ca061e31..81e43c1df7ec 100644
@@ -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;
 }
 
Signature · 1 line
2.17.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 19 lines · Nadav Amit

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.

Quoted 7 lines
Fixes 3f0c625c6ae71 ("iommu/vt-d: Allow interrupts from the entire bus for aliased devices")
Cc Logan Gunthorpe <[email protected]>
Cc David Woodhouse <[email protected]>
Cc Joerg Roedel <[email protected]>
Cc Jacob Pan <[email protected]>

This looks good to me.

Thanks!

Logan

maintainer Applied
#2 lore raw
In reply to Nadav Amit
Quoted 2 lines · Nadav Amit
 drivers/iommu/intel_irq_remapping.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

Applied, thanks.