* [PATCH] iommu/amd: Fix failure return from snp_lookup_rmpentry().
@ 2024-02-05 21:06 Ashish Kalra
2024-02-06 11:31 ` Borislav Petkov
0 siblings, 1 reply; 2+ messages in thread
From: Ashish Kalra @ 2024-02-05 21:06 UTC (permalink / raw)
To: x86; +Cc: iommu, linux-kernel, bp, thomas.lendacky, michael.roth, dan.carpenter
From: Ashish Kalra <ashish.kalra@amd.com>
The patch f366a8dac1b8: "iommu/amd: Clean up RMP entries for IOMMU
pages during SNP shutdown" (linux-next), leads to the following
Smatch static checker warning:
drivers/iommu/amd/init.c:3820 iommu_page_make_shared()
error: uninitialized symbol 'assigned'.
Fix it.
Fixes: f366a8dac1b8 ("iommu/amd: Clean up RMP entries for IOMMU pages during SNP shutdown")
Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
Closes: https://lore.kernel.org/linux-iommu/1be69f6a-e7e1-45f9-9a74-b2550344f3fd@moroto.mountain/
Signed-off-by: Ashish Kalra <ashish.kalra@amd.com>
Link: https://lore.kernel.org/lkml/20240126041126.1927228-20-michael.roth@amd.com/
---
drivers/iommu/amd/init.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/iommu/amd/init.c b/drivers/iommu/amd/init.c
index 88bb08ae39b2..11340380111d 100644
--- a/drivers/iommu/amd/init.c
+++ b/drivers/iommu/amd/init.c
@@ -3813,9 +3813,11 @@ static int iommu_page_make_shared(void *page)
bool assigned;
ret = snp_lookup_rmpentry(pfn, &assigned, &level);
- if (ret)
+ if (ret) {
pr_warn("IOMMU PFN %lx RMP lookup failed, ret %d\n",
pfn, ret);
+ return ret;
+ }
if (!assigned)
pr_warn("IOMMU PFN %lx not assigned in RMP table\n",
--
2.34.1
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] iommu/amd: Fix failure return from snp_lookup_rmpentry().
2024-02-05 21:06 [PATCH] iommu/amd: Fix failure return from snp_lookup_rmpentry() Ashish Kalra
@ 2024-02-06 11:31 ` Borislav Petkov
0 siblings, 0 replies; 2+ messages in thread
From: Borislav Petkov @ 2024-02-06 11:31 UTC (permalink / raw)
To: Ashish Kalra
Cc: x86, iommu, linux-kernel, thomas.lendacky, michael.roth, dan.carpenter
On Mon, Feb 05, 2024 at 09:06:54PM +0000, Ashish Kalra wrote:
> From: Ashish Kalra <ashish.kalra@amd.com>
>
> The patch f366a8dac1b8: "iommu/amd: Clean up RMP entries for IOMMU
> pages during SNP shutdown" (linux-next), leads to the following
Add this:
[alias]
one = show -s --pretty='format:%h (\"%s\")'
to your .git/config so that when you do
$ git one f366a8dac1b8
it can give you the proper formatting for commit references:
f366a8dac1b8 ("iommu/amd: Clean up RMP entries for IOMMU pages during SNP shutdown")
> diff --git a/drivers/iommu/amd/init.c b/drivers/iommu/amd/init.c
> index 88bb08ae39b2..11340380111d 100644
> --- a/drivers/iommu/amd/init.c
> +++ b/drivers/iommu/amd/init.c
> @@ -3813,9 +3813,11 @@ static int iommu_page_make_shared(void *page)
> bool assigned;
>
> ret = snp_lookup_rmpentry(pfn, &assigned, &level);
> - if (ret)
> + if (ret) {
> pr_warn("IOMMU PFN %lx RMP lookup failed, ret %d\n",
> pfn, ret);
> + return ret;
> + }
This one is incomplete and we should've caught this in review: any of
those failure cases here should return an error and not attempt to make
a pfn shared again.
Diff ontop:
---
diff --git a/drivers/iommu/amd/init.c b/drivers/iommu/amd/init.c
index 11340380111d..480e7681f4f3 100644
--- a/drivers/iommu/amd/init.c
+++ b/drivers/iommu/amd/init.c
@@ -3814,24 +3814,27 @@ static int iommu_page_make_shared(void *page)
ret = snp_lookup_rmpentry(pfn, &assigned, &level);
if (ret) {
- pr_warn("IOMMU PFN %lx RMP lookup failed, ret %d\n",
- pfn, ret);
+ pr_warn("IOMMU PFN %lx RMP lookup failed, ret %d\n", pfn, ret);
return ret;
}
- if (!assigned)
- pr_warn("IOMMU PFN %lx not assigned in RMP table\n",
- pfn);
+ if (!assigned) {
+ pr_warn("IOMMU PFN %lx not assigned in RMP table\n", pfn);
+ return -EINVAL;
+ }
if (level > PG_LEVEL_4K) {
ret = psmash(pfn);
- if (ret) {
- pr_warn("IOMMU PFN %lx had a huge RMP entry, but attempted psmash failed, ret: %d, level: %d\n",
- pfn, ret, level);
- }
+ if (!ret)
+ goto done;
+
+ pr_warn("PSMASH failed for IOMMU PFN %lx huge RMP entry, ret: %d, level: %d\n",
+ pfn, ret, level);
+ return ret;
}
}
+done:
return rmp_make_shared(pfn, PG_LEVEL_4K);
}
--
Regards/Gruss,
Boris.
https://people.kernel.org/tglx/notes-about-netiquette
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2024-02-06 11:31 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-02-05 21:06 [PATCH] iommu/amd: Fix failure return from snp_lookup_rmpentry() Ashish Kalra
2024-02-06 11:31 ` Borislav Petkov
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®