Skip to content

Commit e6a8c9b

Browse files
committed
iommu/vt-d: Use BUS_NOTIFY_REMOVED_DEVICE in hotplug path
In the PCI hotplug path of the Intel IOMMU driver, replace the usage of the BUS_NOTIFY_DEL_DEVICE notifier, which is executed before the driver is unbound from the device, with BUS_NOTIFY_REMOVED_DEVICE, which runs after that. This fixes a kernel BUG being triggered in the VT-d code when the device driver tries to unmap DMA buffers and the VT-d driver already destroyed all mappings. Reported-by: Stefani Seibold <[email protected]> Cc: [email protected] # v4.3+ Signed-off-by: Joerg Roedel <[email protected]>
1 parent b6809ee commit e6a8c9b

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

drivers/iommu/dmar.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,8 @@ static int dmar_pci_bus_notifier(struct notifier_block *nb,
329329
/* Only care about add/remove events for physical functions */
330330
if (pdev->is_virtfn)
331331
return NOTIFY_DONE;
332-
if (action != BUS_NOTIFY_ADD_DEVICE && action != BUS_NOTIFY_DEL_DEVICE)
332+
if (action != BUS_NOTIFY_ADD_DEVICE &&
333+
action != BUS_NOTIFY_REMOVED_DEVICE)
333334
return NOTIFY_DONE;
334335

335336
info = dmar_alloc_pci_notify_info(pdev, action);
@@ -339,7 +340,7 @@ static int dmar_pci_bus_notifier(struct notifier_block *nb,
339340
down_write(&dmar_global_lock);
340341
if (action == BUS_NOTIFY_ADD_DEVICE)
341342
dmar_pci_bus_add_dev(info);
342-
else if (action == BUS_NOTIFY_DEL_DEVICE)
343+
else if (action == BUS_NOTIFY_REMOVED_DEVICE)
343344
dmar_pci_bus_del_dev(info);
344345
up_write(&dmar_global_lock);
345346

drivers/iommu/intel-iommu.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4367,7 +4367,7 @@ int dmar_iommu_notify_scope_dev(struct dmar_pci_notify_info *info)
43674367
rmrru->devices_cnt);
43684368
if(ret < 0)
43694369
return ret;
4370-
} else if (info->event == BUS_NOTIFY_DEL_DEVICE) {
4370+
} else if (info->event == BUS_NOTIFY_REMOVED_DEVICE) {
43714371
dmar_remove_dev_scope(info, rmrr->segment,
43724372
rmrru->devices, rmrru->devices_cnt);
43734373
}
@@ -4387,7 +4387,7 @@ int dmar_iommu_notify_scope_dev(struct dmar_pci_notify_info *info)
43874387
break;
43884388
else if(ret < 0)
43894389
return ret;
4390-
} else if (info->event == BUS_NOTIFY_DEL_DEVICE) {
4390+
} else if (info->event == BUS_NOTIFY_REMOVED_DEVICE) {
43914391
if (dmar_remove_dev_scope(info, atsr->segment,
43924392
atsru->devices, atsru->devices_cnt))
43934393
break;

0 commit comments

Comments
 (0)