iommu/amd: Clean up RMP entries for IOMMU pages during SNP shutdown
Hello Ashish Kalra,
The patch f366a8dac1b8: "iommu/amd: Clean up RMP entries for IOMMU pages during SNP shutdown" from Jan 25, 2024 (linux-next), leads to the following Smatch static checker warning:
drivers/iommu/amd/init.c:3820 iommu_page_make_shared() error: uninitialized symbol 'assigned'.
drivers/iommu/amd/init.c
3803 static int iommu_page_make_shared(void *page)
3804 {
3805 unsigned long paddr, pfn;
3806
3807 paddr = iommu_virt_to_phys(page);
3808 /* Cbit maybe set in the paddr */
3809 pfn = __sme_clr(paddr) >> PAGE_SHIFT;
3810
3811 if (!(pfn % PTRS_PER_PMD)) {
3812 int ret, level;
3813 bool assigned;
3814
3815 ret = snp_lookup_rmpentry(pfn, &assigned, &level);
3816 if (ret)
3817 pr_warn("IOMMU PFN %lx RMP lookup failed, ret %d\n",
3818 pfn, ret);
3819 --> 3820 if (!assigned)
assigned is uninitialized if snp_lookup_rmpentry() fails.
3821 pr_warn("IOMMU PFN %lx not assigned in RMP table\n",
3822 pfn);
3823
3824 if (level > PG_LEVEL_4K) {
3825 ret = psmash(pfn);
3826 if (ret) {
3827 pr_warn("IOMMU PFN %lx had a huge RMP entry, but attempted psmash failed, ret: %d, level: %d\n",
3828 pfn, ret, level);
3829 }
3830 }
3831 }
3832
3833 return rmp_make_shared(pfn, PG_LEVEL_4K);
3834 }regards,
dan carpenter