Skip to content

Commit 316f92a

Browse files
yianchen2018joergroedel
authored andcommitted
iommu/vt-d: Fix PCI bus rescan device hot add
Notifier calling chain uses priority to determine the execution order of the notifiers or listeners registered to the chain. PCI bus device hot add utilizes the notification mechanism. The current code sets low priority (INT_MIN) to Intel dmar_pci_bus_notifier and postpones DMAR decoding after adding new device into IOMMU. The result is that struct device pointer cannot be found in DRHD search for the new device's DMAR/IOMMU. Subsequently, the device is put under the "catch-all" IOMMU instead of the correct one. This could cause system hang when device TLB invalidation is sent to the wrong IOMMU. Invalidation timeout error and hard lockup have been observed and data inconsistency/crush may occur as well. This patch fixes the issue by setting a positive priority(1) for dmar_pci_bus_notifier while the priority of IOMMU bus notifier uses the default value(0), therefore DMAR decoding will be in advance of DRHD search for a new device to find the correct IOMMU. Following is a 2-step example that triggers the bug by simulating PCI device hot add behavior in Intel Sapphire Rapids server. echo 1 > /sys/bus/pci/devices/0000:6a:01.0/remove echo 1 > /sys/bus/pci/rescan Fixes: 59ce051 ("iommu/vt-d: Update DRHD/RMRR/ATSR device scope") Cc: [email protected] # v3.15+ Reported-by: Zhang, Bernice <[email protected]> Signed-off-by: Jacob Pan <[email protected]> Signed-off-by: Yian Chen <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Joerg Roedel <[email protected]>
1 parent 88084a3 commit 316f92a

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

drivers/iommu/intel/dmar.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,7 @@ static int dmar_pci_bus_notifier(struct notifier_block *nb,
382382

383383
static struct notifier_block dmar_pci_bus_nb = {
384384
.notifier_call = dmar_pci_bus_notifier,
385-
.priority = INT_MIN,
385+
.priority = 1,
386386
};
387387

388388
static struct dmar_drhd_unit *

0 commit comments

Comments
 (0)