iommu.lists.linux-foundation.org archive mirror
 help / color / mirror / Atom feed
* [PULL REQUEST] iommu/vt-d: fixes for v5.6
@ 2020-03-12  6:09 Lu Baolu
  2020-03-12  6:09 ` [PATCH 1/2] iommu/vt-d: Fix the wrong printing in RHSA parsing Lu Baolu
                   ` (3 more replies)
  0 siblings, 4 replies; 7+ messages in thread
From: Lu Baolu @ 2020-03-12  6:09 UTC (permalink / raw)
  To: Joerg Roedel; +Cc: iommu

Hi Joerg,

There are another two small fixes queued in my tree.

Can you please consider them for v5.6?

Best regards,
-baolu

Daniel Drake (1):
  iommu/vt-d: Ignore devices with out-of-spec domain number

Zhenzhong Duan (1):
  iommu/vt-d: Fix the wrong printing in RHSA parsing

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

-- 
2.17.1

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

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

* [PATCH 1/2] iommu/vt-d: Fix the wrong printing in RHSA parsing
  2020-03-12  6:09 [PULL REQUEST] iommu/vt-d: fixes for v5.6 Lu Baolu
@ 2020-03-12  6:09 ` Lu Baolu
  2020-03-12  6:09 ` [PATCH 2/2] iommu/vt-d: Ignore devices with out-of-spec domain number Lu Baolu
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 7+ messages in thread
From: Lu Baolu @ 2020-03-12  6:09 UTC (permalink / raw)
  To: Joerg Roedel; +Cc: iommu, Zhenzhong Duan

From: Zhenzhong Duan <zhenzhong.duan@gmail.com>

When base address in RHSA structure doesn't match base address in
each DRHD structure, the base address in last DRHD is printed out.

This doesn't make sense when there are multiple DRHD units, fix it
by printing the buggy RHSA's base address.

Signed-off-by: Zhenzhong Duan <zhenzhong.duan@gmail.com>
Signed-off-by: Lu Baolu <baolu.lu@linux.intel.com>
---
 drivers/iommu/dmar.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/iommu/dmar.c b/drivers/iommu/dmar.c
index c000ddff822e..c7b1461e8d0a 100644
--- a/drivers/iommu/dmar.c
+++ b/drivers/iommu/dmar.c
@@ -476,7 +476,7 @@ static int dmar_parse_one_rhsa(struct acpi_dmar_header *header, void *arg)
 	pr_warn(FW_BUG
 		"Your BIOS is broken; RHSA refers to non-existent DMAR unit at %llx\n"
 		"BIOS vendor: %s; Ver: %s; Product Version: %s\n",
-		drhd->reg_base_addr,
+		rhsa->base_address,
 		dmi_get_system_info(DMI_BIOS_VENDOR),
 		dmi_get_system_info(DMI_BIOS_VERSION),
 		dmi_get_system_info(DMI_PRODUCT_VERSION));
-- 
2.17.1

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

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

