Skip to content

Commit 18792e9

Browse files
hegdevasantjoergroedel
authored andcommitted
iommu/amd: Do not identity map v2 capable device when snp is enabled
Flow: - Booted system with SNP enabled, memory encryption off and IOMMU DMA translation mode - AMD driver detects v2 capable device and amd_iommu_def_domain_type() returns identity mode - amd_iommu_domain_alloc() returns NULL an SNP is enabled - System will fail to register device On SNP enabled system, passthrough mode is not supported. IOMMU default domain is set to translation mode. We need to return zero from amd_iommu_def_domain_type() so that it allocates translation domain. Fixes: fb2acca ("iommu/amd: Introduce function to check and enable SNP") CC: Suravee Suthikulpanit <[email protected]> Signed-off-by: Vasant Hegde <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Joerg Roedel <[email protected]>
1 parent b6b26d8 commit 18792e9

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

drivers/iommu/amd/iommu.c

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2403,12 +2403,17 @@ static int amd_iommu_def_domain_type(struct device *dev)
24032403
return 0;
24042404

24052405
/*
2406-
* Do not identity map IOMMUv2 capable devices when memory encryption is
2407-
* active, because some of those devices (AMD GPUs) don't have the
2408-
* encryption bit in their DMA-mask and require remapping.
2406+
* Do not identity map IOMMUv2 capable devices when:
2407+
* - memory encryption is active, because some of those devices
2408+
* (AMD GPUs) don't have the encryption bit in their DMA-mask
2409+
* and require remapping.
2410+
* - SNP is enabled, because it prohibits DTE[Mode]=0.
24092411
*/
2410-
if (!cc_platform_has(CC_ATTR_MEM_ENCRYPT) && dev_data->iommu_v2)
2412+
if (dev_data->iommu_v2 &&
2413+
!cc_platform_has(CC_ATTR_MEM_ENCRYPT) &&
2414+
!amd_iommu_snp_en) {
24112415
return IOMMU_DOMAIN_IDENTITY;
2416+
}
24122417

24132418
return 0;
24142419
}

0 commit comments

Comments
 (0)