[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <Y9PYppHmuSVSqQ62@nvidia.com>
Date: Fri, 27 Jan 2023 09:59:02 -0400
From: Jason Gunthorpe <jgg@...dia.com>
To: Baolu Lu <baolu.lu@...ux.intel.com>
Cc: Robin Murphy <robin.murphy@....com>, joro@...tes.org,
will@...nel.org, hch@....de, iommu@...ts.linux.dev,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH 1/8] iommu: Decouple iommu_present() from bus ops
On Fri, Jan 27, 2023 at 09:50:29PM +0800, Baolu Lu wrote:
> On 2023/1/26 22:41, Jason Gunthorpe wrote:
> > On Thu, Jan 26, 2023 at 02:21:29PM +0000, Robin Murphy wrote:
> >
> > > The "check" is inherent in the fact that it's been called at all. VFIO
> > > noiommu*is* an IOMMU driver in the sense that it provides a bare minimum of
> > > IOMMU API functionality (i.e. creating groups), sufficient to support
> > > (careful) usage by VFIO drivers. There would not seem to be a legitimate
> > > reason for some*other* driver to be specifically querying a device while it
> > > is already bound to a VFIO driver (and thus may have a noiommu group).
> > Yes, the devices that VFIO assigns to its internal groups never leak
> > outside VFIO's control during their assignment - ie they are
> > continuously bound to VFIO never another driver.
> >
> > So no other driver can ever see the internal groups unless it is
> > messing around with devices it is not bound to 😄
>
> Fair enough. I was thinking that probably we could make it like below:
>
> /**
> * device_iommu_mapped - Returns true when the device DMA is translated
> * by an IOMMU
> * @dev: Device to perform the check on
> */
> static inline bool device_iommu_mapped(struct device *dev)
> {
> return (dev->iommu && dev->iommu->iommu_dev);
> }
>
> The iommu probe device code guarantees that dev->iommu->iommu_dev is
> valid only after the IOMMU driver's .probe_device returned successfully.
>
> Any thoughts?
I find the above much clearer if it can work
Jason
Powered by blists - more mailing lists