* [PATCH 2/2] iommu/vt-d: Ignore devices with out-of-spec domain number
  2020-03-12  6:09 [PULL REQUEST] iommu/vt-d: fixes for v5.6 Lu Baolu
  2020-03-12  6:09 ` [PATCH 1/2] iommu/vt-d: Fix the wrong printing in RHSA parsing Lu Baolu
@ 2020-03-12  6:09 ` Lu Baolu
  2020-03-16 15:53   ` Christoph Hellwig
  2020-03-13 13:41 ` [PULL REQUEST] iommu/vt-d: fixes for v5.6 Joerg Roedel
  2020-03-13 13:46 ` Joerg Roedel
  3 siblings, 1 reply; 7+ messages in thread
From: Lu Baolu @ 2020-03-12  6:09 UTC (permalink / raw)
  To: Joerg Roedel; +Cc: iommu, Daniel Drake

From: Daniel Drake <drake@endlessm.com>

VMD subdevices are created with a PCI domain ID of 0x10000 or
higher.

These subdevices are also handled like all other PCI devices by
dmar_pci_bus_notifier().

However, when dmar_alloc_pci_notify_info() take records of such devices,
it will truncate the domain ID to a u16 value (in info->seg).
The device at (e.g.) 10000:00:02.0 is then treated by the DMAR code as if
it is 0000:00:02.0.

In the unlucky event that a real device also exists at 0000:00:02.0 and
also has a device-specific entry in the DMAR table,
dmar_insert_dev_scope() will crash on:
   BUG_ON(i >= devices_cnt);

That's basically a sanity check that only one PCI device matches a
single DMAR entry; in this case we seem to have two matching devices.

Fix this by ignoring devices that have a domain number higher than
what can be looked up in the DMAR table.

This problem was carefully diagnosed by Jian-Hong Pan.

Signed-off-by: Daniel Drake <drake@endlessm.com>
Signed-off-by: Lu Baolu <baolu.lu@linux.intel.com>
---
 drivers/iommu/dmar.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/drivers/iommu/dmar.c b/drivers/iommu/dmar.c
index c7b1461e8d0a..f77dae7ba7d4 100644
--- a/drivers/iommu/dmar.c
+++ b/drivers/iommu/dmar.c
@@ -28,6 +28,7 @@
 #include <linux/slab.h>
 #include <linux/iommu.h>
 #include <linux/numa.h>
+#include <linux/limits.h>
 #include <asm/irq_remapping.h>
 #include <asm/iommu_table.h>
 
@@ -128,6 +129,13 @@ dmar_alloc_pci_notify_info(struct pci_dev *dev, unsigned long event)
 
 	BUG_ON(dev->is_virtfn);
 
+	/*
+	 * Ignore devices that have a domain number higher than what can
+	 * be looked up in DMAR, e.g. VMD subdevices with domain 0x10000
+	 */
+	if (pci_domain_nr(dev->bus) > U16_MAX)
+		return NULL;
+
 	/* Only generate path[] for device addition event */
 	if (event == BUS_NOTIFY_ADD_DEVICE)
 		for (tmp = dev; tmp; tmp = tmp->bus->self)
-- 
2.17.1

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

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

* Re: [PULL REQUEST] iommu/vt-d: fixes for v5.6
  2020-03-12  6:09 [PULL REQUEST] iommu/vt-d: fixes for v5.6 Lu Baolu
  2020-03-12  6:09 ` [PATCH 1/2] iommu/vt-d: Fix the wrong printing in RHSA parsing Lu Baolu
  2020-03-12  6:09 ` [PATCH 2/2] iommu/vt-d: Ignore devices with out-of-spec domain number Lu Baolu
@ 2020-03-13 13:41 ` Joerg Roedel
  2020-03-13 13:46 ` Joerg Roedel
  3 siblings, 0 replies; 7+ messages in thread
From: Joerg Roedel @ 2020-03-13 13:41 UTC (permalink / raw)
  To: Lu Baolu; +Cc: iommu

On Thu, Mar 12, 2020 at 02:09:53PM +0800, Lu Baolu wrote:
> Hi Joerg,
> 
> There are another two small fixes queued in my tree.
> 
> Can you please consider them for v5.6?
> 
> Best regards,
> -baolu
> 
> Daniel Drake (1):
>   iommu/vt-d: Ignore devices with out-of-spec domain number
> 
> Zhenzhong Duan (1):
>   iommu/vt-d: Fix the wrong printing in RHSA parsing
> 
>  drivers/iommu/dmar.c | 10 +++++++++-
>  1 file changed, 9 insertions(+), 1 deletion(-)

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

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

* Re: [PULL REQUEST] iommu/vt-d: fixes for v5.6
  2020-03-12  6:09 [PULL REQUEST] iommu/vt-d: fixes for v5.6 Lu Baolu
                   ` (2 preceding siblings ...)
  2020-03-13 13:41 ` [PULL REQUEST] iommu/vt-d: fixes for v5.6 Joerg Roedel
@ 2020-03-13 13:46 ` Joerg Roedel
  2020-03-14  1:23   ` Lu Baolu
  3 siblings, 1 reply; 7+ messages in thread
From: Joerg Roedel @ 2020-03-13 13:46 UTC (permalink / raw)
  To: Lu Baolu; +Cc: iommu

On Thu, Mar 12, 2020 at 02:09:53PM +0800, Lu Baolu wrote:
> Daniel Drake (1):
>   iommu/vt-d: Ignore devices with out-of-spec domain number
> 
> Zhenzhong Duan (1):
>   iommu/vt-d: Fix the wrong printing in RHSA parsing

Btw, these two probably need fixes tags, can you provide them please?
_______________________________________________
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu

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

* Re: [PULL REQUEST] iommu/vt-d: fixes for v5.6
  2020-03-13 13:46 ` Joerg Roedel
