Re: [RFC 13/20] iommu: Extend iommu_at[de]tach_device() for multiple devices group

David Gibson
2021-10-25T05:29:41Z

[-- Attachment #1.1: Type: text/plain, Size: 2179 bytes --]

On Mon, Oct 18, 2021 at 01:32:38PM -0300, Jason Gunthorpe wrote:
> On Mon, Oct 18, 2021 at 02:57:12PM +1100, David Gibson wrote:
>
> > The first user might read this. Subsequent users are likely to just
> > copy paste examples from earlier things without fully understanding
> > them. In general documenting restrictions somewhere is never as
> > effective as making those restrictions part of the interface signature
> > itself.
>
> I'd think this argument would hold more water if you could point to
> someplace in existing userspace that cares about the VFIO grouping.

My whole point here is that the proposed semantics mean that we have
weird side effects even if the app doesn't think it cares about
groups.

e.g. App's input is a bunch of PCI addresses for NICs. It attaches
each one to a separate IOAS and bridges packets between them all. As
far as the app is concerned, it doesn't care about groups, as you say.

Except that it breaks if any two of the devices are in the same group.
Worse, it has a completely horrible failure mode: no syscall returns
an, it just starts trying to do dma with device A, and the packets get
written into the IOAS that belongs to device B instead. Sounds like a
complete nightmare to debug if you don't know about groups, because
you never thought you cared.

And yes, for a simple bridge like this app, attaching all the devices
to the same IOAS is a more likely setup. But using an IOAS per device
is a perfectly valid configuration as well, and with the current draft
nothing will warn the app that this is a bad idea.

> From what I see the applications do what the admin tells them to do -
> and if the admin says to use a certain VFIO device then that is
> excatly what they do. I don't know of any applications that ask the
> admin to tell them group information.
>
> What I see is aligning what the kernel provides to the APIs the
> applications have already built.
>
> Jason
>

--
David Gibson | I'll have my music baroque, and my code
david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_
| _way_ _around_!
http://www.ozlabs.org/~dgibson

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

[-- Attachment #2: Type: text/plain, Size: 156 bytes --]