* [PATCH] iommu/amd: Do not identity map v2 capable device when snp is enabled
@ 2023-02-07 9:17 Vasant Hegde
2023-02-16 9:47 ` Joerg Roedel
0 siblings, 1 reply; 3+ messages in thread
From: Vasant Hegde @ 2023-02-07 9:17 UTC (permalink / raw)
To: iommu, joro; +Cc: suravee.suthikulpanit, Vasant Hegde
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: fb2accadaa942 (iommu/amd: Introduce function to check and enable SNP)
CC: Suravee Suthikulpanit <suravee.suthikulpanit@amd.com>
Signed-off-by: Vasant Hegde <vasant.hegde@amd.com>
---
drivers/iommu/amd/iommu.c | 13 +++++++++----
1 file changed, 9 insertions(+), 4 deletions(-)
diff --git a/drivers/iommu/amd/iommu.c b/drivers/iommu/amd/iommu.c
index 0b011a97e20d..3186e0dd8b2b 100644
--- a/drivers/iommu/amd/iommu.c
+++ b/drivers/iommu/amd/iommu.c
@@ -2401,12 +2401,17 @@ static int amd_iommu_def_domain_type(struct device *dev)
return 0;
/*
- * Do not identity map IOMMUv2 capable devices when memory encryption is
- * active, because some of those devices (AMD GPUs) don't have the
- * encryption bit in their DMA-mask and require remapping.
+ * Do not identity map IOMMUv2 capable devices when:
+ * - memory encryption is active, because some of those devices
+ * (AMD GPUs) don't have the encryption bit in their DMA-mask
+ * and require remapping.
+ * - SNP is enabled, because it prohibits DTE[Mode]=0.
*/
- if (!cc_platform_has(CC_ATTR_MEM_ENCRYPT) && dev_data->iommu_v2)
+ if (dev_data->iommu_v2 &&
+ !cc_platform_has(CC_ATTR_MEM_ENCRYPT) &&
+ !amd_iommu_snp_en) {
return IOMMU_DOMAIN_IDENTITY;
+ }
return 0;
}
--
2.31.1
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH] iommu/amd: Do not identity map v2 capable device when snp is enabled
2023-02-07 9:17 [PATCH] iommu/amd: Do not identity map v2 capable device when snp is enabled Vasant Hegde
@ 2023-02-16 9:47 ` Joerg Roedel
2023-02-17 5:59 ` Vasant Hegde
0 siblings, 1 reply; 3+ messages in thread
From: Joerg Roedel @ 2023-02-16 9:47 UTC (permalink / raw)
To: Vasant Hegde; +Cc: iommu, suravee.suthikulpanit
Hi Vasant,
On Tue, Feb 07, 2023 at 09:17:52AM +0000, Vasant Hegde wrote:
> drivers/iommu/amd/iommu.c | 13 +++++++++----
> 1 file changed, 9 insertions(+), 4 deletions(-)
Applied and fixed a checkpatch warning. Please use check-patch in the
future before submitting.
Regards,
Joerg
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] iommu/amd: Do not identity map v2 capable device when snp is enabled
2023-02-16 9:47 ` Joerg Roedel
@ 2023-02-17 5:59 ` Vasant Hegde
0 siblings, 0 replies; 3+ messages in thread
From: Vasant Hegde @ 2023-02-17 5:59 UTC (permalink / raw)
To: Joerg Roedel; +Cc: iommu, suravee.suthikulpanit
Joerg,
On 2/16/2023 3:17 PM, Joerg Roedel wrote:
> Hi Vasant,
>
> On Tue, Feb 07, 2023 at 09:17:52AM +0000, Vasant Hegde wrote:
>> drivers/iommu/amd/iommu.c | 13 +++++++++----
>> 1 file changed, 9 insertions(+), 4 deletions(-)
>
> Applied and fixed a checkpatch warning. Please use check-patch in the
> future before submitting.
Sure. Thank you.
-Vasant
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-02-17 6:00 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-02-07 9:17 [PATCH] iommu/amd: Do not identity map v2 capable device when snp is enabled Vasant Hegde
2023-02-16 9:47 ` Joerg Roedel
2023-02-17 5:59 ` Vasant Hegde
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.