Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp827286ybt; Fri, 10 Jul 2020 13:30:02 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzqzt1bVXhEXr7tA9S/uYLvXWqNVksFEIG6clI+bQypPcic5G7/KhQMHcSdXT54t4QsQSKA X-Received: by 2002:aa7:c5d4:: with SMTP id h20mr77622053eds.115.1594413002578; Fri, 10 Jul 2020 13:30:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594413002; cv=none; d=google.com; s=arc-20160816; b=I6K8vYboCcTzg3lkac27durkQjGYgoijvM5BQXoc8ZR07cse08I7jh4RtkXTeqkZwE 96xsIn2VEdjHUvl5Tye/+UQ3B0m5oV3qVElRgcKuJhWP/YVeRaQbB8H6th8NWckmPdAE Zs6Q/6G9/l/gFMp6a9DR0kNr3ojl8d0QYRj/nw8U7ojUkXEJyKXtp52Bac5cfPKmfYAs QeRR6xaCl1Vxf6Yk4Z2y9agvBMJ+9jxOEc9oYi/aRshrPf5NnDqBdLRCAHg+irfBdNaO MsVGVqaPyEcD1AJj5IwHTlcZKTfXAd8aavpZjRb9sx/87ZsFZNiEMXci03UbgN50EmTN e4jQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:message-id:subject:cc:to:from:date:dkim-signature; bh=ecoGORuFz6ZBlYdIfqr1U2dbzhhstG2IM1K/sLenT0s=; b=eMDb3YunJAgZJzNi7acjmrCeiYoXAP9QKKY77de+Hp4Akg6qNQ7DSQ7KiUdYgIzP1m 5h9PMXuGB0H0OvwQc+LljtTANG4YBUEbNxMVkJGW3d7a7ykW37hWfB1oXW8cdaOnhpMq Pjbr7w8qeqPV8HNc39oHACsOkBtcy1DPz8o31q49RA5EFJzLX6J5kp5CDEc3DvB2AFv1 Oha0U73392ADLaTngM9q790cXDxT6aY7hub/KFCtiGdSUWEnxgi20ZUEa7aMq1FwXTBE mEVS5jDRz8RD+0Dj0I4iWj4TBi9Hi74mIeud4HvZNCnisb0fQfkL+ox6tjLELqBI8jhg /mpw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Mg98WBUB; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id m16si4433271eji.77.2020.07.10.13.29.36; Fri, 10 Jul 2020 13:30:02 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Mg98WBUB; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S1727107AbgGJU3Z (ORCPT + 99 others); Fri, 10 Jul 2020 16:29:25 -0400 Received: from mail.kernel.org ([198.145.29.99]:53848 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726832AbgGJU3Y (ORCPT ); Fri, 10 Jul 2020 16:29:24 -0400 Received: from localhost (mobile-166-175-191-139.mycingular.net [166.175.191.139]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 01EEA20748; Fri, 10 Jul 2020 20:29:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1594412964; bh=DiQoR/qIH6L3RLjeyhUKDGJQxa1UAOogxnzXV3WwyYM=; h=Date:From:To:Cc:Subject:In-Reply-To:From; b=Mg98WBUBOpphkDnIHW8UWq9hjz21UEVfEZUm2hCYj4fI3Z3Pd0mvcodlBgh3hPfQR 8i6qn/ymwX6+Hwn75+YwG8EoV/evuOSi7qZEpRc4q3e858ej7z4C76bhgqNhGmxHlC v0NqnH5iKyuPe4eCHax/Um6J0l3evRwJGkibQ3jg= Date: Fri, 10 Jul 2020 15:29:22 -0500 From: Bjorn Helgaas To: Rajat Jain Cc: David Woodhouse , Lu Baolu , Joerg Roedel , Bjorn Helgaas , "Rafael J. Wysocki" , Len Brown , iommu@lists.linux-foundation.org, linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org, linux-acpi@vger.kernel.org, Raj Ashok , lalithambika.krishnakumar@intel.com, Mika Westerberg , Jean-Philippe Brucker , Prashant Malani , Benson Leung , Todd Broch , Alex Levin , Mattias Nissler , Rajat Jain , Bernie Keany , Aaron Durbin , Diego Rivas , Duncan Laurie , Furquan Shaikh , Jesse Barnes , Christian Kellner , Alex Williamson , Greg Kroah-Hartman , oohall@gmail.com, Saravana Kannan , Suzuki K Poulose , Arnd Bergmann , Heikki Krogerus Subject: Re: [PATCH v4 4/4] PCI/ACS: Enable PCI_ACS_TB for untrusted/external-facing devices Message-ID: <20200710202922.GA77140@bjorn-Precision-5520> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200707224604.3737893-4-rajatja@google.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jul 07, 2020 at 03:46:04PM -0700, Rajat Jain wrote: > When enabling ACS, enable translation blocking for external facing ports > and untrusted devices. > > Signed-off-by: Rajat Jain > --- > v4: Add braces to avoid warning from kernel robot > print warning for only external-facing devices. > v3: print warning if ACS_TB not supported on external-facing/untrusted ports. > Minor code comments fixes. > v2: Commit log change > > drivers/pci/pci.c | 8 ++++++++ > drivers/pci/quirks.c | 15 +++++++++++++++ > 2 files changed, 23 insertions(+) > > diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c > index 73a8627822140..a5a6bea7af7ce 100644 > --- a/drivers/pci/pci.c > +++ b/drivers/pci/pci.c > @@ -876,6 +876,14 @@ static void pci_std_enable_acs(struct pci_dev *dev) > /* Upstream Forwarding */ > ctrl |= (cap & PCI_ACS_UF); > > + /* Enable Translation Blocking for external devices */ > + if (dev->external_facing || dev->untrusted) { > + if (cap & PCI_ACS_TB) > + ctrl |= PCI_ACS_TB; > + else if (dev->external_facing) > + pci_warn(dev, "ACS: No Translation Blocking on external-facing dev\n"); > + } IIUC, this means that external devices can *never* use ATS and can never cache translations. And (I guess, I'm not an expert) it can also never use the Page Request Services? Is this what we want? Do we have any idea how many external devices this will affect or how much of a performance impact they will see? Do we need some kind of override or mechanism to authenticate certain devices so they can use ATS and PRI? If we do decide this is the right thing to do, I think we need to expand the commit log a bit, because this is potentially a significant user-visible change. > pci_write_config_word(dev, pos + PCI_ACS_CTRL, ctrl); > } > > diff --git a/drivers/pci/quirks.c b/drivers/pci/quirks.c > index b341628e47527..bb22b46c1d719 100644 > --- a/drivers/pci/quirks.c > +++ b/drivers/pci/quirks.c > @@ -4934,6 +4934,13 @@ static void pci_quirk_enable_intel_rp_mpc_acs(struct pci_dev *dev) > } > } > > +/* > + * Currently this quirk does the equivalent of > + * PCI_ACS_SV | PCI_ACS_RR | PCI_ACS_CR | PCI_ACS_UF > + * > + * TODO: This quirk also needs to do equivalent of PCI_ACS_TB, > + * if dev->external_facing || dev->untrusted > + */ > static int pci_quirk_enable_intel_pch_acs(struct pci_dev *dev) > { > if (!pci_quirk_intel_pch_acs_match(dev)) > @@ -4973,6 +4980,14 @@ static int pci_quirk_enable_intel_spt_pch_acs(struct pci_dev *dev) > ctrl |= (cap & PCI_ACS_CR); > ctrl |= (cap & PCI_ACS_UF); > > + /* Enable Translation Blocking for external devices */ > + if (dev->external_facing || dev->untrusted) { > + if (cap & PCI_ACS_TB) > + ctrl |= PCI_ACS_TB; > + else if (dev->external_facing) > + pci_warn(dev, "ACS: No Translation Blocking on external-facing dev\n"); > + } > + > pci_write_config_dword(dev, pos + INTEL_SPT_ACS_CTRL, ctrl); > > pci_info(dev, "Intel SPT PCH root port ACS workaround enabled\n"); > -- > 2.27.0.212.ge8ba1cc988-goog >