Re: [PATCH v4 04/14] PCI/P2PDMA: Clear ACS P2P flags for all devices behind switches

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

 



Am 10.05.2018 um 19:15 schrieb Logan Gunthorpe:

On 10/05/18 11:11 AM, Stephen  Bates wrote:
Not to me. In the p2pdma code we specifically program DMA engines with
the PCI bus address.
Ah yes of course. Brain fart on my part. We are not programming the P2PDMA initiator with an IOVA but with the PCI bus address...

By disabling the ACS bits on the intermediate bridges you turn their address routing from IOVA addresses (which are to be resolved by the root complex) back to PCI bus addresses (which are resolved locally in the bridge).

This only works when the IOVA and the PCI bus addresses never overlap. I'm not sure how the IOVA allocation works but I don't think we guarantee that on Linux.


So regardless of whether we are using the IOMMU or
not, the packets will be forwarded directly to the peer. If the ACS
  Redir bits are on they will be forced back to the RC by the switch and
  the transaction will fail. If we clear the ACS bits, the TLPs will go
  where we want and everything will work (but we lose the isolation of ACS).
Agreed.

If we really want to enable P2P without ATS and IOMMU enabled I think we should probably approach it like this:

a) Make double sure that IOVA in an IOMMU group never overlap with PCI BARs in that group.

b) Add configuration options to put a whole PCI branch of devices (e.g. a bridge) into a single IOMMU group.

c) Add a configuration option to disable the ACS bit on bridges in the same IOMMU group.


I agree that we have a rather special case here, but I still find that approach rather brave and would vote for disabling P2P without ATS when IOMMU is enabled.


BTW: I can't say anything about other implementations, but at least for the AMD-IOMMU the transaction won't fail when it is send to the root complex.

Instead the root complex would send it to the correct device. I already tested that on an AMD Ryzen with IOMMU enabled and P2P between two GPUs (but could be that this only works because of ATS).

Regards,
Christian.

    For EPs that support ATS, we should (but don't necessarily have to)
    program them with the IOVA address so they can go through the
    translation process which will allow P2P without disabling the ACS Redir
    bits -- provided the ACS direct translation bit is set. (And btw, if it
    is, then we lose the benefit of ACS protecting against malicious EPs).
    But, per above, the ATS transaction should involve only the IOVA address
    so the ACS bits not being set should not break ATS.
Well we would still have to clear some ACS bits but now we can clear only for translated addresses.
We don't have to clear the ACS Redir bits as we did in the first case.
We just have to make sure the ACS Direct Translated bit is set.

Logan




[Index of Archives]     [Linux RAID]     [Linux SCSI]     [Linux ATA RAID]     [IDE]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Device Mapper]

  Powered by Linux