From: "Nicholas Piggin" <npiggin@gmail.com>
To: "Phil Dennis-Jordan" <lists@philjordan.eu>
Cc: "Michael S . Tsirkin" <mst@redhat.com>,
"Marcel Apfelbaum" <marcel.apfelbaum@gmail.com>,
<qemu-devel@nongnu.org>
Subject: Re: [PATCH 2/2] hw/pci: Assert a bar is not registered multiple times
Date: Tue, 21 Jan 2025 14:41:45 +1000 [thread overview]
Message-ID: <D77H4P297PKY.25UZ63LQ3915T@gmail.com> (raw)
In-Reply-To: <CAGCz3vtDjaVnWbnZdKQSEReoWdtrMpyJGVkzXu4Q8XaVPYciFw@mail.gmail.com>
On Sun Jan 19, 2025 at 8:38 PM AEST, Phil Dennis-Jordan wrote:
> Looks good to me. There is a risk here that the assertion will fail on
> existing code. (Unless you've rigorously audited all callers, which would
> be quite the task.) However, I agree that this would constitute a bug in
> the calling code, not an issue with this change. Since we've still got a
> few months left in the 10.0 release cycle, I say go for it - hopefully such
> bugs, if there are any, will be shaken out over the next few weeks.
You're right I didn't do an exhaustive audit or test beyond CI and some
browsing. I think it would be quite buggy already if this happens so we
should just catch and fix it quickly, but happy to change to a warning
first if anybody is concerned.
Thanks,
Nick
>
> On Fri, 17 Jan 2025 at 18:29, Nicholas Piggin <npiggin@gmail.com> wrote:
>
>> Nothing should be doing this, but it doesn't get caught by
>> pci_register_bar(). Add an assertion to prevent misuse.
>>
>> Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
>>
> Reviewed-by: Phil Dennis-Jordan <phil@philjordan.eu>
>
>
>> ---
>> hw/pci/pci.c | 1 +
>> 1 file changed, 1 insertion(+)
>>
>> diff --git a/hw/pci/pci.c b/hw/pci/pci.c
>> index 2afa423925c..b067a55c5bc 100644
>> --- a/hw/pci/pci.c
>> +++ b/hw/pci/pci.c
>> @@ -1391,6 +1391,7 @@ void pci_register_bar(PCIDevice *pci_dev, int
>> region_num,
>> assert(hdr_type != PCI_HEADER_TYPE_BRIDGE || region_num < 2);
>>
>> r = &pci_dev->io_regions[region_num];
>> + assert(!r->size);
>> r->addr = PCI_BAR_UNMAPPED;
>> r->size = size;
>> r->type = type;
>> --
>> 2.45.2
>>
>>
>>
prev parent reply other threads:[~2025-01-21 4:42 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-17 17:28 [PATCH 0/2] hw/pci: catch a few error cases Nicholas Piggin
2025-01-17 17:28 ` [PATCH 1/2] hw/pci/msix: Warn on PBA writes Nicholas Piggin
2025-01-18 7:38 ` Akihiko Odaki
2025-01-19 10:31 ` Phil Dennis-Jordan
2025-01-22 7:04 ` Philippe Mathieu-Daudé
2025-01-17 17:28 ` [PATCH 2/2] hw/pci: Assert a bar is not registered multiple times Nicholas Piggin
2025-01-19 10:38 ` Phil Dennis-Jordan
2025-01-21 4:41 ` Nicholas Piggin [this message]
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=D77H4P297PKY.25UZ63LQ3915T@gmail.com \
--to=npiggin@gmail.com \
--cc=lists@philjordan.eu \
--cc=marcel.apfelbaum@gmail.com \
--cc=mst@redhat.com \
--cc=qemu-devel@nongnu.org \
/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).