All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] iommu/vt-d: Set up scalable mode context entries for DMA aliases
@ 2026-11-09 13:20 ` Ahmed Abdelfattah
  0 siblings, 0 replies; 4+ messages in thread
From: Ahmed Abdelfattah via B4 Relay @ 2026-11-09 13:20 UTC (permalink / raw)
  To: David Woodhouse, Lu Baolu, Joerg Roedel (AMD), Will Deacon,
	Robin Murphy, Kevin Tian
  Cc: iommu, linux-kernel, stable, Ahmed Abdelfattah

From: Ahmed Abdelfattah <me@ahmedabdelfattah.dev>

In scalable mode, devices behind a PCIe-to-PCI bridge can't do DMA at
all. Their requests carry the bridge's alias requester ID, and the
context entry for that ID is never written, so every request faults:

  DMAR: [DMA Read NO_PASID] Request device [0000:02:00.0] fault addr 0xfffff000 [fault reason 0x02] Present bit in context entry is clear

pci_pasid_table_setup() and pci_pasid_table_teardown() only act when
they are called for the device itself. pci_for_each_dma_alias() reports
an alias that comes from an upstream bridge with the bridge as @pdev,
so these aliases are skipped. An identity domain doesn't help either,
as the device still needs the context entry.

Legacy mode is fine, because domain_context_mapping_cb() and
domain_context_clear_one_cb() have no such check, and the same check
was already removed from the pass-through path in commit 64f792981e35
("iommu/vt-d: Remove device comparison in context_setup_pass_through_cb").

Drop it from both callbacks, so the alias context entry points to the
device's PASID table and is cleared again when the device is released.

Fixes: 301f1a80487f ("iommu/vt-d: Setup scalable mode context entry in probe path")
Fixes: 81e921fd3216 ("iommu/vt-d: Fix NULL domain on device release")
Cc: stable@vger.kernel.org
Signed-off-by: Ahmed Abdelfattah <me@ahmedabdelfattah.dev>
---
This showed up with a USB controller behind QEMU's pcie-pci-bridge in a
q35 guest using intel-iommu with scalable-mode=on: the USB tablet behind
it never enumerates.

Tested on v7.4-rc2 in that guest (x86_64_defconfig + kvm_guest.config,
INTEL_IOMMU with scalable mode on by default), with an EHCI controller
and an e1000 behind the bridge, in scalable mode with second-stage
tables, with first-stage tables (fsts=on) and with iommu=pt. Without
the patch both devices fault on 02:00.0, the tablet never shows up and
the e1000 hits Tx unit hangs. With it the tablet enumerates, the e1000
passes traffic and no DMAR faults are logged. Removing the EHCI
controller through sysfs and rescanning brings it back without faults,
which exercises the teardown side. Legacy mode behaves the same with
and without the patch.

Devices that share an alias always end up in the same IOMMU group, so
whichever device's PASID table the alias entry points to, it translates
with the group's domain. As in legacy mode, releasing one of them also
clears the alias entry the other one uses, so its DMA is blocked until it
is probed again (see the comment above domain_context_clear()).
---
 drivers/iommu/intel/pasid.c | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/drivers/iommu/intel/pasid.c b/drivers/iommu/intel/pasid.c
index e4f24d3f19a6..e72b6e972cfb 100644
--- a/drivers/iommu/intel/pasid.c
+++ b/drivers/iommu/intel/pasid.c
@@ -760,8 +760,7 @@ static int pci_pasid_table_teardown(struct pci_dev *pdev, u16 alias, void *data)
 {
 	struct device *dev = data;
 
-	if (dev == &pdev->dev)
-		device_pasid_table_teardown(dev, PCI_BUS_NUM(alias), alias & 0xff);
+	device_pasid_table_teardown(dev, PCI_BUS_NUM(alias), alias & 0xff);
 
 	return 0;
 }
@@ -897,9 +896,6 @@ static int pci_pasid_table_setup(struct pci_dev *pdev, u16 alias, void *data)
 {
 	struct device *dev = data;
 
-	if (dev != &pdev->dev)
-		return 0;
-
 	return device_pasid_table_setup(dev, PCI_BUS_NUM(alias), alias & 0xff);
 }
 

---
base-commit: 7475ea8b58616b33c04afb976cf0fbaad9dd63fb
change-id: 20261109-iommu-vtd-sm-bridge-alias-9ea7ccd74a3b

Best regards,
--  
Ahmed Abdelfattah <me@ahmedabdelfattah.dev>



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

* [PATCH] iommu/vt-d: Set up scalable mode context entries for DMA aliases
@ 2026-11-09 13:20 ` Ahmed Abdelfattah
  0 siblings, 0 replies; 4+ messages in thread
