Skip to content

Commit c2b00cb

Browse files
committed
Merge tag 'iommu-fixes-v5.7-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/joro/iommu
Pull iommu fixes from Joerg Roedel: "All related to the AMD IOMMU driver: - ACPI table parser fix to correctly read the UID of ACPI devices - ACPI UID device matching fix - Fix deferred device attachment to a domain in kdump kernels when the IOMMU driver uses the dma-iommu DMA-API implementation" * tag 'iommu-fixes-v5.7-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/joro/iommu: iommu: Fix deferred domain attachment iommu/amd: Fix get_acpihid_device_id() iommu/amd: Fix over-read of ACPI UID from IVRS table
2 parents 7bd57fb + bd42126 commit c2b00cb

File tree

3 files changed

+18
-11
lines changed

3 files changed

+18
-11
lines changed

drivers/iommu/amd_iommu.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,8 @@ static inline int get_acpihid_device_id(struct device *dev,
127127
return -ENODEV;
128128

129129
list_for_each_entry(p, &acpihid_map, list) {
130-
if (acpi_dev_hid_uid_match(adev, p->hid, p->uid)) {
130+
if (acpi_dev_hid_uid_match(adev, p->hid,
131+
p->uid[0] ? p->uid : NULL)) {
131132
if (entry)
132133
*entry = p;
133134
return p->devid;

drivers/iommu/amd_iommu_init.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1329,8 +1329,8 @@ static int __init init_iommu_from_acpi(struct amd_iommu *iommu,
13291329
}
13301330
case IVHD_DEV_ACPI_HID: {
13311331
u16 devid;
1332-
u8 hid[ACPIHID_HID_LEN] = {0};
1333-
u8 uid[ACPIHID_UID_LEN] = {0};
1332+
u8 hid[ACPIHID_HID_LEN];
1333+
u8 uid[ACPIHID_UID_LEN];
13341334
int ret;
13351335

13361336
if (h->type != 0x40) {
@@ -1347,6 +1347,7 @@ static int __init init_iommu_from_acpi(struct amd_iommu *iommu,
13471347
break;
13481348
}
13491349

1350+
uid[0] = '\0';
13501351
switch (e->uidf) {
13511352
case UID_NOT_PRESENT:
13521353

@@ -1361,8 +1362,8 @@ static int __init init_iommu_from_acpi(struct amd_iommu *iommu,
13611362
break;
13621363
case UID_IS_CHARACTER:
13631364

1364-
memcpy(uid, (u8 *)(&e->uid), ACPIHID_UID_LEN - 1);
1365-
uid[ACPIHID_UID_LEN - 1] = '\0';
1365+
memcpy(uid, &e->uid, e->uidl);
1366+
uid[e->uidl] = '\0';
13661367

13671368
break;
13681369
default:

drivers/iommu/iommu.c

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -693,6 +693,15 @@ static int iommu_group_create_direct_mappings(struct iommu_group *group,
693693
return ret;
694694
}
695695

696+
static bool iommu_is_attach_deferred(struct iommu_domain *domain,
697+
struct device *dev)
698+
{
699+
if (domain->ops->is_attach_deferred)
700+
return domain->ops->is_attach_deferred(domain, dev);
701+
702+
return false;
703+
}
704+
696705
/**
697706
* iommu_group_add_device - add a device to an iommu group
698707
* @group: the group into which to add the device (reference should be held)
@@ -747,7 +756,7 @@ int iommu_group_add_device(struct iommu_group *group, struct device *dev)
747756

748757
mutex_lock(&group->mutex);
749758
list_add_tail(&device->list, &group->devices);
750-
if (group->domain)
759+
if (group->domain && !iommu_is_attach_deferred(group->domain, dev))
751760
ret = __iommu_attach_device(group->domain, dev);
752761
mutex_unlock(&group->mutex);
753762
if (ret)
@@ -1653,9 +1662,6 @@ static int __iommu_attach_device(struct iommu_domain *domain,
16531662
struct device *dev)
16541663
{
16551664
int ret;
1656-
if ((domain->ops->is_attach_deferred != NULL) &&
1657-
domain->ops->is_attach_deferred(domain, dev))
1658-
return 0;
16591665

16601666
if (unlikely(domain->ops->attach_dev == NULL))
16611667
return -ENODEV;
@@ -1727,8 +1733,7 @@ EXPORT_SYMBOL_GPL(iommu_sva_unbind_gpasid);
17271733
static void __iommu_detach_device(struct iommu_domain *domain,
17281734
struct device *dev)
17291735
{
1730-
if ((domain->ops->is_attach_deferred != NULL) &&
1731-
domain->ops->is_attach_deferred(domain, dev))
1736+
if (iommu_is_attach_deferred(domain, dev))
17321737
return;
17331738

17341739
if (unlikely(domain->ops->detach_dev == NULL))

0 commit comments

Comments
 (0)