Received: by 2002:a4f:b056:0:0:0:0:0 with SMTP id m22csp2663092ivi; Tue, 15 Sep 2020 16:03:35 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzO/ZPrto06UYWaIAPzpunnlEpblKS0ImF+ejztV026vXYuqJ2yzcZoz6/OB55NchrYS8oW X-Received: by 2002:a17:906:d9c3:: with SMTP id qk3mr10602940ejb.207.1600211015619; Tue, 15 Sep 2020 16:03:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600211015; cv=none; d=google.com; s=arc-20160816; b=u5MmO+bJy01r1OESKtI1ZYgvfjwHI/XGIyakabYM3cllx6Jpp21FpZSF/7bmZCacTk KP9Q54g826nbmr64/HjXZS0jFcbUwy6JTLYH1OUeV9NCtCggu7ZwMBVt8jA3aMO5C/ju R9CZNxGmMp7MGGvQZdqO4SNgwf+iPgmsEgj3lGH4QUh8eP7myImO0/jafq0+SEDCaJ71 JkDprkOI6zMDyQBC2k+O/JY5TheOqCVHWKsRoAESiz4e5kZr6o5kBz41rIsgJ7Y7mgiE FEijYsZFpU5iFEFIqaWMCmELWOrro+p6jhcS2H7UmTp01mgtAcygND0ENAQaVFI5WEoj WGZQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=/9scBHPNix+y6Pwr8cQyVX+xDYS3UrPPXINpHzBknN4=; b=gl+tiaNJR7itQDSal2/5FTtgRs7go9ZJzzNdtFqA1uTozY9DYd3zfjPin5sPygyH9K l2nyF96z5WrgnCAPcClovzNiRwoKhqfcWYb3nNS6Ts1Ac9QJb2bJXSF6ukzLCh/o3221 GCl2WCjiMZpb0E1f5BN43ExCuoK4HA5MuN6YnfgEdUK4WB7qhAwCAL9BMJxdLBbQOD2M WLgsfHTnclE9C3wUrXE37gizONkpKhvWSl+AiRewPqdcRLIadFT92tqKJ5iJBmICu1fZ D9n0BWZ6l4rin+SUb/T09MxpEp3K8Y9a4gQbXQZ8BeN7kRNhZFCRWdZoJTIJnt2577p+ 2wyw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=ZVyYyQFG; 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 i11si12083990edl.230.2020.09.15.16.03.13; Tue, 15 Sep 2020 16:03:35 -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=ZVyYyQFG; 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 S1727333AbgIOXCn (ORCPT + 99 others); Tue, 15 Sep 2020 19:02:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58138 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727367AbgIOXCY (ORCPT ); Tue, 15 Sep 2020 19:02:24 -0400 Received: from mail-lj1-x244.google.com (mail-lj1-x244.google.com [IPv6:2a00:1450:4864:20::244]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B1E9CC06174A for ; Tue, 15 Sep 2020 16:02:23 -0700 (PDT) Received: by mail-lj1-x244.google.com with SMTP id w3so4268183ljo.5 for ; Tue, 15 Sep 2020 16:02:23 -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; bh=/9scBHPNix+y6Pwr8cQyVX+xDYS3UrPPXINpHzBknN4=; b=ZVyYyQFG1iBiLFuKDDQuAPmiBZLpB11LhmJ8YIOtjnryLAEf3A4zUrMoifNnYRWJlf 8GcDcZvPM6I43fh/hfWt5Ij4L0sml+BEcbwcrw9YG7Yv4MCF4a3iTKVN2+zx/6t1Ok/U EztiiWABfLBG0/pmN5Vl7Cj2fE6WIAdiGdue7cOiCXYCIRSnnNjhvCG039/GlTc80TRj aqwQ3MOyvtANK7SvVzqwtpY0bPLrbyc56t1ojaXcJdWtPVCALRtamlRtUIQUeZZ3HY8z BDvzFgB0IjGoamrNzKeAtkR8T1BKPA8B09P9hDpTiuNjtQyYdb12iJHIbtSbTSRWvjFY sX3A== 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; bh=/9scBHPNix+y6Pwr8cQyVX+xDYS3UrPPXINpHzBknN4=; b=LNlwi66esAC5tY5dCBmO/KQTCSoU6evVtRLW0wdFtqf5jLzoQ6lvsRA0f3zMQCHMFe EpLTb6uteT/nZr7m5hn82eXB8xc0qIkxt47EfMXb9Rkd2t94A4p1Lxhfe8UX6CQNTSn0 u7wq3xmkFihnFieIwm6F8+eCKE3vx0vvc31TerlkBoTclTMnybehu1iQPp5UIvdkXZx3 KeNmejyC7LNBYMgGVvKHoF8o/LK1ebftBJQLkCrK5tqfhgCjgAnWMtSSaWWDkKLaISrh QZczPgWOe84PN3dbAujQDPWbPuH2O1SKB5qrOKeibeEzJ1OM6sV8Qi4xsUaVKb1mkeZY p9mg== X-Gm-Message-State: AOAM531TnERA8KjeIOluirY2jl3qcntUBBD6e4fm6ILdYF+mdPMsGvoz 42Rs2+lbZ+M1nffwaDqbe266Z5EKzW18rsTxm+fViQ== X-Received: by 2002:a2e:9992:: with SMTP id w18mr7963973lji.301.1600210941914; Tue, 15 Sep 2020 16:02:21 -0700 (PDT) MIME-Version: 1.0 References: <20200711195346.GA132330@bjorn-Precision-5520> In-Reply-To: From: Rajat Jain Date: Tue, 15 Sep 2020 16:01:45 -0700 Message-ID: Subject: Re: [PATCH v4 4/4] PCI/ACS: Enable PCI_ACS_TB for untrusted/external-facing devices To: Bjorn Helgaas Cc: "Raj, Ashok" , 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" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hello Bjorn, On Tue, Jul 14, 2020 at 1:19 PM Rajat Jain wrote: > > On Sat, Jul 11, 2020 at 12:53 PM Bjorn Helgaas wrote: > > > > On Fri, Jul 10, 2020 at 03:53:59PM -0700, Rajat Jain wrote: > > > On Fri, Jul 10, 2020 at 2:29 PM Raj, Ashok wrote: > > > > 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 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. > > > > > > 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. > > > > Thinking about this some more, I wonder if Linux should: > > > > - Explicitly disable ATS for every device at enumeration-time, e.g., > > in pci_init_capabilities(), > > > > - Enable PCI_ACS_TB for every device (not just external-facing or > > untrusted ones), > > > > - Disable PCI_ACS_TB for the relevant devices along the path only > > when enabling ATS. > > > > One nice thing about doing that is that the "untrusted" test would be > > only in pci_enable_ats(), and we wouldn't need one in > > pci_std_enable_acs(). > > Sent out v5 with this approach here: > https://patchwork.kernel.org/patch/11663515/ Any feedback on the patch above? It has been waiting for feedback.... Thanks & Best Regards,, Rajat > > Thanks, > > Rajat > > > > > > > It's possible BIOS gives us devices with ATS enabled, and this might > > break them, but that seems like something we'd want to find out about. > > > > Bjorn