[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20220817211743.GA2274788@bhelgaas>
Date: Wed, 17 Aug 2022 16:17:43 -0500
From: Bjorn Helgaas <helgaas@...nel.org>
To: Lu Baolu <baolu.lu@...ux.intel.com>
Cc: Joerg Roedel <joro@...tes.org>, Jason Gunthorpe <jgg@...dia.com>,
Christoph Hellwig <hch@...radead.org>,
Bjorn Helgaas <bhelgaas@...gle.com>,
Kevin Tian <kevin.tian@...el.com>,
Ashok Raj <ashok.raj@...el.com>, Will Deacon <will@...nel.org>,
Robin Murphy <robin.murphy@....com>,
Jean-Philippe Brucker <jean-philippe@...aro.com>,
Dave Jiang <dave.jiang@...el.com>,
Vinod Koul <vkoul@...nel.org>,
Eric Auger <eric.auger@...hat.com>,
Liu Yi L <yi.l.liu@...el.com>,
Jacob jun Pan <jacob.jun.pan@...el.com>,
Zhangfei Gao <zhangfei.gao@...aro.org>,
Zhu Tony <tony.zhu@...el.com>, iommu@...ts.linux.dev,
linux-pci@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH v11 04/13] PCI: Allow PASID only when ACS enforced on
upstreaming path
On Wed, Aug 17, 2022 at 09:20:15AM +0800, Lu Baolu wrote:
> Some configurations of the PCI fabric will route device originated TLP
> packets based on the memory addresses.
This makes it sound like a few unusual configurations will route TLPs
based on memory addresses, but address routing is the default for all
PCIe Memory Requests, and ACS provides a way to override that default.
> These configurations are incompatible with PASID as the PASID
> packets form a distinct address space.
I would say "the Requester ID/PASID combination forms a distinct
address space."
> For instance, any configuration where switches are present
> without ACS enabled is incompatible.
>
> This enhances the pci_enable_pasid() interface by requiring the ACS to
> support Source Validation, Request Redirection, Completer Redirection,
> and Upstream Forwarding. This effectively means that devices cannot
> spoof their requester ID, requests and completions cannot be redirected,
> and all transactions are forwarded upstream, even as it passes through a
> bridge where the target device is downstream.
I think your patch actually requires all those features to be not just
"supported" but actually *enabled* for the entire path leading to the
device.
To use the terms from the spec:
"P2P Request Redirect"
"P2P Completion Redirect"
"Requester ID, Requests, and Completions"
and maybe something like:
... even if the TLP looks like a P2P Request because its memory
address (ignoring the PASID) would fall in a bridge window and would
normally be routed downstream.
Does the PCIe spec really allow TLPs with PASID to be routed anywhere
except upstream? It seems nonsensical to route them downstream, and
hardware should be able to check that easily. But I took a quick look
through the spec and didn't see anything about PASID by itself
influencing routing.
> Suggested-by: Jason Gunthorpe <jgg@...dia.com>
> Suggested-by: Kevin Tian <kevin.tian@...el.com>
> Signed-off-by: Lu Baolu <baolu.lu@...ux.intel.com>
> ---
> drivers/pci/ats.c | 5 +++++
> 1 file changed, 5 insertions(+)
>
> diff --git a/drivers/pci/ats.c b/drivers/pci/ats.c
> index c967ad6e2626..0715e48e7973 100644
> --- a/drivers/pci/ats.c
> +++ b/drivers/pci/ats.c
> @@ -382,6 +382,11 @@ int pci_enable_pasid(struct pci_dev *pdev, int features)
> if (!pasid)
> return -EINVAL;
>
> + if (!pci_acs_path_enabled(pdev, NULL,
> + PCI_ACS_SV | PCI_ACS_RR |
> + PCI_ACS_CR | PCI_ACS_UF))
> + return -EINVAL;
> +
> pci_read_config_word(pdev, pasid + PCI_PASID_CAP, &supported);
> supported &= PCI_PASID_CAP_EXEC | PCI_PASID_CAP_PRIV;
>
> --
> 2.25.1
>
Powered by blists - more mailing lists