From: Jason Gunthorpe <jgg@ziepe.ca>
To: Dan Carpenter <dan.carpenter@linaro.org>
Cc: iommu@lists.linux.dev
Subject: Re: [bug report] iommupt: Add map_pages op
Date: Thu, 20 Nov 2025 13:21:07 -0400 [thread overview]
Message-ID: <20251120172107.GA233636@ziepe.ca> (raw)
In-Reply-To: <aRwgNW9PiW2j-Qwo@stanley.mountain>
On Tue, Nov 18, 2025 at 10:28:53AM +0300, Dan Carpenter wrote:
> Hello Jason Gunthorpe,
>
> Commit dcd6a011a8d5 ("iommupt: Add map_pages op") from Nov 4, 2025
> (linux-next), leads to the following Smatch static checker warning:
>
> drivers/iommu/generic_pt/fmt/../iommu_pt.h:752 increase_top()
> error: uninitialized symbol 'new_level'.
>
> drivers/iommu/generic_pt/fmt/../iommu_pt.h
> 665 static int increase_top(struct pt_iommu *iommu_table, struct pt_range *range,
> 666 struct pt_iommu_map_args *map)
> 667 {
> 668 struct iommu_pages_list free_list = IOMMU_PAGES_LIST_INIT(free_list);
> 669 struct pt_common *common = common_from_iommu(iommu_table);
> 670 uintptr_t top_of_table = READ_ONCE(common->top_of_table);
> 671 uintptr_t new_top_of_table = top_of_table;
> 672 struct pt_table_p *table_mem;
> 673 unsigned int new_level;
> 674 spinlock_t *domain_lock;
> 675 unsigned long flags;
> 676 int ret;
> 677
> 678 while (true) {
> 679 struct pt_range top_range =
> 680 _pt_top_range(common, new_top_of_table);
> 681 struct pt_state pts = pt_init_top(&top_range);
> 682
> 683 top_range.va = range->va;
> 684 top_range.last_va = range->last_va;
> 685
> 686 if (!pt_check_range(&top_range) && map->leaf_level <= pts.level)
> 687 break;
>
> Smatch worries that we could break on the first iteration. I don't
> know if that's possible.
Hmm, I wanted to say it can't because of the caller, but the locking
doesn't work like that, so yeah this is a bug. I will make a patch
Jason
next prev parent reply other threads:[~2025-11-20 17:21 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-18 7:28 [bug report] iommupt: Add map_pages op Dan Carpenter
2025-11-20 17:21 ` Jason Gunthorpe [this message]
-- strict thread matches above, loose matches on Subject: below --
2025-11-21 9:22 Dan Carpenter
2025-11-21 12:48 ` Jason Gunthorpe
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20251120172107.GA233636@ziepe.ca \
--to=jgg@ziepe.ca \
--cc=dan.carpenter@linaro.org \
--cc=iommu@lists.linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).