Skip to content

Commit 8388f7d

Browse files
ssuthiku-amdjoergroedel
authored andcommitted
iommu/amd: Do not support IOMMU_DOMAIN_IDENTITY after SNP is enabled
Once SNP is enabled (by executing SNP_INIT command), IOMMU can no longer support the passthrough domain (i.e. IOMMU_DOMAIN_IDENTITY). The SNP_INIT command is called early in the boot process, and would fail if the kernel is configure to default to passthrough mode. After the system is already booted, users can try to change IOMMU domain type of a particular IOMMU group. In this case, the IOMMU driver needs to check the SNP-enable status and return failure when requesting to change domain type to identity. Therefore, return failure when trying to allocate identity domain. Reviewed-by: Robin Murphy <[email protected]> Signed-off-by: Suravee Suthikulpanit <[email protected]> Link: https://lore.kernel.org/r/[email protected] [ joro: Removed WARN_ON_ONCE() ] Signed-off-by: Joerg Roedel <[email protected]>
1 parent b9f0043 commit 8388f7d

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

drivers/iommu/amd/iommu.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2068,6 +2068,13 @@ static struct iommu_domain *amd_iommu_domain_alloc(unsigned type)
20682068
{
20692069
struct protection_domain *domain;
20702070

2071+
/*
2072+
* Since DTE[Mode]=0 is prohibited on SNP-enabled system,
2073+
* default to use IOMMU_DOMAIN_DMA[_FQ].
2074+
*/
2075+
if (amd_iommu_snp_en && (type == IOMMU_DOMAIN_IDENTITY))
2076+
return NULL;
2077+
20712078
domain = protection_domain_alloc(type);
20722079
if (!domain)
20732080
return NULL;

0 commit comments

Comments
 (0)