Commit b650b38b authored by Vasant Hegde's avatar Vasant Hegde Committed by Joerg Roedel

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 <ashish.kalra@amd.com>
Cc: Michael Roth <michael.roth@amd.com>
Cc: Tom Lendacky <thomas.lendacky@amd.com>
Signed-off-by: default avatarVasant Hegde <vasant.hegde@amd.com>
Reviewed-by: default avatarTom Lendacky <thomas.lendacky@amd.com>
Link: https://lore.kernel.org/r/20240410085702.31869-1-vasant.hegde@amd.comSigned-off-by: default avatarJoerg Roedel <jroedel@suse.de>
parent 84b1cec4
...@@ -3232,28 +3232,29 @@ static void iommu_snp_enable(void) ...@@ -3232,28 +3232,29 @@ static void iommu_snp_enable(void)
return; return;
/* /*
* The SNP support requires that IOMMU must be enabled, and is * The SNP support requires that IOMMU must be enabled, and is
* not configured in the passthrough mode. * configured with V1 page table (DTE[Mode] = 0 is not supported).
*/ */
if (no_iommu || iommu_default_passthrough()) { if (no_iommu || iommu_default_passthrough()) {
pr_err("SNP: IOMMU disabled or configured in passthrough mode, SNP cannot be supported.\n"); pr_err("SNP: IOMMU disabled or configured in passthrough mode, SNP cannot be supported.\n");
cc_platform_clear(CC_ATTR_HOST_SEV_SNP); goto disable_snp;
return; }
if (amd_iommu_pgtable != AMD_IOMMU_V1) {
pr_warn("SNP: IOMMU is configured with V2 page table mode, SNP cannot be supported.\n");
goto disable_snp;
} }
amd_iommu_snp_en = check_feature(FEATURE_SNP); amd_iommu_snp_en = check_feature(FEATURE_SNP);
if (!amd_iommu_snp_en) { if (!amd_iommu_snp_en) {
pr_err("SNP: IOMMU SNP feature not enabled, SNP cannot be supported.\n"); pr_err("SNP: IOMMU SNP feature not enabled, SNP cannot be supported.\n");
cc_platform_clear(CC_ATTR_HOST_SEV_SNP); goto disable_snp;
return;
} }
pr_info("IOMMU SNP support enabled.\n"); pr_info("IOMMU SNP support enabled.\n");
return;
/* Enforce IOMMU v1 pagetable when SNP is enabled. */ disable_snp:
if (amd_iommu_pgtable != AMD_IOMMU_V1) { cc_platform_clear(CC_ATTR_HOST_SEV_SNP);
pr_warn("Forcing use of AMD IOMMU v1 page table due to SNP.\n");
amd_iommu_pgtable = AMD_IOMMU_V1;
}
#endif #endif
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment