Skip to content

Commit 0f91d07

Browse files
hegdevasantjoergroedel
authored andcommitted
iommu/amd: Enhance def_domain_type to handle untrusted device
Previously, IOMMU core layer was forcing IOMMU_DOMAIN_DMA domain for untrusted device. This always took precedence over driver's def_domain_type(). Commit 59ddce4 ("iommu: Reorganize iommu_get_default_domain_type() to respect def_domain_type()") changed the behaviour. Current code calls def_domain_type() but if it doesn't return IOMMU_DOMAIN_DMA for untrusted device it throws error. This results in IOMMU group (and potentially IOMMU itself) in undetermined state. This patch adds untrusted check in AMD IOMMU driver code. So that it allows eGPUs behind Thunderbolt work again. Fine tuning amd_iommu_def_domain_type() will be done later. Reported-by: Eric Wagner <ewagner12@gmail.com> Link: https://lore.kernel.org/linux-iommu/CAHudX3zLH6CsRmLE-yb+gRjhh-v4bU5_1jW_xCcxOo_oUUZKYg@mail.gmail.com Closes: https://gitlab.freedesktop.org/drm/amd/-/issues/3182 Fixes: 59ddce4 ("iommu: Reorganize iommu_get_default_domain_type() to respect def_domain_type()") Cc: Robin Murphy <robin.murphy@arm.com> Cc: Jason Gunthorpe <jgg@ziepe.ca> Cc: stable@kernel.org # v6.7+ Signed-off-by: Vasant Hegde <vasant.hegde@amd.com> Link: https://lore.kernel.org/r/20240423111725.5813-1-vasant.hegde@amd.com Signed-off-by: Joerg Roedel <jroedel@suse.de>
1 parent ed30a4a commit 0f91d07

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

drivers/iommu/amd/iommu.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2754,6 +2754,10 @@ static int amd_iommu_def_domain_type(struct device *dev)
27542754
if (!dev_data)
27552755
return 0;
27562756

2757+
/* Always use DMA domain for untrusted device */
2758+
if (dev_is_pci(dev) && to_pci_dev(dev)->untrusted)
2759+
return IOMMU_DOMAIN_DMA;
2760+
27572761
/*
27582762
* Do not identity map IOMMUv2 capable devices when:
27592763
* - memory encryption is active, because some of those devices

0 commit comments

Comments
 (0)