iommu.lists.linux-foundation.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] iommu/vt-d fix adding non-PCI devices to Intel IOMMU
@ 2019-12-26 23:56 Patrick Steinhardt
  2019-12-30  0:35 ` Lu Baolu
  2020-01-07 13:03 ` Joerg Roedel
  0 siblings, 2 replies; 3+ messages in thread
From: Patrick Steinhardt @ 2019-12-26 23:56 UTC (permalink / raw)
  To: iommu; +Cc: Patrick Steinhardt, David Woodhouse

Starting with commit fa212a97f3a3 ("iommu/vt-d: Probe DMA-capable ACPI
name space devices"), we now probe DMA-capable ACPI name
space devices. On Dell XPS 13 9343, which has an Intel LPSS platform
device INTL9C60 enumerated via ACPI, this change leads to the following
warning:

    ------------[ cut here ]------------
    WARNING: CPU: 1 PID: 1 at pci_device_group+0x11a/0x130
    CPU: 1 PID: 1 Comm: swapper/0 Tainted: G                T 5.5.0-rc3+ #22
    Hardware name: Dell Inc. XPS 13 9343/0310JH, BIOS A20 06/06/2019
    RIP: 0010:pci_device_group+0x11a/0x130
    Code: f0 ff ff 48 85 c0 49 89 c4 75 c4 48 8d 74 24 10 48 89 ef e8 48 ef ff ff 48 85 c0 49 89 c4 75 af e8 db f7 ff ff 49 89 c4 eb a5 <0f> 0b 49 c7 c4 ea ff ff ff eb 9a e8 96 1e c7 ff 66 0f 1f 44 00 00
    RSP: 0000:ffffc0d6c0043cb0 EFLAGS: 00010202
    RAX: 0000000000000000 RBX: ffffa3d1d43dd810 RCX: 0000000000000000
    RDX: ffffa3d1d4fecf80 RSI: ffffa3d12943dcc0 RDI: ffffa3d1d43dd810
    RBP: ffffa3d1d43dd810 R08: 0000000000000000 R09: ffffa3d1d4c04a80
    R10: ffffa3d1d4c00880 R11: ffffa3d1d44ba000 R12: 0000000000000000
    R13: ffffa3d1d4383b80 R14: ffffa3d1d4c090d0 R15: ffffa3d1d4324530
    FS:  0000000000000000(0000) GS:ffffa3d1d6700000(0000) knlGS:0000000000000000
    CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
    CR2: 0000000000000000 CR3: 000000000460a001 CR4: 00000000003606e0
    Call Trace:
     ? iommu_group_get_for_dev+0x81/0x1f0
     ? intel_iommu_add_device+0x61/0x170
     ? iommu_probe_device+0x43/0xd0
     ? intel_iommu_init+0x1fa2/0x2235
     ? pci_iommu_init+0x52/0xe7
     ? e820__memblock_setup+0x15c/0x15c
     ? do_one_initcall+0xcc/0x27e
     ? kernel_init_freeable+0x169/0x259
     ? rest_init+0x95/0x95
     ? kernel_init+0x5/0xeb
     ? ret_from_fork+0x35/0x40
    ---[ end trace 28473e7abc25b92c ]---
    DMAR: ACPI name space devices didn't probe correctly

The bug results from the fact that while we now enumerate ACPI devices,
we aren't able to handle any non-PCI device when generating the device
group. Fix the issue by implementing an Intel-specific callback that
returns `pci_device_group` only if the device is a PCI device.
Otherwise, it will return a generic device group.

Fixes: fa212a97f3a3 ("iommu/vt-d: Probe DMA-capable ACPI name space devices")
Signed-off-by: Patrick Steinhardt <ps@pks.im>
---

I've recently spotted above warning in v5.5-rc3. The attached fix
is rather intended as a discussion starter -- it's quite likely
to be wrong as I ain't got much of a clue about the IOMMU
subsystem.

 drivers/iommu/intel-iommu.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/drivers/iommu/intel-iommu.c b/drivers/iommu/intel-iommu.c
index 42966611a192..e3696a754fd1 100644
--- a/drivers/iommu/intel-iommu.c
+++ b/drivers/iommu/intel-iommu.c
@@ -5972,6 +5972,13 @@ static bool intel_iommu_is_attach_deferred(struct iommu_domain *domain,
 	return dev->archdata.iommu == DEFER_DEVICE_DOMAIN_INFO;
 }
 
+static struct iommu_group *intel_iommu_device_group(struct device *dev)
+{
+	if (dev_is_pci(dev))
+		return pci_device_group(dev);
+	return generic_device_group(dev);
+}
+
 const struct iommu_ops intel_iommu_ops = {
 	.capable		= intel_iommu_capable,
 	.domain_alloc		= intel_iommu_domain_alloc,
@@ -5989,7 +5996,7 @@ const struct iommu_ops intel_iommu_ops = {
 	.get_resv_regions	= intel_iommu_get_resv_regions,
 	.put_resv_regions	= intel_iommu_put_resv_regions,
 	.apply_resv_region	= intel_iommu_apply_resv_region,
-	.device_group		= pci_device_group,
+	.device_group		= intel_iommu_device_group,
 	.dev_has_feat		= intel_iommu_dev_has_feat,
 	.dev_feat_enabled	= intel_iommu_dev_feat_enabled,
 	.dev_enable_feat	= intel_iommu_dev_enable_feat,
-- 
2.24.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 adding non-PCI devices to Intel IOMMU
  2019-12-26 23:56 [PATCH] iommu/vt-d fix adding non-PCI devices to Intel IOMMU Patrick Steinhardt
@ 2019-12-30  0:35 ` Lu Baolu
  2020-01-07 13:03 ` Joerg Roedel
  1 sibling, 0 replies; 3+ messages in thread
From: Lu Baolu @ 2019-12-30  0:35 UTC (permalink / raw)
  To: Patrick Steinhardt, iommu; +Cc: David Woodhouse

Hi,

On 12/27/19 7:56 AM, Patrick Steinhardt wrote:
> Starting with commit fa212a97f3a3 ("iommu/vt-d: Probe DMA-capable ACPI
> name space devices"), we now probe DMA-capable ACPI name
> space devices. On Dell XPS 13 9343, which has an Intel LPSS platform
> device INTL9C60 enumerated via ACPI, this change leads to the following
> warning:
> 
>      ------------[ cut here ]------------
>      WARNING: CPU: 1 PID: 1 at pci_device_group+0x11a/0x130
>      CPU: 1 PID: 1 Comm: swapper/0 Tainted: G                T 5.5.0-rc3+ #22
>      Hardware name: Dell Inc. XPS 13 9343/0310JH, BIOS A20 06/06/2019
>      RIP: 0010:pci_device_group+0x11a/0x130
>      Code: f0 ff ff 48 85 c0 49 89 c4 75 c4 48 8d 74 24 10 48 89 ef e8 48 ef ff ff 48 85 c0 49 89 c4 75 af e8 db f7 ff ff 49 89 c4 eb a5 <0f> 0b 49 c7 c4 ea ff ff ff eb 9a e8 96 1e c7 ff 66 0f 1f 44 00 00
>      RSP: 0000:ffffc0d6c0043cb0 EFLAGS: 00010202
>      RAX: 0000000000000000 RBX: ffffa3d1d43dd810 RCX: 0000000000000000
>      RDX: ffffa3d1d4fecf80 RSI: ffffa3d12943dcc0 RDI: ffffa3d1d43dd810
>      RBP: ffffa3d1d43dd810 R08: 0000000000000000 R09: ffffa3d1d4c04a80
>      R10: ffffa3d1d4c00880 R11: ffffa3d1d44ba000 R12: 0000000000000000
>      R13: ffffa3d1d4383b80 R14: ffffa3d1d4c090d0 R15: ffffa3d1d4324530
>      FS:  0000000000000000(0000) GS:ffffa3d1d6700000(0000) knlGS:0000000000000000
>      CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
>      CR2: 0000000000000000 CR3: 000000000460a001 CR4: 00000000003606e0
>      Call Trace:
>       ? iommu_group_get_for_dev+0x81/0x1f0
>       ? intel_iommu_add_device+0x61/0x170
>       ? iommu_probe_device+0x43/0xd0
>       ? intel_iommu_init+0x1fa2/0x2235
>       ? pci_iommu_init+0x52/0xe7
>       ? e820__memblock_setup+0x15c/0x15c
>       ? do_one_initcall+0xcc/0x27e
>       ? kernel_init_freeable+0x169/0x259
>       ? rest_init+0x95/0x95
>       ? kernel_init+0x5/0xeb
>       ? ret_from_fork+0x35/0x40
>      ---[ end trace 28473e7abc25b92c ]---
>      DMAR: ACPI name space devices didn't probe correctly
> 
> The bug results from the fact that while we now enumerate ACPI devices,
> we aren't able to handle any non-PCI device when generating the device
> group. Fix the issue by implementing an Intel-specific callback that
> returns `pci_device_group` only if the device is a PCI device.
> Otherwise, it will return a generic device group.
> 
> Fixes: fa212a97f3a3 ("iommu/vt-d: Probe DMA-capable ACPI name space devices")
> Signed-off-by: Patrick Steinhardt<ps@pks.im>

This will allocate per-device group for the ANDD device. Different
devices that couldn't be isolated should be put in a single group.
Unfortunately, the spec doesn't state how the ANDD devices are isolated.

Currently we don't support assigning a platform device to user level as
far as I can see, so though this fix is not the best, it won't break
anything. I will ack this fix so that the kernel crash could be fixed
before we figure out a better solution.

Cc: stable@vger.kernel.org # v5.3+
Acked-by: Lu Baolu <baolu.lu@linux.intel.com>

Best regards,
-baolu
_______________________________________________
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 adding non-PCI devices to Intel IOMMU
  2019-12-26 23:56 [PATCH] iommu/vt-d fix adding non-PCI devices to Intel IOMMU Patrick Steinhardt
  2019-12-30  0:35 ` Lu Baolu
@ 2020-01-07 13:03 ` Joerg Roedel
  1 sibling, 0 replies; 3+ messages in thread
From: Joerg Roedel @ 2020-01-07 13:03 UTC (permalink / raw)
  To: Patrick Steinhardt; +Cc: iommu, David Woodhouse

On Fri, Dec 27, 2019 at 12:56:18AM +0100, Patrick Steinhardt wrote:
> 
> I've recently spotted above warning in v5.5-rc3. The attached fix
> is rather intended as a discussion starter -- it's quite likely
> to be wrong as I ain't got much of a clue about the IOMMU
> subsystem.
> 
>  drivers/iommu/intel-iommu.c | 9 ++++++++-
>  1 file changed, 8 insertions(+), 1 deletion(-)

Applied for v5.5.

_______________________________________________
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:[~2020-01-07 13:03 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-12-26 23:56 [PATCH] iommu/vt-d fix adding non-PCI devices to Intel IOMMU Patrick Steinhardt
2019-12-30  0:35 ` Lu Baolu
2020-01-07 13:03 ` 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).