Skip to content

Commit e97eace

Browse files
committed
Merge tag 'iommu-fixes-v6.1-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/joro/iommu
Pull iommu fixes from Joerg Roedel: "Intel VT-d fixes: - Fix a lockdep splat issue in intel_iommu_init() - Allow NVS regions to pass RMRR check - Domain cleanup in error path" * tag 'iommu-fixes-v6.1-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/joro/iommu: iommu/vt-d: Clean up si_domain in the init_dmars() error path iommu/vt-d: Allow NVS regions in arch_rmrr_sanity_check() iommu/vt-d: Use rcu_lock in get_resv_regions iommu: Add gfp parameter to iommu_alloc_resv_region
2 parents 334fe5d + 620bf9f commit e97eace

File tree

11 files changed

+37
-21
lines changed

11 files changed

+37
-21
lines changed

arch/x86/include/asm/iommu.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,10 @@ arch_rmrr_sanity_check(struct acpi_dmar_reserved_memory *rmrr)
2525
{
2626
u64 start = rmrr->base_address;
2727
u64 end = rmrr->end_address + 1;
28+
int entry_type;
2829

29-
if (e820__mapped_all(start, end, E820_TYPE_RESERVED))
30+
entry_type = e820__get_entry_type(start, end);
31+
if (entry_type == E820_TYPE_RESERVED || entry_type == E820_TYPE_NVS)
3032
return 0;
3133

3234
pr_err(FW_BUG "No firmware reserved region can cover this RMRR [%#018Lx-%#018Lx], contact BIOS vendor for fixes\n",

drivers/acpi/arm64/iort.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1142,7 +1142,8 @@ static void iort_iommu_msi_get_resv_regions(struct device *dev,
11421142
struct iommu_resv_region *region;
11431143

11441144
region = iommu_alloc_resv_region(base + SZ_64K, SZ_64K,
1145-
prot, IOMMU_RESV_MSI);
1145+
prot, IOMMU_RESV_MSI,
1146+
GFP_KERNEL);
11461147
if (region)
11471148
list_add_tail(&region->list, head);
11481149
}

drivers/iommu/amd/iommu.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2330,7 +2330,8 @@ static void amd_iommu_get_resv_regions(struct device *dev,
23302330
type = IOMMU_RESV_RESERVED;
23312331

23322332
region = iommu_alloc_resv_region(entry->address_start,
2333-
length, prot, type);
2333+
length, prot, type,
2334+
GFP_KERNEL);
23342335
if (!region) {
23352336
dev_err(dev, "Out of memory allocating dm-regions\n");
23362337
return;
@@ -2340,14 +2341,14 @@ static void amd_iommu_get_resv_regions(struct device *dev,
23402341

23412342
region = iommu_alloc_resv_region(MSI_RANGE_START,
23422343
MSI_RANGE_END - MSI_RANGE_START + 1,
2343-
0, IOMMU_RESV_MSI);
2344+
0, IOMMU_RESV_MSI, GFP_KERNEL);
23442345
if (!region)
23452346
return;
23462347
list_add_tail(&region->list, head);
23472348

23482349
region = iommu_alloc_resv_region(HT_RANGE_START,
23492350
HT_RANGE_END - HT_RANGE_START + 1,
2350-
0, IOMMU_RESV_RESERVED);
2351+
0, IOMMU_RESV_RESERVED, GFP_KERNEL);
23512352
if (!region)
23522353
return;
23532354
list_add_tail(&region->list, head);

drivers/iommu/apple-dart.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -758,7 +758,7 @@ static void apple_dart_get_resv_regions(struct device *dev,
758758

759759
region = iommu_alloc_resv_region(DOORBELL_ADDR,
760760
PAGE_SIZE, prot,
761-
IOMMU_RESV_MSI);
761+
IOMMU_RESV_MSI, GFP_KERNEL);
762762
if (!region)
763763
return;
764764

drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2757,7 +2757,7 @@ static void arm_smmu_get_resv_regions(struct device *dev,
27572757
int prot = IOMMU_WRITE | IOMMU_NOEXEC | IOMMU_MMIO;
27582758

27592759
region = iommu_alloc_resv_region(MSI_IOVA_BASE, MSI_IOVA_LENGTH,
2760-
prot, IOMMU_RESV_SW_MSI);
2760+
prot, IOMMU_RESV_SW_MSI, GFP_KERNEL);
27612761
if (!region)
27622762
return;
27632763

drivers/iommu/arm/arm-smmu/arm-smmu.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1534,7 +1534,7 @@ static void arm_smmu_get_resv_regions(struct device *dev,
15341534
int prot = IOMMU_WRITE | IOMMU_NOEXEC | IOMMU_MMIO;
15351535

15361536
region = iommu_alloc_resv_region(MSI_IOVA_BASE, MSI_IOVA_LENGTH,
1537-
prot, IOMMU_RESV_SW_MSI);
1537+
prot, IOMMU_RESV_SW_MSI, GFP_KERNEL);
15381538
if (!region)
15391539
return;
15401540

drivers/iommu/intel/iommu.c

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2410,6 +2410,7 @@ static int __init si_domain_init(int hw)
24102410

24112411
if (md_domain_init(si_domain, DEFAULT_DOMAIN_ADDRESS_WIDTH)) {
24122412
domain_exit(si_domain);
2413+
si_domain = NULL;
24132414
return -EFAULT;
24142415
}
24152416

@@ -3052,6 +3053,10 @@ static int __init init_dmars(void)
30523053
disable_dmar_iommu(iommu);
30533054
free_dmar_iommu(iommu);
30543055
}
3056+
if (si_domain) {
3057+
domain_exit(si_domain);
3058+
si_domain = NULL;
3059+
}
30553060

