Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp306707imm; Mon, 21 May 2018 06:26:04 -0700 (PDT) X-Google-Smtp-Source: AB8JxZo8zjDGU/rVfEZhVBYPt++Woe9ypXHearUIfnfH4xm5LVznPGYcUwTXBboK5T8X5i5pU+uf X-Received: by 2002:a63:7415:: with SMTP id p21-v6mr9606381pgc.373.1526909164575; Mon, 21 May 2018 06:26:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526909164; cv=none; d=google.com; s=arc-20160816; b=dyyK7trs3+P2BgexjBcW+YCr93b+wR/2G2M/nvlj9rDbx54pxZYXSKfIhE6RT+xgar wFfchP7ZXBZ8LRAmW8Y9FGVVLJWiJncRD/L4dDHvX0TpTOoa4xVXcFnQQbHjXHtTqvoC Ze+/RTm1UzAMTkeq451SUyTWyJiwHgkW+z0jT/DYv9z9oeprV9wS/NQnXItQS+L49URS y9vjVWK1+IYHvf4fzMjig8Z6jPcrssskVyD+G4HXM+vKjOSmmTmYzF08uKZEQFLWO0tU RDjqrd57xliOCiaBsIZBBKKautbpYwNnO9i1ktf9Fw6hSuIk5TE5En04ydVp/PSNJ+uz yWKA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dmarc-filter :dkim-signature:dkim-signature:arc-authentication-results; bh=6JSejRNcYmGU076Yi02alpSFXAO7ukJ2QDDvI828koo=; b=UT65pPIZGbZVk/GrWC7iKK8fm+hGE7lhLXbOBRJ45j52dGcKb2+SyhEHbPl4stxmZA vldg1UjXpHX+Xy0oO2iq8+74KemKEodklcnEBaTsMKVEUwgJZCveeJtGH8YgAOIkhg/x 94cjYCV4DCr6Bl3lp4qebPMoj/uROGStEJ7Cb5PwVj/3lGcRg+I2MdSWygXN7lSFWCSU mRA9L5w824/RywtkitDkiYwV6xieyk8rjXbu56l4qkGDek8vKqc1fqMeU7qTWfqFonNo 7PcGRfRixH7YTkNHDN0UUlbjlLCoV9tlY9U3pFBwJ/1UnwuyGQeHNR4LmSej3t3VM4kf RgHw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@codeaurora.org header.s=default header.b=lWIDPrT2; dkim=pass header.i=@codeaurora.org header.s=default header.b=bal71MbH; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a7-v6si11357465pgd.338.2018.05.21.06.25.50; Mon, 21 May 2018 06:26:04 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@codeaurora.org header.s=default header.b=lWIDPrT2; dkim=pass header.i=@codeaurora.org header.s=default header.b=bal71MbH; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751719AbeEUNZe (ORCPT + 99 others); Mon, 21 May 2018 09:25:34 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:37536 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750962AbeEUNZa (ORCPT ); Mon, 21 May 2018 09:25:30 -0400 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 5E7FD60AF9; Mon, 21 May 2018 13:25:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1526909130; bh=G2tnmJNqv47Jq/kMsXjB9854Zbxx4RfIx54XNqw/9+M=; h=Subject:To:Cc:References:From:Date:In-Reply-To:From; b=lWIDPrT2yUdGgMGadLZVekcLzVST29iK6NG87Viqcp6iDGMhuLTp7f5G/+rOWzXZW N/xcEIcAFO2elq29nXZ1iZ1cUOQ1oLugDyVbqtF+rW9JSer4w0QdtKYVD9LZddhiO5 LfQYQXqTzAkKPFvlN4godkGVeVqEIYhKec61QwEc= X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on pdx-caf-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.8 required=2.0 tests=ALL_TRUSTED,BAYES_00, DKIM_SIGNED,T_DKIM_INVALID autolearn=no autolearn_force=no version=3.4.0 Received: from [192.168.0.106] (cpe-174-109-247-98.nc.res.rr.com [174.109.247.98]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: okaya@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id 276FA601D4; Mon, 21 May 2018 13:25:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1526909129; bh=G2tnmJNqv47Jq/kMsXjB9854Zbxx4RfIx54XNqw/9+M=; h=Subject:To:Cc:References:From:Date:In-Reply-To:From; b=bal71MbH5/rjEp6SHR3eiEiJHypZ3+8tS1SkaOol30+aTvr3fXUzKjjj6SwQUCIvN BWAwBEqqKvKySVY0DODZDRgcK8juyTL0YyXbVTpbpbrat9mNrWYnYmbeHwYfIievWl 5HBgV8Eo5Cunw/w9OM2HYOghR0hMp7kGvRcJWlgI= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 276FA601D4 Authentication-Results: pdx-caf-mail.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: pdx-caf-mail.web.codeaurora.org; spf=none smtp.mailfrom=okaya@codeaurora.org Subject: Re: [PATCH] PCI: Do not enable PASID when End-to-End TLP is not supported To: linux-pci@vger.kernel.org, timur@codeaurora.org Cc: linux-arm-msm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Bjorn Helgaas , open list , iommu@lists.linux-foundation.org References: <1526748769-701-1-git-send-email-okaya@codeaurora.org> From: Sinan Kaya Message-ID: Date: Mon, 21 May 2018 09:25:26 -0400 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.7.0 MIME-Version: 1.0 In-Reply-To: <1526748769-701-1-git-send-email-okaya@codeaurora.org> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org +iommu folks. On 5/19/2018 12:52 PM, Sinan Kaya wrote: > A PCIe endpoint carries the process address space identifier (PASID) in > the TLP prefix as part of the memory read/write transaction. The address > information in the TLP is relevant only for a given PASID context. > > A translation agent takes PASID value and the address information from the > TLP to look up the physical address in the system. > > If a bridge drops the TLP prefix, the translation agent can resolve the > address to an incorrect location and cause data corruption. Prevent > this condition by requiring End-to-End TLP prefix to be supported on the > entire data path between the endpoint and the root port. > > Signed-off-by: Sinan Kaya > --- > drivers/pci/ats.c | 16 ++++++++++++++++ > include/uapi/linux/pci_regs.h | 1 + > 2 files changed, 17 insertions(+) > > diff --git a/drivers/pci/ats.c b/drivers/pci/ats.c > index 89305b5..0bcded5 100644 > --- a/drivers/pci/ats.c > +++ b/drivers/pci/ats.c > @@ -265,7 +265,9 @@ EXPORT_SYMBOL_GPL(pci_reset_pri); > int pci_enable_pasid(struct pci_dev *pdev, int features) > { > u16 control, supported; > + struct pci_dev *bridge; > int pos; > + u32 cap; > > if (WARN_ON(pdev->pasid_enabled)) > return -EBUSY; > @@ -274,6 +276,20 @@ int pci_enable_pasid(struct pci_dev *pdev, int features) > if (!pos) > return -EINVAL; > > + bridge = pci_upstream_bridge(pdev); > + while (bridge) { > + if (!pci_find_capability(bridge, PCI_CAP_ID_EXP)) > + return -EINVAL; > + > + if (pcie_capability_read_dword(bridge, PCI_EXP_DEVCAP2, &cap)) > + return -EINVAL; > + > + if (!(cap & PCI_EXP_DEVCAP2_E2ETLP)) > + return -EINVAL; > + > + bridge = pci_upstream_bridge(bridge); > + } > + > pci_read_config_word(pdev, pos + PCI_PASID_CAP, &supported); > supported &= PCI_PASID_CAP_EXEC | PCI_PASID_CAP_PRIV; > > diff --git a/include/uapi/linux/pci_regs.h b/include/uapi/linux/pci_regs.h > index 103ba79..d91dea5 100644 > --- a/include/uapi/linux/pci_regs.h > +++ b/include/uapi/linux/pci_regs.h > @@ -634,6 +634,7 @@ > #define PCI_EXP_DEVCAP2_OBFF_MASK 0x000c0000 /* OBFF support mechanism */ > #define PCI_EXP_DEVCAP2_OBFF_MSG 0x00040000 /* New message signaling */ > #define PCI_EXP_DEVCAP2_OBFF_WAKE 0x00080000 /* Re-use WAKE# for OBFF */ > +#define PCI_EXP_DEVCAP2_E2ETLP 0x00200000 /* End-to-End TLP Prefix */ > #define PCI_EXP_DEVCTL2 40 /* Device Control 2 */ > #define PCI_EXP_DEVCTL2_COMP_TIMEOUT 0x000f /* Completion Timeout Value */ > #define PCI_EXP_DEVCTL2_COMP_TMOUT_DIS 0x0010 /* Completion Timeout Disable */ > -- Sinan Kaya Qualcomm Datacenter Technologies, Inc. as an affiliate of Qualcomm Technologies, Inc. Qualcomm Technologies, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project.