Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge tag 'iommu-fixes-v5.1-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/joro/iommu

Pull IOMMU fixes from Joerg Roedel:

- Fix a bug in the AMD IOMMU driver not handling exclusion ranges
correctly. In fact the driver did not reserve these ranges for IOVA
allocations, so that dma-handles could be allocated in an exclusion
range, leading to data corruption. Exclusion ranges have not been
used by any firmware up to now, so this issue remained undiscovered
for quite some time.

- Fix wrong warning messages that the IOMMU core code prints when it
tries to allocate the default domain for an iommu group and the
driver does not support any of the default domain types (like Intel
VT-d).

* tag 'iommu-fixes-v5.1-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/joro/iommu:
iommu/amd: Reserve exclusion range in iova-domain
iommu: Don't print warning when IOMMU driver only supports unmanaged domains

+17 -9
+6 -3
drivers/iommu/amd_iommu.c
··· 3169 3169 return; 3170 3170 3171 3171 list_for_each_entry(entry, &amd_iommu_unity_map, list) { 3172 + int type, prot = 0; 3172 3173 size_t length; 3173 - int prot = 0; 3174 3174 3175 3175 if (devid < entry->devid_start || devid > entry->devid_end) 3176 3176 continue; 3177 3177 3178 + type = IOMMU_RESV_DIRECT; 3178 3179 length = entry->address_end - entry->address_start; 3179 3180 if (entry->prot & IOMMU_PROT_IR) 3180 3181 prot |= IOMMU_READ; 3181 3182 if (entry->prot & IOMMU_PROT_IW) 3182 3183 prot |= IOMMU_WRITE; 3184 + if (entry->prot & IOMMU_UNITY_MAP_FLAG_EXCL_RANGE) 3185 + /* Exclusion range */ 3186 + type = IOMMU_RESV_RESERVED; 3183 3187 3184 3188 region = iommu_alloc_resv_region(entry->address_start, 3185 - length, prot, 3186 - IOMMU_RESV_DIRECT); 3189 + length, prot, type); 3187 3190 if (!region) { 3188 3191 dev_err(dev, "Out of memory allocating dm-regions\n"); 3189 3192 return;
+4 -3
drivers/iommu/amd_iommu_init.c
··· 2013 2013 if (e == NULL) 2014 2014 return -ENOMEM; 2015 2015 2016 + if (m->flags & IVMD_FLAG_EXCL_RANGE) 2017 + init_exclusion_range(m); 2018 + 2016 2019 switch (m->type) { 2017 2020 default: 2018 2021 kfree(e); ··· 2062 2059 2063 2060 while (p < end) { 2064 2061 m = (struct ivmd_header *)p; 2065 - if (m->flags & IVMD_FLAG_EXCL_RANGE) 2066 - init_exclusion_range(m); 2067 - else if (m->flags & IVMD_FLAG_UNITY_MAP) 2062 + if (m->flags & (IVMD_FLAG_UNITY_MAP | IVMD_FLAG_EXCL_RANGE)) 2068 2063 init_unity_map_range(m); 2069 2064 2070 2065 p += m->length;
+2
drivers/iommu/amd_iommu_types.h
··· 374 374 #define IOMMU_PROT_IR 0x01 375 375 #define IOMMU_PROT_IW 0x02 376 376 377 + #define IOMMU_UNITY_MAP_FLAG_EXCL_RANGE (1 << 2) 378 + 377 379 /* IOMMU capabilities */ 378 380 #define IOMMU_CAP_IOTLB 24 379 381 #define IOMMU_CAP_NPCACHE 26
+5 -3
drivers/iommu/iommu.c
··· 1105 1105 1106 1106 dom = __iommu_domain_alloc(dev->bus, iommu_def_domain_type); 1107 1107 if (!dom && iommu_def_domain_type != IOMMU_DOMAIN_DMA) { 1108 - dev_warn(dev, 1109 - "failed to allocate default IOMMU domain of type %u; falling back to IOMMU_DOMAIN_DMA", 1110 - iommu_def_domain_type); 1111 1108 dom = __iommu_domain_alloc(dev->bus, IOMMU_DOMAIN_DMA); 1109 + if (dom) { 1110 + dev_warn(dev, 1111 + "failed to allocate default IOMMU domain of type %u; falling back to IOMMU_DOMAIN_DMA", 1112 + iommu_def_domain_type); 1113 + } 1112 1114 } 1113 1115 1114 1116 group->default_domain = dom;