Skip to contentSkip to conversation

iommu/vt-d: fixes for v5.6

GIT PULL In review Lu Baolu 3 participants 7 messages Mar 12, 2020 – Mar 16, 2020

Subsystems (2)
lore
Share & tools
lore

Lu Baolu

author
#0 lore raw

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(-)
Signature · 6 lines
2.17.1

_______________________________________________
iommu mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/iommu
author
#1 lore raw

PATCH 1/2 iommu/vt-d: Fix the wrong printing in RHSA parsing

From: Zhenzhong Duan <[email protected]>

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.

---
 drivers/iommu/dmar.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iommu/dmar.c +1 -1
index c000ddff822e..c7b1461e8d0a 100644
@@ -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));
Signature · 6 lines
2.17.1

_______________________________________________
iommu mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/iommu
author
#2 lore raw

PATCH 2/2 iommu/vt-d: Ignore devices with out-of-spec domain number

In reply to Lu Baolu

From: Daniel Drake <[email protected]>

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.

---
 drivers/iommu/dmar.c | 8 ++++++++
 1 file changed, 8 insertions(+)
drivers/iommu/dmar.c +8 -0
index c7b1461e8d0a..f77dae7ba7d4 100644
@@ -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)
Signature · 6 lines
2.17.1

_______________________________________________
iommu mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/iommu
maintainer
#4 lore raw
In reply to Lu Baolu
Quoted 9 lines · Lu Baolu

Hi Joerg,

There are another two small fixes queued in my tree.

Can you please consider them for v5.6?

Best regards,
-baolu

Quoted 8 lines

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
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/iommu

author
#6 lore raw
Quoted 3 lines · Joerg Roedel
Quoted 2 lines · Lu Baolu

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

Quoted 3 lines
Quoted 3 lines

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

Quoted 3 lines

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

Sure.

Best regards,
baolu
_______________________________________________
iommu mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/iommu

#3 lore raw

Re: [PATCH 2/2] iommu/vt-d: Ignore devices with out-of-spec domain number

In reply to Lu Baolu

drivers/iommu/dmar.c dmar_alloc_pci_notify_info(struct pci_dev *dev, unsigned long event) · line 136

Quoted 9 lines · Lu Baolu
drivers/iommu/dmar.c +5 -0
@@ -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.