From: "Roger Pau Monné" <roger.pau@citrix.com>
To: Jan Beulich <jbeulich@suse.com>
Cc: "Chen, Jiqian" <Jiqian.Chen@amd.com>,
"xen-devel@lists.xenproject.org" <xen-devel@lists.xenproject.org>,
"Huang, Ray" <Ray.Huang@amd.com>
Subject: Re: [PATCH v4 03/10] vpci/header: Emulate extended capability list for dom0
Date: Mon, 19 May 2025 15:21:49 +0200 [thread overview]
Message-ID: <aCswbbh-0GTdr1tr@Mac.lan> (raw)
In-Reply-To: <20d48f86-d7fe-47c8-89ab-61d816e1d6e9@suse.com>
On Mon, May 19, 2025 at 03:10:17PM +0200, Jan Beulich wrote:
> On 19.05.2025 09:13, Chen, Jiqian wrote:
> > On 2025/5/19 14:56, Jan Beulich wrote:
> >> On 19.05.2025 08:43, Chen, Jiqian wrote:
> >>> On 2025/5/18 22:20, Jan Beulich wrote:
> >>>> On 09.05.2025 11:05, Jiqian Chen wrote:
> >>>>> @@ -827,6 +827,34 @@ static int vpci_init_capability_list(struct pci_dev *pdev)
> >>>>> PCI_STATUS_RSVDZ_MASK);
> >>>>> }
> >>>>>
> >>>>> +static int vpci_init_ext_capability_list(struct pci_dev *pdev)
> >>>>> +{
> >>>>> + unsigned int pos = PCI_CFG_SPACE_SIZE, ttl = 480;
> >>>>
> >>>> The ttl value exists (in the function you took it from) to make sure
> >>>> the loop below eventually ends. That is, to be able to kind of
> >>>> gracefully deal with loops in the linked list. Such loops, however,
> >>>> would ...
> >>>>
> >>>>> + if ( !is_hardware_domain(pdev->domain) )
> >>>>> + /* Extended capabilities read as zero, write ignore for guest */
> >>>>> + return vpci_add_register(pdev->vpci, vpci_read_val, NULL,
> >>>>> + pos, 4, (void *)0);
> >>>>> +
> >>>>> + while ( pos >= PCI_CFG_SPACE_SIZE && ttl-- )
> >>>>> + {
> >>>>> + uint32_t header = pci_conf_read32(pdev->sbdf, pos);
> >>>>> + int rc;
> >>>>> +
> >>>>> + if ( !header )
> >>>>> + return 0;
> >>>>> +
> >>>>> + rc = vpci_add_register(pdev->vpci, vpci_read_val, vpci_hw_write32,
> >>>>> + pos, 4, (void *)(uintptr_t)header);
> >>>>
> >>>> ... mean we may invoke this twice for the same capability. Such
> >>>> a secondary invocation would fail with -EEXIST, causing device init
> >>>> to fail altogether. Which is kind of against our aim of exposing
> >>>> (in a controlled manner) as much of the PCI hardware as possible.
> >>> May I know what situation that can make this twice for one capability when initialization?
> >>> Does hardware capability list have a cycle?
> >>
> >> Any of this is to work around flawed hardware, I suppose.
> >>
> >>>> Imo we ought to be using a bitmap to detect the situation earlier
> >>>> and hence to be able to avoid redundant register addition. Thoughts?
> >>> Can we just let it go forward and continue to add register for next capability when rc == -EXIST, instead of returning error ?
> >>
> >> Possible, but feels wrong.
> > How about when EXIST, setting the next bits of previous extended capability to be zero and return 0? Then we break the cycle.
>
> Hmm. Again an option, yet again I'm not certain. But that's perhaps just
> me, and Roger may be fine with it. IOW we might as well start out this way,
> and adjust if (ever) an issue with a real device is found.
Returning -EEXIST might be fine, but at that point there's no further
capability to process. There's a loop in the linked capability list,
and we should just exit. There needs to be a warning in this case,
and since this is for the hardware domain only it shouldn't be fatal.
If it was for domUs we would possibly need to discuss whether
assigning the device should fail if a capability linked list loop is
found.
Thanks, Roger.
next prev parent reply other threads:[~2025-05-19 13:22 UTC|newest]
Thread overview: 45+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-05-09 9:05 [PATCH v4 00/10] Support hiding capability when its initialization fails Jiqian Chen
2025-05-09 9:05 ` [PATCH v4 01/10] vpci/header: Move emulating cap list logic into new function Jiqian Chen
2025-05-09 9:05 ` [PATCH v4 02/10] vpci/header: Emulate legacy capability list for dom0 Jiqian Chen
2025-05-15 16:29 ` Roger Pau Monné
2025-05-16 2:33 ` Chen, Jiqian
2025-05-09 9:05 ` [PATCH v4 03/10] vpci/header: Emulate extended " Jiqian Chen
2025-05-18 14:20 ` Jan Beulich
2025-05-19 6:43 ` Chen, Jiqian
2025-05-19 6:56 ` Jan Beulich
2025-05-19 7:13 ` Chen, Jiqian
2025-05-19 13:10 ` Jan Beulich
2025-05-19 13:21 ` Roger Pau Monné [this message]
2025-05-21 6:08 ` Chen, Jiqian
2025-05-21 6:25 ` Jan Beulich
2025-05-21 6:44 ` Chen, Jiqian
2025-05-09 9:05 ` [PATCH v4 04/10] vpci: Refactor REGISTER_VPCI_INIT Jiqian Chen
2025-05-18 14:34 ` Jan Beulich
2025-05-19 6:56 ` Chen, Jiqian
2025-05-19 13:07 ` Jan Beulich
2025-05-09 9:05 ` [PATCH v4 05/10] vpci: Hide legacy capability when it fails to initialize Jiqian Chen
2025-05-18 14:44 ` Jan Beulich
2025-05-19 7:35 ` Chen, Jiqian
2025-05-19 10:04 ` Roger Pau Monné
2025-05-09 9:05 ` [PATCH v4 06/10] vpci: Hide extended " Jiqian Chen
2025-05-18 14:47 ` Jan Beulich
2025-05-19 7:41 ` Chen, Jiqian
2025-05-19 13:12 ` Jan Beulich
2025-05-09 9:05 ` [PATCH v4 07/10] vpci: Refactor vpci_remove_register to remove matched registers Jiqian Chen
2025-05-19 6:30 ` Jan Beulich
2025-05-19 7:44 ` Chen, Jiqian
2025-05-19 10:24 ` Roger Pau Monné
2025-05-09 9:05 ` [PATCH v4 08/10] vpci/rebar: Remove registers when init_rebar() fails Jiqian Chen
2025-05-19 6:54 ` Jan Beulich
2025-05-19 7:49 ` Chen, Jiqian
2025-05-09 9:05 ` [PATCH v4 09/10] vpci/msi: Free MSI resources when init_msi() fails Jiqian Chen
2025-05-20 6:40 ` Jan Beulich
2025-05-20 9:09 ` Roger Pau Monné
2025-05-20 9:14 ` Jan Beulich
2025-05-20 9:43 ` Roger Pau Monné
2025-05-21 7:00 ` Chen, Jiqian
2025-05-21 11:23 ` Roger Pau Monné
2025-05-22 2:21 ` Chen, Jiqian
2025-05-22 7:12 ` Roger Pau Monné
2025-05-22 7:27 ` Chen, Jiqian
2025-05-09 9:05 ` [PATCH v4 10/10] vpci/msix: Add function to clean MSIX resources Jiqian Chen
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=aCswbbh-0GTdr1tr@Mac.lan \
--to=roger.pau@citrix.com \
--cc=Jiqian.Chen@amd.com \
--cc=Ray.Huang@amd.com \
--cc=jbeulich@suse.com \
--cc=xen-devel@lists.xenproject.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.