Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp5267698rwb; Wed, 17 Aug 2022 14:27:30 -0700 (PDT) X-Google-Smtp-Source: AA6agR7lMFOo65lXI/S2iPWk/kL53XFt3kg4bPWLRK7quNksbfttgaPetROY4mQpqMFEu8iI8emx X-Received: by 2002:a05:6402:90d:b0:443:ef4c:480f with SMTP id g13-20020a056402090d00b00443ef4c480fmr16904edz.128.1660771650740; Wed, 17 Aug 2022 14:27:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660771650; cv=none; d=google.com; s=arc-20160816; b=eoQ/ORZLbReVfGwcOU/yvruofCoC4hmxG2/wgwvVkpzR3vXUA8gdVgbJUQgH0PWcNr H1UgcXrddlN2mY4gua02QTdbFClN9zH8O9ulPh/x1hPBKgkKupuPyhOgiFnRinrAL8et TVwlAE34W6PgQEvbggFj2zYJbUJPomY+INXKBisNrMsbJF3zPlYyZMGzcD5LHaZwVpbk k76hstQR5qNSzoRKsmXyhE2kt83abWO8nxt4YAPPRBzenUsflqtNUlgj4/hv4GiFC+4a vt526MkjUdFUmbt0wn73ZGfAQiAhivwh9+/vEh1hSQ9mHVV8shDRv0BCUAGgWrZCK0vz WIcQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :message-id:subject:cc:to:from:date:dkim-signature; bh=VVrlbcDNxeILUL+lWaEXChx9BEl8tWK2nlp+RYUOQEg=; b=lkRnCnNG5oAI6QKzAhPchpNw9dK5c6o7QyZach+fLbZlTc/Qw562sfoNu84rCjk1CL l4vTsrDx845hx81lwPqRN6YJnY2y55v9lvfSTbp5JRPcCLdv2bGQudNfonMTRIXFA89H EajxRHQIb5oimkdKSULz01NGphdkysiCuUdzCXjx7R+bVv9iWjkr0YkDexNm3TpPRK7G UqBc3VOR1FVGqitp4Pw5NsPNaYb9kgrocvmtDb88qDkM7C2MtSg0wczy6N3XoGiPaIU9 cN1UXa1KfuGwoMgf7qIt9V1oMRKp9mb8X2xOnDqc6gkecP8RzUYVyFUd8Zx1MjA1KJFd OUmw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=ofD9MlTR; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ga13-20020a1709070c0d00b006ff49b183e9si1025185ejc.971.2022.08.17.14.27.06; Wed, 17 Aug 2022 14:27:30 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=ofD9MlTR; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241752AbiHQVRv (ORCPT + 99 others); Wed, 17 Aug 2022 17:17:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52736 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235159AbiHQVRu (ORCPT ); Wed, 17 Aug 2022 17:17:50 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 01FCC57564; Wed, 17 Aug 2022 14:17:49 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id AC451B81F99; Wed, 17 Aug 2022 21:17:47 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id F3D92C433C1; Wed, 17 Aug 2022 21:17:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1660771066; bh=vuBF7ADDDys2amXNJQY4RfW15B+ZTZQfk/0OWbwwenw=; h=Date:From:To:Cc:Subject:In-Reply-To:From; b=ofD9MlTRsM+ltsFAOYVSogg5ogb3x7ZW3QI7kj49uZBU91x2mfKtFMZ58BQsw3HnA sSFgdsPJvKSJ+x/Y3Rcg7Lw4lyqWaVbogfwRD+e0bkmwzbFbVKW+juv4QP/u6MPQgW MSd4J1iR0deRRgQvx3JScGxjaygZpvYmydy+qGScozCiWnMPbfvfrj0qeOo9imc9Xo +9+8F5Ezf90+utCQ3VFXzpNmtbrWgU+HHe7asljI2m47nf0MTq+/DqhC9AiPDAJeuL OlnQ84RqPSeS7SL8S0fqQjXiXDxihIP8JXGb8CXoPiPFOZ8+6L11JCTC6MECCEr1qR 8tV+A/QFCL4wA== Date: Wed, 17 Aug 2022 16:17:43 -0500 From: Bjorn Helgaas To: Lu Baolu Cc: Joerg Roedel , Jason Gunthorpe , Christoph Hellwig , Bjorn Helgaas , Kevin Tian , Ashok Raj , Will Deacon , Robin Murphy , Jean-Philippe Brucker , Dave Jiang , Vinod Koul , Eric Auger , Liu Yi L , Jacob jun Pan , Zhangfei Gao , Zhu Tony , iommu@lists.linux.dev, linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v11 04/13] PCI: Allow PASID only when ACS enforced on upstreaming path Message-ID: <20220817211743.GA2274788@bhelgaas> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220817012024.3251276-5-baolu.lu@linux.intel.com> X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 > Suggested-by: Kevin Tian > Signed-off-by: Lu Baolu > --- > 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 >