IOMMU Fixes for Linux v3.17-rc1

The fixes include:
 
 	* A patch to fix a crash in the VT-d driver when devices with a
 	  driver attached are hot-unplugged
 
 	* A patch for the AMD IOMMU driver to fix a crash with device
 	  assignment of 32 bit PCI devices to KVM guests
 
 	* Fix for a copy&paste error in generic IOMMU code. Now the
 	  right function pointer is checked before calling.
 -----BEGIN PGP SIGNATURE-----
 Version: GnuPG v2.0.22 (GNU/Linux)
 
 iQIcBAABAgAGBQJT9mqKAAoJECvwRC2XARrjVyEQANuc6QDV9DcmXkd+3sXOtC/s
 VA5G8CCxqiDmit+p2/o9+Bq7vbIIWEI140AU4LMSubFoshTejKZn3ejpGkKK/+cB
 qAqyoJNnjiuyEcGpXLxlOwM57/6NFTU5GGT5FqKqTZ8o2jVZHLAqbVXwp0ywww9n
 3j0NQMAmwEmxIzuM29WBVC4ioD5AJYE8z4NOL36rR97cJ3BGA3uH7DbLKpibjOo7
 gz+wW6csRKPODfPhf/08tuR8tgxwo9F03EmJ6ZD1N0/Y3uSqf1FksWE+nDUoszgX
 L6iTkW+d3kDBbqRPaxyr35yPYFALMdvrMsrzqw8b6pcyYFND6XoSj30iGcJJ+8xf
 7jKYTKOfXCZjWNpGovps+dCgBmd4Aa1II8uRn+bVK+ZQuu7Wur5iFvZKAQ0qgjXn
 H86jjwOwBKihnljtdNquU6QjDsE/0wP1qnnkCubcRyYirZiWTEIAqdM/KMy/8298
 KEO7IBAwOw1k2B0kRiOJx762Mz2xsL8+o08AnJxOv6NZ1Jpbl976bUwQu26ILVzm
 FBicMCEFgWBxZ4n9utAZTYLsChMInqwnmQmhnlmN+L0gc5HZli+ACUmgQZx/k80L
 eG6qiUr1TlrEgEZn4IitxyZxPWeekJRb0JLAG0syDVO4EREHW9JGo0u7WRlruqU1
 I02opq+flSipokaWomoh
 =KWBo
 -----END PGP SIGNATURE-----

Merge tag 'iommu-fixes-v3.17-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/joro/iommu

Pull IOMMU fixes from Joerg Roedel:
 "The fixes include:

   - fix a crash in the VT-d driver when devices with a driver attached
     are hot-unplugged

   - fix a AMD IOMMU driver crash with device assignment of 32 bit PCI
     devices to KVM guests

   - fix for a copy&paste error in generic IOMMU code.  Now the right
     function pointer is checked before calling"

* tag 'iommu-fixes-v3.17-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/joro/iommu:
  iommu/core: Check for the right function pointer in iommu_map()
  iommu/amd: Fix cleanup_domain for mass device removal
  iommu/vt-d: Defer domain removal if device is assigned to a driver
This commit is contained in:
Linus Torvalds 2014-08-22 09:06:22 -07:00
commit 1ae45cf06c
3 changed files with 15 additions and 5 deletions

View file

@ -3149,14 +3149,16 @@ int __init amd_iommu_init_dma_ops(void)
static void cleanup_domain(struct protection_domain *domain)
{
struct iommu_dev_data *dev_data, *next;
struct iommu_dev_data *entry;
unsigned long flags;
write_lock_irqsave(&amd_iommu_devtable_lock, flags);
list_for_each_entry_safe(dev_data, next, &domain->dev_list, list) {
__detach_device(dev_data);
atomic_set(&dev_data->bind, 0);
while (!list_empty(&domain->dev_list)) {
entry = list_first_entry(&domain->dev_list,
struct iommu_dev_data, list);
__detach_device(entry);
atomic_set(&entry->bind, 0);
}
write_unlock_irqrestore(&amd_iommu_devtable_lock, flags);

View file

@ -3869,6 +3869,14 @@ static int device_notifier(struct notifier_block *nb,
action != BUS_NOTIFY_DEL_DEVICE)
return 0;
/*
* If the device is still attached to a device driver we can't
* tear down the domain yet as DMA mappings may still be in use.
* Wait for the BUS_NOTIFY_UNBOUND_DRIVER event to do that.
*/
if (action == BUS_NOTIFY_DEL_DEVICE && dev->driver != NULL)
return 0;
domain = find_domain(dev);
if (!domain)
return 0;

View file

@ -995,7 +995,7 @@ int iommu_map(struct iommu_domain *domain, unsigned long iova,
size_t orig_size = size;
int ret = 0;
if (unlikely(domain->ops->unmap == NULL ||
if (unlikely(domain->ops->map == NULL ||
domain->ops->pgsize_bitmap == 0UL))
return -ENODEV;