Skip to content

Commit 117266f

Browse files
LuBaolujoergroedel
authored andcommitted
iommu/vt-d: Check identity map for hot-added devices
The Intel IOMMU driver will put devices into a static identity mapped domain during boot if the kernel parameter "iommu=pt" is used. That means the IOMMU hardware will translate a DMA address into the same memory address. Unfortunately, hot-added devices are not subject to this. That results in some devices not working properly after hot added. A quick way to reproduce this issue is to boot a system with iommu=pt and, remove then readd the pci device with echo 1 > /sys/bus/pci/devices/[pci_source_id]/remove echo 1 > /sys/bus/pci/rescan You will find the identity mapped domain was replaced with a normal domain. Cc: Ashok Raj <ashok.raj@intel.com> Cc: Jacob Pan <jacob.jun.pan@linux.intel.com> Cc: Fenghua Yu <fenghua.yu@intel.com> Cc: stable@vger.kernel.org Reported-by: Jis Ben <jisben@google.com> Signed-off-by: Lu Baolu <baolu.lu@linux.intel.com> Tested-by: James Dong <xmdong@google.com> Fixes: 99dcade ('intel-iommu: Support PCIe hot-plug') Signed-off-by: Joerg Roedel <jroedel@suse.de>
1 parent 61363c1 commit 117266f

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

drivers/iommu/intel-iommu.c

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4567,16 +4567,19 @@ static int device_notifier(struct notifier_block *nb,
45674567
if (iommu_dummy(dev))
45684568
return 0;
45694569

4570-
if (action != BUS_NOTIFY_REMOVED_DEVICE)
4571-
return 0;
4572-
4573-
domain = find_domain(dev);
4574-
if (!domain)
4575-
return 0;
4570+
if (action == BUS_NOTIFY_REMOVED_DEVICE) {
4571+
domain = find_domain(dev);
4572+
if (!domain)
4573+
return 0;
45764574

4577-
dmar_remove_one_dev_info(dev);
4578-
if (!domain_type_is_vm_or_si(domain) && list_empty(&domain->devices))
4579-
domain_exit(domain);
4575+
dmar_remove_one_dev_info(dev);
4576+
if (!domain_type_is_vm_or_si(domain) &&
4577+
list_empty(&domain->devices))
4578+
domain_exit(domain);
4579+
} else if (action == BUS_NOTIFY_ADD_DEVICE) {
4580+
if (iommu_should_identity_map(dev, 1))
4581+
domain_add_dev_info(si_domain, dev);
4582+
}
45804583

45814584
return 0;
45824585
}

0 commit comments

Comments
 (0)