qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH v2] pci: Assert that capabilities never overlap


From: Akihiko Odaki
Subject: Re: [PATCH v2] pci: Assert that capabilities never overlap
Date: Sun, 4 Sep 2022 16:06:55 +0900

On Fri, Sep 2, 2022 at 7:23 PM Markus Armbruster <armbru@redhat.com> wrote:
>
> Akihiko Odaki <akihiko.odaki@daynix.com> writes:
>
> > pci_add_capability appears most PCI devices. Its error handling required
> > lots of code, and led to inconsistent behaviors such as:
> > - passing error_abort
> > - passing error_fatal
> > - asserting the returned value
> > - propagating the error to the caller
> > - skipping the rest of the function
> > - just ignoring
> >
> > The code generating errors in pci_add_capability had a comment which
> > says:
> >> Verify that capabilities don't overlap.  Note: device assignment
> >> depends on this check to verify that the device is not broken.
> >> Should never trigger for emulated devices, but it's helpful for
> >> debugging these.
> >
> > Indeed vfio has some code that passes capability offsets and sizes from
> > a physical device, but it explicitly pays attention so that the
> > capabilities never overlap.
>
> I can't see that at a glance.  Can you give me a clue?
>
> >                             Therefore, we can always assert that
> > capabilities never overlap when pci_add_capability is called, resolving
> > these inconsistencies.
> >
> > Signed-off-by: Akihiko Odaki <akihiko.odaki@daynix.com>
>

Looking at vfio_add_std_cap(), and vfio_add_ext_cap() it seems that
they are clipping the size of capabilities so that they do not
overlap, if I read it correctly.

Regards,
Akihiko Odaki



reply via email to

[Prev in Thread] Current Thread [Next in Thread]