From: Ahmed Abdelfattah @ 2026-11-09 13:20 UTC (permalink / raw)
  To: David Woodhouse, Lu Baolu, Joerg Roedel (AMD), Will Deacon,
	Robin Murphy, Kevin Tian
  Cc: iommu, linux-kernel, stable, Ahmed Abdelfattah

In scalable mode, devices behind a PCIe-to-PCI bridge can't do DMA at
all. Their requests carry the bridge's alias requester ID, and the
context entry for that ID is never written, so every request faults:

  DMAR: [DMA Read NO_PASID] Request device [0000:02:00.0] fault addr 0xfffff000 [fault reason 0x02] Present bit in context entry is clear

pci_pasid_table_setup() and pci_pasid_table_teardown() only act when
they are called for the device itself. pci_for_each_dma_alias() reports
an alias that comes from an upstream bridge with the bridge as @pdev,
so these aliases are skipped. An identity domain doesn't help either,
as the device still needs the context entry.

Legacy mode is fine, because domain_context_mapping_cb() and
domain_context_clear_one_cb() have no such check, and the same check
was already removed from the pass-through path in commit 64f792981e35
("iommu/vt-d: Remove device comparison in context_setup_pass_through_cb").

Drop it from both callbacks, so the alias context entry points to the
device's PASID table and is cleared again when the device is released.

Fixes: 301f1a80487f ("iommu/vt-d: Setup scalable mode context entry in probe path")
Fixes: 81e921fd3216 ("iommu/vt-d: Fix NULL domain on device release")
Cc: stable@vger.kernel.org
Signed-off-by: Ahmed Abdelfattah <me@ahmedabdelfattah.dev>
---
This showed up with a USB controller behind QEMU's pcie-pci-bridge in a
q35 guest using intel-iommu with scalable-mode=on: the USB tablet behind
it never enumerates.

Tested on v7.4-rc2 in that guest (x86_64_defconfig + kvm_guest.config,
INTEL_IOMMU with scalable mode on by default), with an EHCI controller
and an e1000 behind the bridge, in scalable mode with second-stage
tables, with first-stage tables (fsts=on) and with iommu=pt. Without
the patch both devices fault on 02:00.0, the tablet never shows up and
the e1000 hits Tx unit hangs. With it the tablet enumerates, the e1000
passes traffic and no DMAR faults are logged. Removing the EHCI
controller through sysfs and rescanning brings it back without faults,
which exercises the teardown side. Legacy mode behaves the same with
and without the patch.

Devices that share an alias always end up in the same IOMMU group, so
whichever device's PASID table the alias entry points to, it translates
with the group's domain. As in legacy mode, releasing one of them also
clears the alias entry the other one uses, so its DMA is blocked until it
is probed again (see the comment above domain_context_clear()).
---
 drivers/iommu/intel/pasid.c | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/drivers/iommu/intel/pasid.c b/drivers/iommu/intel/pasid.c
