Skip to contentSkip to conversation

iommu/amd: Clear amd_iommu_snp_en if snp_rmptable_init() fails

PATCH In review Dheeraj Kumar Srivastava 3 participants 3 messages Oct 23 – Nov 2

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 iommu/amd: Clear amd_iommu_snp_en if snp_rmptable_init() fails

iommu_snp_enable() checks that the IOMMU can support SNP and sets amd_iommu_snp_en, then calls snp_rmptable_init() to map the RMP table. If that call fails, CC_ATTR_HOST_SEV_SNP is cleared but amd_iommu_snp_en is left set. Later IOMMU initialization uses amd_iommu_snp_en to configure the IOMMU for SNP, on the assumption that RMP setup succeeded.

Clear amd_iommu_snp_en along with CC_ATTR_HOST_SEV_SNP.

Fixes 409f45387c93 ("x86/sev: Fix broken SNP support with KVM module built-in")
---
 drivers/iommu/amd/init.c | 1 +
 1 file changed, 1 insertion(+)
drivers/iommu/amd/init.c +1 -0
index 8a410d4aa370..d413b1240294 100644
@@ -3445,6 +3445,7 @@ static __init void iommu_snp_enable(void)
 	return;
 
 disable_snp:
+	amd_iommu_snp_en = false;
 	cc_platform_clear(CC_ATTR_HOST_SEV_SNP);
 #endif
 }
Signature · 1 line
2.25.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 9 lines · Dheeraj Kumar Srivastava

iommu_snp_enable() checks that the IOMMU can support SNP and sets amd_iommu_snp_en, then calls snp_rmptable_init() to map the RMP table. If that call fails, CC_ATTR_HOST_SEV_SNP is cleared but amd_iommu_snp_en is left set. Later IOMMU initialization uses amd_iommu_snp_en to configure the IOMMU for SNP, on the assumption that RMP setup succeeded.

Clear amd_iommu_snp_en along with CC_ATTR_HOST_SEV_SNP.

Fixes 409f45387c93 ("x86/sev: Fix broken SNP support with KVM module built-in")
Quoted 20 lines
---
 drivers/iommu/amd/init.c | 1 +
 1 file changed, 1 insertion(+)
drivers/iommu/amd/init.c +1 -0
index 8a410d4aa370..d413b1240294 100644
@@ -3445,6 +3445,7 @@ static __init void iommu_snp_enable(void)
 	return;
 
 disable_snp:
+	amd_iommu_snp_en = false;
 	cc_platform_clear(CC_ATTR_HOST_SEV_SNP);
 #endif
 }
Signature · 1 line
2.25.1
maintainer
#2 lore raw
In reply to Dheeraj Kumar Srivastava
Quoted 10 lines · Dheeraj Kumar Srivastava

iommu_snp_enable() checks that the IOMMU can support SNP and sets amd_iommu_snp_en, then calls snp_rmptable_init() to map the RMP table. If that call fails, CC_ATTR_HOST_SEV_SNP is cleared but amd_iommu_snp_en is left set. Later IOMMU initialization uses amd_iommu_snp_en to configure the IOMMU for SNP, on the assumption that RMP setup succeeded.

Clear amd_iommu_snp_en along with CC_ATTR_HOST_SEV_SNP.

Fixes 409f45387c93 ("x86/sev: Fix broken SNP support with KVM module built-in")

Thanks. Queued for rc.

-Vasant