Re: iommu/amd: Initialize IOMMU Private Address (IPA) space mapping region

From: Weinan Liu

Date: Tue Mar 31 2026 - 01:12:31 EST


> diff --git a/drivers/iommu/amd/init.c b/drivers/iommu/amd/init.c
> @@ -2198,6 +2202,10 @@ static int __init iommu_init_pci(struct amd_iommu *iommu)
> if (check_feature(FEATURE_PPR) && amd_iommu_alloc_ppr_log(iommu))
> return -ENOMEM;
>
> + ret = amd_viommu_init(iommu);
> + if (ret)
> + pr_err("Failed to initialize vIOMMU.\n");

Should amd_iommu_viommu be set to false if vIOMMU initialization fails?
Currently, the following logic will indicate that vIOMMU is enabled even if the
initialization process does not succeed:

if (iommu->cap & (1UL << IOMMU_CAP_NPCACHE)) {
pr_info("Using strict mode due to virtualization\n");
iommu_set_dma_strict();
@@ -2291,6 +2299,9 @@ static void print_iommu_info(void)
if (check_feature2(FEATURE_SEVSNPIO_SUP))
pr_cont(" SEV-TIO");

+ if (check_feature(FEATURE_VIOMMU))
+ pr_cont(" vIOMMU");
+
pr_cont("\n");
}

@@ -2303,6 +2314,8 @@ static void print_iommu_info(void)
pr_info("V2 page table enabled (Paging mode : %d level)\n",
amd_iommu_gpt_level);
}
+ if (amd_iommu_viommu)
+ pr_info("AMD-Vi: vIOMMU enabled\n");
}