index e4f24d3f19a6..e72b6e972cfb 100644
--- a/drivers/iommu/intel/pasid.c
+++ b/drivers/iommu/intel/pasid.c
@@ -760,8 +760,7 @@ static int pci_pasid_table_teardown(struct pci_dev *pdev, u16 alias, void *data)
 {
 	struct device *dev = data;
 
-	if (dev == &pdev->dev)
-		device_pasid_table_teardown(dev, PCI_BUS_NUM(alias), alias & 0xff);
+	device_pasid_table_teardown(dev, PCI_BUS_NUM(alias), alias & 0xff);
 
 	return 0;
 }
@@ -897,9 +896,6 @@ static int pci_pasid_table_setup(struct pci_dev *pdev, u16 alias, void *data)
 {
 	struct device *dev = data;
 
-	if (dev != &pdev->dev)
-		return 0;
-
 	return device_pasid_table_setup(dev, PCI_BUS_NUM(alias), alias & 0xff);
 }
 

---
base-commit: 7475ea8b58616b33c04afb976cf0fbaad9dd63fb
change-id: 20261109-iommu-vtd-sm-bridge-alias-9ea7ccd74a3b

Best regards,
--  
Ahmed Abdelfattah <me@ahmedabdelfattah.dev>


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

* Re: [PATCH] iommu/vt-d: Set up scalable mode context entries for DMA aliases
  2026-11-09 13:20 ` Ahmed Abdelfattah
  (?)
@ 2026-12-01 15:27 ` Ahmed Abdelfattah
  2026-12-02  3:01   ` Baolu Lu
  -1 siblings, 1 reply; 4+ messages in thread
From: Ahmed Abdelfattah @ 2026-12-01 15:27 UTC (permalink / raw)
  To: Lu Baolu, Joerg Roedel (AMD)
  Cc: David Woodhouse, Will Deacon, Robin Murphy, Kevin Tian, iommu,
	linux-kernel

On Mon, Nov 09, 2026 at 03:20:52PM +0200, Ahmed Abdelfattah wrote:
> In scalable mode, devices behind a PCIe-to-PCI bridge can't do DMA at
> all. Their requests carry the bridge's alias requester ID, and the
> context entry for that ID is never written, so every request faults:

Gentle ping. The check in pci_pasid_table_setup() is still there in
v7.4-rc5 and in linux-next, and the patch still applies to both as is.

Is there anything you would like me to change?

Thanks,
Ahmed

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

* Re: [PATCH] iommu/vt-d: Set up scalable mode context entries for DMA aliases
  2026-12-01 15:27 ` Ahmed Abdelfattah
@ 2026-12-02  3:01   ` Baolu Lu
  0 siblings, 0 replies; 4+ messages in thread
From: Baolu Lu @ 2026-12-02  3:01 UTC (permalink / raw)
  To: Ahmed Abdelfattah, Joerg Roedel (AMD)
  Cc: David Woodhouse, Will Deacon, Robin Murphy, Kevin Tian, iommu,
	linux-kernel

On 12/1/26 23:27, Ahmed Abdelfattah wrote:
> On Mon, Nov 09, 2026 at 03:20:52PM +0200, Ahmed Abdelfattah wrote:
>> In scalable mode, devices behind a PCIe-to-PCI bridge can't do DMA at
>> all. Their requests carry the bridge's alias requester ID, and the
>> context entry for that ID is never written, so every request faults:
> Gentle ping. The check in pci_pasid_table_setup() is still there in
> v7.4-rc5 and in linux-next, and the patch still applies to both as is.
> 
> Is there anything you would like me to change?

No. I will queue this patch for iommu/next.

Thanks,
baolu

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

end of thread, other threads:[~2026-12-02  3:01 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-09 13:20 [PATCH] iommu/vt-d: Set up scalable mode context entries for DMA aliases Ahmed Abdelfattah via B4 Relay
2026-11-09 13:20 ` Ahmed Abdelfattah
2026-12-01 15:27 ` Ahmed Abdelfattah
2026-12-02  3:01   ` Baolu Lu

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.