@ 2020-03-14  1:23   ` Lu Baolu
  0 siblings, 0 replies; 7+ messages in thread
From: Lu Baolu @ 2020-03-14  1:23 UTC (permalink / raw)
  To: Joerg Roedel; +Cc: iommu

On 2020/3/13 21:46, Joerg Roedel wrote:
> On Thu, Mar 12, 2020 at 02:09:53PM +0800, Lu Baolu wrote:
>> Daniel Drake (1):
>>    iommu/vt-d: Ignore devices with out-of-spec domain number

Fixes: 59ce0515cdaf3 ("iommu/vt-d: Update DRHD/RMRR/ATSR device scope
caches when PCI hotplug happens")

>>
>> Zhenzhong Duan (1):
>>    iommu/vt-d: Fix the wrong printing in RHSA parsing

Fixes: fd0c8894893cb ("intel-iommu: Set a more specific taint flag for
invalid BIOS DMAR tables")

> 
> Btw, these two probably need fixes tags, can you provide them please?
> 

Sure.

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

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

* Re: [PATCH 2/2] iommu/vt-d: Ignore devices with out-of-spec domain number
  2020-03-12  6:09 ` [PATCH 2/2] iommu/vt-d: Ignore devices with out-of-spec domain number Lu Baolu
@ 2020-03-16 15:53   ` Christoph Hellwig
  0 siblings, 0 replies; 7+ messages in thread
From: Christoph Hellwig @ 2020-03-16 15:53 UTC (permalink / raw)
  To: Lu Baolu; +Cc: linux-pci, iommu, Daniel Drake

On Thu, Mar 12, 2020 at 02:09:55PM +0800, Lu Baolu wrote:
> @@ -128,6 +129,13 @@ dmar_alloc_pci_notify_info(struct pci_dev *dev, unsigned long event)
>  
>  	BUG_ON(dev->is_virtfn);
>  
> +	/*
> +	 * Ignore devices that have a domain number higher than what can
> +	 * be looked up in DMAR, e.g. VMD subdevices with domain 0x10000
> +	 */
> +	if (pci_domain_nr(dev->bus) > U16_MAX)

I think this needs a well documented core PCI layer function, as that
is where these "fake" domains are create.

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

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

end of thread, other threads:[~2020-03-16 15:53 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-12  6:09 [PULL REQUEST] iommu/vt-d: fixes for v5.6 Lu Baolu
2020-03-12  6:09 ` [PATCH 1/2] iommu/vt-d: Fix the wrong printing in RHSA parsing Lu Baolu
2020-03-12  6:09 ` [PATCH 2/2] iommu/vt-d: Ignore devices with out-of-spec domain number Lu Baolu
2020-03-16 15:53   ` Christoph Hellwig
2020-03-13 13:41 ` [PULL REQUEST] iommu/vt-d: fixes for v5.6 Joerg Roedel
2020-03-13 13:46 ` Joerg Roedel
2020-03-14  1:23   ` Lu Baolu

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).