Skip to content

Commit b650b38

Browse files
hegdevasantjoergroedel
authored andcommitted
iommu/amd: Do not enable SNP when V2 page table is enabled
DTE[Mode]=0 is not supported when SNP is enabled in the host. That means to support SNP, IOMMU must be configured with V1 page table (See IOMMU spec [1] for the details). If user passes kernel command line to configure IOMMU domains with v2 page table (amd_iommu=pgtbl_v2) then disable SNP as the user asked by not forcing the page table to v1. [1] https://www.amd.com/content/dam/amd/en/documents/processor-tech-docs/specifications/48882_IOMMU.pdf Cc: Ashish Kalra <[email protected]> Cc: Michael Roth <[email protected]> Cc: Tom Lendacky <[email protected]> Signed-off-by: Vasant Hegde <[email protected]> Reviewed-by: Tom Lendacky <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Joerg Roedel <[email protected]>
1 parent 84b1cec commit b650b38

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

drivers/iommu/amd/init.c

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3232,28 +3232,29 @@ static void iommu_snp_enable(void)
32323232
return;
32333233
/*
32343234
* The SNP support requires that IOMMU must be enabled, and is
3235-
* not configured in the passthrough mode.
3235+
* configured with V1 page table (DTE[Mode] = 0 is not supported).
32363236
*/
32373237
if (no_iommu || iommu_default_passthrough()) {
32383238
pr_err("SNP: IOMMU disabled or configured in passthrough mode, SNP cannot be supported.\n");
3239-
cc_platform_clear(CC_ATTR_HOST_SEV_SNP);
3240-
return;
3239+
goto disable_snp;
3240+
}
3241+
3242+
if (amd_iommu_pgtable != AMD_IOMMU_V1) {
3243+
pr_warn("SNP: IOMMU is configured with V2 page table mode, SNP cannot be supported.\n");
3244+
goto disable_snp;
32413245
}
32423246

32433247
amd_iommu_snp_en = check_feature(FEATURE_SNP);
32443248
if (!amd_iommu_snp_en) {
32453249
pr_err("SNP: IOMMU SNP feature not enabled, SNP cannot be supported.\n");
3246-
cc_platform_clear(CC_ATTR_HOST_SEV_SNP);
3247-
return;
3250+
goto disable_snp;
32483251
}
32493252

32503253
pr_info("IOMMU SNP support enabled.\n");
3254+
return;
32513255

3252-
/* Enforce IOMMU v1 pagetable when SNP is enabled. */
3253-
if (amd_iommu_pgtable != AMD_IOMMU_V1) {
3254-
pr_warn("Forcing use of AMD IOMMU v1 page table due to SNP.\n");
3255-
amd_iommu_pgtable = AMD_IOMMU_V1;
3256-
}
3256+
disable_snp:
3257+
cc_platform_clear(CC_ATTR_HOST_SEV_SNP);
32573258
#endif
32583259
}
32593260

0 commit comments

Comments
 (0)