lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20220727115339.GM4438@nvidia.com>
Date:   Wed, 27 Jul 2022 08:53:39 -0300
From:   Jason Gunthorpe <jgg@...dia.com>
To:     "Tian, Kevin" <kevin.tian@...el.com>
Cc:     Baolu Lu <baolu.lu@...ux.intel.com>,
        Joerg Roedel <joro@...tes.org>,
        Christoph Hellwig <hch@...radead.org>,
        "Raj, Ashok" <ashok.raj@...el.com>, Will Deacon <will@...nel.org>,
        Robin Murphy <robin.murphy@....com>,
        Jean-Philippe Brucker <jean-philippe@...aro.com>,
        "Jiang, Dave" <dave.jiang@...el.com>,
        Vinod Koul <vkoul@...nel.org>,
        Eric Auger <eric.auger@...hat.com>,
        "Liu, Yi L" <yi.l.liu@...el.com>,
        "Pan, Jacob jun" <jacob.jun.pan@...el.com>,
        Zhangfei Gao <zhangfei.gao@...aro.org>,
        "Zhu, Tony" <tony.zhu@...el.com>,
        "iommu@...ts.linux.dev" <iommu@...ts.linux.dev>,
        "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
        Jean-Philippe Brucker <jean-philippe@...aro.org>
Subject: Re: [PATCH v10 04/12] iommu: Add attach/detach_dev_pasid iommu
 interface

On Wed, Jul 27, 2022 at 03:20:25AM +0000, Tian, Kevin wrote:
> > From: Jason Gunthorpe <jgg@...dia.com>
> > Sent: Tuesday, July 26, 2022 9:57 PM
> > 
> > On Tue, Jul 26, 2022 at 02:23:26PM +0800, Baolu Lu wrote:
> > > On 2022/7/25 22:40, Jason Gunthorpe wrote:
> > > > On Sun, Jul 24, 2022 at 03:03:16PM +0800, Baolu Lu wrote:
> > > >
> > > > > How about rephrasing this part of commit message like below:
> > > > >
> > > > > Some buses, like PCI, route packets without considering the PASID value.
> > > > > Thus a DMA target address with PASID might be treated as P2P if the
> > > > > address falls into the MMIO BAR of other devices in the group. To make
> > > > > things simple, these interfaces only apply to devices belonging to the
> > > > > singleton groups.
> > > >
> > > > > Considering that the PCI bus supports hot-plug, even a device boots
> > with
> > > > > a singleton group, a later hot-added device is still possible to share
> > > > > the group, which breaks the singleton group assumption. In order to
> > > > > avoid this situation, this interface requires that the ACS is enabled on
> > > > > all devices on the path from the device to the host-PCI bridge.
> > > >
> > > > But ACS directly fixes the routing issue above
> > > >
> > > > This entire explanation can be recast as saying we block PASID
> > > > attachment in all cases where the PCI fabric is routing based on
> > > > address. ACS disables that.
> > > >
> > > > Not sure it even has anything to do with hotplug or singleton??
> > >
> > > Yes, agreed. I polished this patch like below. Does it look good to you?
> > >
> > > iommu: Add attach/detach_dev_pasid iommu interface
> > >
> > > Attaching an IOMMU domain to a PASID of a device is a generic operation
> > > for modern IOMMU drivers which support PASID-granular DMA address
> > > translation. Currently visible usage scenarios include (but not limited):
> > >
> > >  - SVA (Shared Virtual Address)
> > >  - kernel DMA with PASID
> > >  - hardware-assist mediated device
> > >
> > > This adds a pair of domain ops for this purpose and adds the interfaces
> > > for device drivers to attach/detach a domain to/from a {device,
> > > PASID}.
> > 
> > > The PCI bus routes packets without considering the PASID value.
> > 
> > More like:
> > 
> > Some configurations of the PCI fabric will route device originated TLP
> > packets based on memory address, and these configurations are
> > incompatible with PASID as the PASID packets form a distinct address
> > space. For instance any configuration where switches are present
> > without ACS is incompatible with PASID.
> 
> This description reads like ACS enables PASID-based routing...

Well, that is kind of what it is.

> In reality PCI fabric always route TLP based on memory address.
> ACS just provides a way to redirect the packet to RC, with or
> without PASID.

Always except in all the cases it doesn't, like ACS :)

> > > +	 * Block PASID attachment in all cases where the PCI fabric is
> > > +	 * routing based on address. ACS disables it.
> > > +	 */
> > > +	if (dev_is_pci(dev) &&
> > > +	    !pci_acs_path_enabled(to_pci_dev(dev), NULL, REQ_ACS_FLAGS))
> > > +		return -ENODEV;
> > 
> > I would probably still put this in a function just to be clear, and
> > probably even a PCI layer funcion 'pci_is_pasid_supported' that
> > clearly indicates that the fabric path can route a PASID packet
> > without mis-routing it.
> 
> But there is no single line in above check related to PASID...

The question to answer here is if the device/fabric supports PASID,
and on PCI that requires ACS on any switches. IMHO that is a PCI layer
question and perhaps we shouldn't even succeed pci_enable_pasid() if
ACS isn't on.

Then we don't need this weirdo check in the core iommu code at all.

Jason

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