30563061
return ret;
30573062
}
@@ -4534,7 +4539,7 @@ static void intel_iommu_get_resv_regions(struct device *device,
45344539
struct device *i_dev;
45354540
int i;
45364541

4537-
down_read(&dmar_global_lock);
4542+
rcu_read_lock();
45384543
for_each_rmrr_units(rmrr) {
45394544
for_each_active_dev_scope(rmrr->devices, rmrr->devices_cnt,
45404545
i, i_dev) {
@@ -4552,22 +4557,24 @@ static void intel_iommu_get_resv_regions(struct device *device,
45524557
IOMMU_RESV_DIRECT_RELAXABLE : IOMMU_RESV_DIRECT;
45534558

45544559
resv = iommu_alloc_resv_region(rmrr->base_address,
4555-
length, prot, type);
4560+
length, prot, type,
4561+
GFP_ATOMIC);
45564562
if (!resv)
45574563
break;
45584564

45594565
list_add_tail(&resv->list, head);
45604566
}
45614567
}
4562-
up_read(&dmar_global_lock);
4568+
rcu_read_unlock();
45634569

45644570
#ifdef CONFIG_INTEL_IOMMU_FLOPPY_WA
45654571
if (dev_is_pci(device)) {
45664572
struct pci_dev *pdev = to_pci_dev(device);
45674573

45684574
if ((pdev->class >> 8) == PCI_CLASS_BRIDGE_ISA) {
45694575
reg = iommu_alloc_resv_region(0, 1UL << 24, prot,
4570-
IOMMU_RESV_DIRECT_RELAXABLE);
4576+
IOMMU_RESV_DIRECT_RELAXABLE,
4577+
GFP_KERNEL);
45714578
if (reg)
45724579
list_add_tail(&reg->list, head);
45734580
}
@@ -4576,7 +4583,7 @@ static void intel_iommu_get_resv_regions(struct device *device,
45764583

45774584
reg = iommu_alloc_resv_region(IOAPIC_RANGE_START,
45784585
IOAPIC_RANGE_END - IOAPIC_RANGE_START + 1,
4579-
0, IOMMU_RESV_MSI);
4586+
0, IOMMU_RESV_MSI, GFP_KERNEL);
45804587
if (!reg)
45814588
return;
45824589
list_add_tail(&reg->list, head);

drivers/iommu/iommu.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -504,7 +504,7 @@ static int iommu_insert_resv_region(struct iommu_resv_region *new,
504504
LIST_HEAD(stack);
505505

506506
nr = iommu_alloc_resv_region(new->start, new->length,
507-
new->prot, new->type);
507+
new->prot, new->type, GFP_KERNEL);
508508
if (!nr)
509509
return -ENOMEM;
510510

@@ -2579,11 +2579,12 @@ EXPORT_SYMBOL(iommu_put_resv_regions);
25792579

25802580
struct iommu_resv_region *iommu_alloc_resv_region(phys_addr_t start,
25812581
size_t length, int prot,
2582-
enum iommu_resv_type type)
2582+
enum iommu_resv_type type,
2583+
gfp_t gfp)
25832584
{
25842585
struct iommu_resv_region *region;
25852586

2586-
region = kzalloc(sizeof(*region), GFP_KERNEL);
2587+
region = kzalloc(sizeof(*region), gfp);
25872588
if (!region)
25882589
return NULL;
25892590

drivers/iommu/mtk_iommu.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -917,7 +917,8 @@ static void mtk_iommu_get_resv_regions(struct device *dev,
917917
continue;
918918

919919
region = iommu_alloc_resv_region(resv->iova_base, resv->size,
920-
prot, IOMMU_RESV_RESERVED);
920+
prot, IOMMU_RESV_RESERVED,
921+
GFP_KERNEL);
921922
if (!region)
922923
return;
923924

drivers/iommu/virtio-iommu.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -490,11 +490,13 @@ static int viommu_add_resv_mem(struct viommu_endpoint *vdev,
490490
fallthrough;
491491
case VIRTIO_IOMMU_RESV_MEM_T_RESERVED:
492492
region = iommu_alloc_resv_region(start, size, 0,
493-
IOMMU_RESV_RESERVED);
493+
IOMMU_RESV_RESERVED,
494+
GFP_KERNEL);
494495
break;
495496
case VIRTIO_IOMMU_RESV_MEM_T_MSI:
496497
region = iommu_alloc_resv_region(start, size, prot,
497-
IOMMU_RESV_MSI);
498+
IOMMU_RESV_MSI,
499+
GFP_KERNEL);
498500
break;
499501
}
500502
if (!region)
@@ -909,7 +911,8 @@ static void viommu_get_resv_regions(struct device *dev, struct list_head *head)
909911
*/
910912
if (!msi) {
911913
msi = iommu_alloc_resv_region(MSI_IOVA_BASE, MSI_IOVA_LENGTH,
912-
prot, IOMMU_RESV_SW_MSI);
914+
prot, IOMMU_RESV_SW_MSI,
915+
GFP_KERNEL);
913916
if (!msi)
914917
return;
915918

0 commit comments

Comments
 (0)