aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2016-07-01 12:13:31 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2016-07-01 12:13:31 -0400
commitaa7a6c8e5252ba28f36a8f87b9acd6a726aa3ae5 (patch)
tree42ad78abf19100d237cc780fe4f90effb2a1d7b2
parent1a0a02d1efa066001fd315c1b4df583d939fa2c4 (diff)
parent6082ee72e9d89e80a664418be06f47d728243e85 (diff)
Merge tag 'iommu-fixes-v4.7-rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/joro/iommu
Pull IOMMU fixes from Joerg Roedel: "Three fixes: - Fix use of smp_processor_id() in preemptible code in the IOVA allocation code. This got introduced with the scalability improvements in this release cycle. - A VT-d fix for out-of-bounds access of the iommu->domains array. The bug showed during suspend/resume. - AMD IOMMU fix to print the correct device id in the ACPI parsing code" * tag 'iommu-fixes-v4.7-rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/joro/iommu: iommu/amd: Initialize devid variable before using it iommu/vt-d: Fix overflow of iommu->domains array iommu/iova: Disable preemption around use of this_cpu_ptr()
-rw-r--r--drivers/iommu/amd_iommu_init.c2
-rw-r--r--drivers/iommu/intel-iommu.c2
-rw-r--r--drivers/iommu/iova.c8
3 files changed, 8 insertions, 4 deletions
diff --git a/drivers/iommu/amd_iommu_init.c b/drivers/iommu/amd_iommu_init.c
index 9e0034196e10..d091defc3426 100644
--- a/drivers/iommu/amd_iommu_init.c
+++ b/drivers/iommu/amd_iommu_init.c
@@ -1107,13 +1107,13 @@ static int __init init_iommu_from_acpi(struct amd_iommu *iommu,
1107 break; 1107 break;
1108 } 1108 }
1109 1109
1110 devid = e->devid;
1110 DUMP_printk(" DEV_ACPI_HID(%s[%s])\t\tdevid: %02x:%02x.%x\n", 1111 DUMP_printk(" DEV_ACPI_HID(%s[%s])\t\tdevid: %02x:%02x.%x\n",
1111 hid, uid, 1112 hid, uid,
1112 PCI_BUS_NUM(devid), 1113 PCI_BUS_NUM(devid),
1113 PCI_SLOT(devid), 1114 PCI_SLOT(devid),
1114 PCI_FUNC(devid)); 1115 PCI_FUNC(devid));
1115 1116
1116 devid = e->devid;
1117 flags = e->flags; 1117 flags = e->flags;
1118 1118
1119 ret = add_acpi_hid_device(hid, uid, &devid, false); 1119 ret = add_acpi_hid_device(hid, uid, &devid, false);
diff --git a/drivers/iommu/intel-iommu.c b/drivers/iommu/intel-iommu.c
index 10700945994e..cfe410eedaf0 100644
--- a/drivers/iommu/intel-iommu.c
+++ b/drivers/iommu/intel-iommu.c
@@ -4607,7 +4607,7 @@ static void free_all_cpu_cached_iovas(unsigned int cpu)
4607 if (!iommu) 4607 if (!iommu)
4608 continue; 4608 continue;
4609 4609
4610 for (did = 0; did < 0xffff; did++) { 4610 for (did = 0; did < cap_ndoms(iommu->cap); did++) {
4611 domain = get_iommu_domain(iommu, did); 4611 domain = get_iommu_domain(iommu, did);
4612 4612
4613 if (!domain) 4613 if (!domain)
diff --git a/drivers/iommu/iova.c b/drivers/iommu/iova.c
index ba764a0835d3..e23001bfcfee 100644
--- a/drivers/iommu/iova.c
+++ b/drivers/iommu/iova.c
@@ -420,8 +420,10 @@ retry:
420 420
421 /* Try replenishing IOVAs by flushing rcache. */ 421 /* Try replenishing IOVAs by flushing rcache. */
422 flushed_rcache = true; 422 flushed_rcache = true;
423 preempt_disable();
423 for_each_online_cpu(cpu) 424 for_each_online_cpu(cpu)
424 free_cpu_cached_iovas(cpu, iovad); 425 free_cpu_cached_iovas(cpu, iovad);
426 preempt_enable();
425 goto retry; 427 goto retry;
426 } 428 }
427 429
@@ -749,7 +751,7 @@ static bool __iova_rcache_insert(struct iova_domain *iovad,
749 bool can_insert = false; 751 bool can_insert = false;
750 unsigned long flags; 752 unsigned long flags;
751 753
752 cpu_rcache = this_cpu_ptr(rcache->cpu_rcaches); 754 cpu_rcache = get_cpu_ptr(rcache->cpu_rcaches);
753 spin_lock_irqsave(&cpu_rcache->lock, flags); 755 spin_lock_irqsave(&cpu_rcache->lock, flags);
754 756
755 if (!iova_magazine_full(cpu_rcache->loaded)) { 757 if (!iova_magazine_full(cpu_rcache->loaded)) {
@@ -779,6 +781,7 @@ static bool __iova_rcache_insert(struct iova_domain *iovad,
779 iova_magazine_push(cpu_rcache->loaded, iova_pfn); 781 iova_magazine_push(cpu_rcache->loaded, iova_pfn);
780 782
781 spin_unlock_irqrestore(&cpu_rcache->lock, flags); 783 spin_unlock_irqrestore(&cpu_rcache->lock, flags);
784 put_cpu_ptr(rcache->cpu_rcaches);
782 785
783 if (mag_to_free) { 786 if (mag_to_free) {
784 iova_magazine_free_pfns(mag_to_free, iovad); 787 iova_magazine_free_pfns(mag_to_free, iovad);
@@ -812,7 +815,7 @@ static unsigned long __iova_rcache_get(struct iova_rcache *rcache,
812 bool has_pfn = false; 815 bool has_pfn = false;
813 unsigned long flags; 816 unsigned long flags;
814 817
815 cpu_rcache = this_cpu_ptr(rcache->cpu_rcaches); 818 cpu_rcache = get_cpu_ptr(rcache->cpu_rcaches);
816 spin_lock_irqsave(&cpu_rcache->lock, flags); 819 spin_lock_irqsave(&cpu_rcache->lock, flags);
817 820
818 if (!iova_magazine_empty(cpu_rcache->loaded)) { 821 if (!iova_magazine_empty(cpu_rcache->loaded)) {
@@ -834,6 +837,7 @@ static unsigned long __iova_rcache_get(struct iova_rcache *rcache,
834 iova_pfn = iova_magazine_pop(cpu_rcache->loaded, limit_pfn); 837 iova_pfn = iova_magazine_pop(cpu_rcache->loaded, limit_pfn);
835 838
836 spin_unlock_irqrestore(&cpu_rcache->lock, flags); 839 spin_unlock_irqrestore(&cpu_rcache->lock, flags);
840 put_cpu_ptr(rcache->cpu_rcaches);
837 841
838 return iova_pfn; 842 return iova_pfn;
839} 843}