Skip to content

Commit aa7a6c8

Browse files
committed
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()
2 parents 1a0a02d + 6082ee7 commit aa7a6c8

File tree

3 files changed

+8
-4
lines changed

3 files changed

+8
-4
lines changed

drivers/iommu/amd_iommu_init.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1107,13 +1107,13 @@ static int __init init_iommu_from_acpi(struct amd_iommu *iommu,
11071107
break;
11081108
}
11091109

1110+
devid = e->devid;
11101111
DUMP_printk(" DEV_ACPI_HID(%s[%s])\t\tdevid: %02x:%02x.%x\n",
11111112
hid, uid,
11121113
PCI_BUS_NUM(devid),
11131114
PCI_SLOT(devid),
11141115
PCI_FUNC(devid));
11151116

1116-
devid = e->devid;
11171117
flags = e->flags;
11181118

11191119
ret = add_acpi_hid_device(hid, uid, &devid, false);

drivers/iommu/intel-iommu.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4607,7 +4607,7 @@ static void free_all_cpu_cached_iovas(unsigned int cpu)
46074607
if (!iommu)
46084608
continue;
46094609

4610-
for (did = 0; did < 0xffff; did++) {
4610+
for (did = 0; did < cap_ndoms(iommu->cap); did++) {
46114611
domain = get_iommu_domain(iommu, did);
46124612

46134613
if (!domain)

drivers/iommu/iova.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -420,8 +420,10 @@ alloc_iova_fast(struct iova_domain *iovad, unsigned long size,
420420

421421
/* Try replenishing IOVAs by flushing rcache. */
422422
flushed_rcache = true;
423+
preempt_disable();
423424
for_each_online_cpu(cpu)
424425
free_cpu_cached_iovas(cpu, iovad);
426+
preempt_enable();
425427
goto retry;
426428
}
427429

@@ -749,7 +751,7 @@ static bool __iova_rcache_insert(struct iova_domain *iovad,
749751
bool can_insert = false;
750752
unsigned long flags;
751753

752-
cpu_rcache = this_cpu_ptr(rcache->cpu_rcaches);
754+
cpu_rcache = get_cpu_ptr(rcache->cpu_rcaches);
753755
spin_lock_irqsave(&cpu_rcache->lock, flags);
754756

755757
if (!iova_magazine_full(cpu_rcache->loaded)) {
@@ -779,6 +781,7 @@ static bool __iova_rcache_insert(struct iova_domain *iovad,
779781
iova_magazine_push(cpu_rcache->loaded, iova_pfn);
780782

781783
spin_unlock_irqrestore(&cpu_rcache->lock, flags);
784+
put_cpu_ptr(rcache->cpu_rcaches);
782785

783786
if (mag_to_free) {
784787
iova_magazine_free_pfns(mag_to_free, iovad);
@@ -812,7 +815,7 @@ static unsigned long __iova_rcache_get(struct iova_rcache *rcache,
812815
bool has_pfn = false;
813816
unsigned long flags;
814817

815-
cpu_rcache = this_cpu_ptr(rcache->cpu_rcaches);
818+
cpu_rcache = get_cpu_ptr(rcache->cpu_rcaches);
816819
spin_lock_irqsave(&cpu_rcache->lock, flags);
817820

818821
if (!iova_magazine_empty(cpu_rcache->loaded)) {
@@ -834,6 +837,7 @@ static unsigned long __iova_rcache_get(struct iova_rcache *rcache,
834837
iova_pfn = iova_magazine_pop(cpu_rcache->loaded, limit_pfn);
835838

836839
spin_unlock_irqrestore(&cpu_rcache->lock, flags);
840+
put_cpu_ptr(rcache->cpu_rcaches);
837841

838842
return iova_pfn;
839843
}

0 commit comments

Comments
 (0)