Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp909526ybt; Fri, 10 Jul 2020 15:57:22 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwFuisv6qZufD+yszmaTdCkjGhwvR76QlHBLkszESjEy6w8y76Mc48NolXMrM6IeWbf0V++ X-Received: by 2002:a50:e8c8:: with SMTP id l8mr81618415edn.386.1594421841995; Fri, 10 Jul 2020 15:57:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594421841; cv=none; d=google.com; s=arc-20160816; b=QDJoM3cwERcmXonbGwo3mOK1ibuu9LVS94O24ICNRY4lYGc+CLbhtzjfb/VV89WHRc a0w9KseGOTNcNoSXnF0swbkBy13FpCkXqtQsrPEJU1l3ibFfbqFDlUFRybOWwBthjQ7V SHY0DPCs27SqCwdL3/r5K4zJ0ayGG+PLzFJp4jGx6pqrfzwRdYyWKTvEyzifVEeL/dhL DbR0EO460RSboCkVR0+nM1if0B+YNxa1HolPC0+oTsBMdmBJKJgZxi7otHXL3BnXKDrc k6NIumjM72j2OEJ3lUVBUdUFf+YUHMVUWwGpyoWHauhYos8v6r1btap8zTtYxTX4u0H/ FTzQ== 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:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=U7Cna4GrnjdjT+b7GHMGh/kq7NJ5oQ1TUzK9PPX6KpA=; b=lUREIY3AHnIe4T+7cvmcRXPT3nWVFzPap6UxGlknjdh8zzzJyRFZz4Zbp2HfUbAzTz LPh7R58o+XSLnpOd/2UkApHEjf3qzuFENXAVUwJoVfeqjyFKrzY8IRZVp01B/SRJAQdw EvjqordrH43Xg8lsLJGxvpPAFcsPv+5j+KSmNoL/8L16ZuUDmT+pY7q9LFCU0JaTBCU+ OkY2x29OqiGYNgZa6krfskd708mss1kt/6OJZQDUU8O4cuGXmg9u58ly6jFd3VujneVK sXuD0Gpu6Maxf1kMuZmYxQknUKThU9vhLwvD404+yAIOj+gdj1l6wGTT5FLtmW7qvona rjHA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=a6gbiToy; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h24si5057183ejk.168.2020.07.10.15.56.59; Fri, 10 Jul 2020 15:57:21 -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=@google.com header.s=20161025 header.b=a6gbiToy; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726709AbgGJWyi (ORCPT + 99 others); Fri, 10 Jul 2020 18:54:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37242 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726671AbgGJWyi (ORCPT ); Fri, 10 Jul 2020 18:54:38 -0400 Received: from mail-lj1-x241.google.com (mail-lj1-x241.google.com [IPv6:2a00:1450:4864:20::241]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 89367C08E6DC for ; Fri, 10 Jul 2020 15:54:37 -0700 (PDT) Received: by mail-lj1-x241.google.com with SMTP id f5so8153225ljj.10 for ; Fri, 10 Jul 2020 15:54:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=U7Cna4GrnjdjT+b7GHMGh/kq7NJ5oQ1TUzK9PPX6KpA=; b=a6gbiToyPxUK3InfnvVZBU7oEbpYuMHbk6eqF+jMiyF6wPT/Z64eZPlf9V/Zaj1LP0 kZkRbL0Saj2MSBonD6QOvJtpDCP2I9w4TiFF2V/ooWVigvgcrvNCYundCD09B2fhaRZC 9fPoMp36q6NZg4kG4CICGp8zwK77O+Q8BzzEEVkx6GU9J8snKkF2O8x4zqunNyNJ4C1j OyJQQ9d6oHiaBsXbA+I2CBySWDPATgKnetYtFn0V5V8vPhQfKZrMg6MDD8ClpR3w7qev HSOD61JmBfoOD566JRe76F7tSyYg9i/0gen00XoPo7Cn5Pwb5VHMJvJgGb2KNuASs9ow 7iNQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=U7Cna4GrnjdjT+b7GHMGh/kq7NJ5oQ1TUzK9PPX6KpA=; b=pp0TKssSYSJEl+OQOrGNkfHNURG/U1eSyEw3OS/FYS1MfPbSl1zdfp7O13jSr5W+HT 95HGC/ZDqHDF1RMwnCCQoba9ojJZz/XXCLI/f4wjo3jZ1SyadUtvKqUo1CUlBdRFiWgZ WkK7UOAbj5WtBARD3P8wz0VyZS3BOaB/vZR97kgxpFs+varTHRIHLPX58jNodE7PcL7R J4Ff5MdvSJbdfgfGuCPJGypsJv6gQVfLVFImp/dEbHLCSuTpVTOgkoiqi0shnA8x+3dG EEBzYssyiizVqoE8IfG0H/YsPonnU6Wa3I2DfqDY+TD5+nJrqerlrNE5W0mVdpbSXE2T RUJw== X-Gm-Message-State: AOAM533oa4vGTttLDr0FSX/VSOXj/KmjEoGRR+FiL9Y3IlcK+3kSrzFd kXaRmhcPnjuJLt+2MDGwm9k4EnIAszOY0orl501D7g== X-Received: by 2002:a2e:9644:: with SMTP id z4mr12971597ljh.333.1594421675522; Fri, 10 Jul 2020 15:54:35 -0700 (PDT) MIME-Version: 1.0 References: <20200707224604.3737893-4-rajatja@google.com> <20200710202922.GA77140@bjorn-Precision-5520> <20200710212853.GA328472@otc-nc-03> In-Reply-To: <20200710212853.GA328472@otc-nc-03> From: Rajat Jain Date: Fri, 10 Jul 2020 15:53:59 -0700 Message-ID: Subject: Re: [PATCH v4 4/4] PCI/ACS: Enable PCI_ACS_TB for untrusted/external-facing devices To: "Raj, Ashok" Cc: Bjorn Helgaas , David Woodhouse , Lu Baolu , Joerg Roedel , Bjorn Helgaas , "Rafael J. Wysocki" , Len Brown , "open list:AMD IOMMU (AMD-VI)" , Linux Kernel Mailing List , linux-pci , ACPI Devel Maling List , "Krishnakumar, Lalithambika" , 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 , "Oliver O'Halloran" , Saravana Kannan , Suzuki K Poulose , Arnd Bergmann , Heikki Krogerus Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hello, On Fri, Jul 10, 2020 at 2:29 PM Raj, Ashok wrote: > > Hi Bjorn > > > On Fri, Jul 10, 2020 at 03:29:22PM -0500, Bjorn Helgaas wrote: > > On Tue, Jul 07, 2020 at 03:46:04PM -0700, Rajat Jain wrote: > > > When enabling ACS, enable translation blocking for external facing po= rts > > > 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/untruste= d 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 *d= ev) > > > /* Upstream Forwarding */ > > > ctrl |=3D (cap & PCI_ACS_UF); > > > > > > + /* Enable Translation Blocking for external devices */ > > > + if (dev->external_facing || dev->untrusted) { > > > + if (cap & PCI_ACS_TB) > > > + ctrl |=3D PCI_ACS_TB; > > > + else if (dev->external_facing) > > > + pci_warn(dev, "ACS: No Translation Blocking on ex= ternal-facing dev\n"); > > > + } > > > > IIUC, this means that external devices can *never* use ATS > and can > > never cache translations. Yes, but it already exists today (and this patch doesn't change that): 521376741b2c2 "PCI/ATS: Only enable ATS for trusted devices" IMHO any external device trying to send ATS traffic despite having ATS disabled should count as a bad intent. And this patch is trying to plug that loophole, by blocking the AT traffic from devices that we do not expect to see AT from anyway. Do you see any case where this is not true? > And (I guess, I'm not an expert) it can > > also never use the Page Request Services? > > Yep, sounds like it. Yes, from spec "Address Translation Services" Rev 1.1: "...a device that supports ATS need not support PRI, but PRI is dependent on ATS=E2=80=99s capabilities." (So no ATS =3D No PRI). > > > > > 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? > > Sounds like we would need some form of an allow-list to start with so we > can have something in the interim. I assume what is being referred to, is an escape hatch to enable ATS on certain given "external-facing" ports (and devices downstream on that port). Do we really think a *per-port* control for ATS may be needed? I can add if there is consensus about this. > > I suppose a future platform might have a facilty to ensure ATS is secure = and > authenticated we could enable for all of devices in the system, in additi= on > to PCI CMA/IDE. > > I think having a global override to enable all devices so platform can > switch to current behavior, or maybe via a cmdline switch.. as much as we > have a billion of those, it still gives an option in case someone needs i= t. Currently: pci.noats =3D> No ATS on all PCI devices. (Absense of pci.noats): ATS on all PCI devices, EXCEPT external devices. I can look to add another parameter that is synonymous to "trust-external-pci-devices" that can keep ATS enabled on external ports as well. I think this is better than an allow-list of only certain ports, because most likely an admin will trust all its external ports, or not. Also, we can add this global override and may be add a more granular control later, if and when really needed. Thanks, Rajat > > > > > > > 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 |=3D (cap & PCI_ACS_CR); > > > ctrl |=3D (cap & PCI_ACS_UF); > > > > > > + /* Enable Translation Blocking for external devices */ > > > + if (dev->external_facing || dev->untrusted) { > > > + if (cap & PCI_ACS_TB) > > > + ctrl |=3D PCI_ACS_TB; > > > + else if (dev->external_facing) > > > + pci_warn(dev, "ACS: No Translation Blocking on ex= ternal-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 > > >