Re: [PATCH] iommu/amd: Clear amd_iommu_snp_en if snp_rmptable_init() fails

From: Ankit Soni

Date: Tue Oct 27 2026 - 12:37:33 EST


On Sat, Oct 24, 2026 at 12:20:41AM +0530, Dheeraj Kumar Srivastava wrote:
> 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")

Reviewed-by: Ankit Soni <Ankit.Soni@xxxxxxx>

> Signed-off-by: Dheeraj Kumar Srivastava <dheerajkumar.srivastava@xxxxxxx>
> ---
> drivers/iommu/amd/init.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/drivers/iommu/amd/init.c b/drivers/iommu/amd/init.c
> index 8a410d4aa370..d413b1240294 100644
> --- a/drivers/iommu/amd/init.c
> +++ b/drivers/iommu/amd/init.c
> @@ -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
> }
> --
> 2.25.1
>