Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp53997ybt; Tue, 7 Jul 2020 15:53:19 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy7Nzngmoi8eNqW0ZUmyTJVE4C++R01Nf4rbZ85+U42lu2wL8NHnBZ07k6CMolAUZj/nfq3 X-Received: by 2002:a05:6402:377:: with SMTP id s23mr65072901edw.200.1594162399694; Tue, 07 Jul 2020 15:53:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594162399; cv=none; d=google.com; s=arc-20160816; b=gSL/OEExIUZsZ7ZOLbY9esNNd8Hi//uUeF3axCpNtB4HxTFGa5u0segoLLWY7nwGRA 2tMxCZE9gSQAiPDVGVsNnQ9rZ32zjJLSY/VF4/ALxEFUQmod0sVYavi3HcjDMy+0oVbi vzK/cksdHfSWrpAtF6clTdKY9qtGJduP4yWImaewao0E1lZsp3JCNdVf9nvOV/JWAZsK nBT2MaAVUr4Zaep59aVYRC5mmVyrMuh3ZB9kXF8npEjrx3kMBiNDxFfdZ3B7Oq5SzcuH m7WpqqbHkxxkg5f5BwBT2sp/yABYx5rXLTTfTIhoye/5IamjzHsWu9L2jvpyKeXtM+fg OCTg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:from:subject:references :mime-version:message-id:in-reply-to:date:dkim-signature; bh=n09L38FqLziZB80XiEEa4U3Rbl7E07buKJV52yFHq04=; b=P37w6RG0x1tbschgt/ncpj7iy/koOhQuWX7bZYuKXA7pckR1J/d8QJoh4SnySxZOgJ 8WTWl1B47dIl3GOLR0ElyBpWvyQMUjU8o9SHZyKGvQiRd4lCuXEyyKFxNt3elD+PEaKZ 5i9aoi9pnor0qUWI55kqrvmztPVdVZ6MS0VRbxxsHdYDLu4L/8PuyWXaADo3KuHTuN6i 98NdJlRNucZ6wM7I0qF379QOzszqaO8K/tC5fACO2lrOp9npaql7s1j44M147qqWq4PA XjDiPVgEOilILPOBNbpQ+3IO84UpXjS5qHmd8vksW7TtciBlm2velYXiGUXEUVHb5OQu c8vw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b="Gc/SRTnI"; 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 d18si14263116ejm.684.2020.07.07.15.52.55; Tue, 07 Jul 2020 15:53:19 -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="Gc/SRTnI"; 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 S1729499AbgGGWqP (ORCPT + 99 others); Tue, 7 Jul 2020 18:46:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45136 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729472AbgGGWqN (ORCPT ); Tue, 7 Jul 2020 18:46:13 -0400 Received: from mail-yb1-xb49.google.com (mail-yb1-xb49.google.com [IPv6:2607:f8b0:4864:20::b49]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B22D5C08C5E1 for ; Tue, 7 Jul 2020 15:46:13 -0700 (PDT) Received: by mail-yb1-xb49.google.com with SMTP id j187so12778721ybj.7 for ; Tue, 07 Jul 2020 15:46:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=n09L38FqLziZB80XiEEa4U3Rbl7E07buKJV52yFHq04=; b=Gc/SRTnIxUHoSJi+odkT9ED/cAZBziEF60Mve91fM9ATmPS3FGriWKvJORZEl5Z0i6 Rt1q9Vj5DMEAtIDwvsa0svlN3MYRac1QJf+VBjUzkBJ22HvTQa8Now99YUMjCbAmUArG 5X+9HsquJ7uXVe4Pxn4vmk60HOhkEddPfyOyNrHxPW1zHyAcQIwk3gp0EqwnVfa3GZY4 q4JcOTH38ilJwF+ZrP6i0omqbEBDlm/Qojb6gfUCxgu5Ue6rglL1jV4JOPjCNpS+ODQj hyRyy82rMnXmypFgaIK9L3UolmGvLn5iAPdb1li5GfA7hM9hQC5Y3D/8RLFnLgvk5HSZ pO1w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=n09L38FqLziZB80XiEEa4U3Rbl7E07buKJV52yFHq04=; b=jXRVxbPUrqbuWWtwdPBZE9UqHXajlwT9vUZqvdsUYDeHPY8RKeMiWi0ENDhNu/lkNm Hbn2IONaesXcnVI73jUKpkK0WPp7edth9aq9H12RI5nbE+1E7XKH4Ff3A9vV1MHsWT/9 oEr/26yqHwA/fXWNlCir22H79i04aCicNqSTl5nwwj2vMfC7wvKs+11taQwN6L98NiPp M2eHfLw/UR3S9OiStizF9vWRkkb5B12IljM4bx9uRD5+O825h5EtkATyu64yYVve06PE vPp6cIsfnvuIWOgLb0J6qQkxP54aZFHUlZWIpB6OqCdNR8L+z6YxdD3wiWhyiHRCfifN 5uNQ== X-Gm-Message-State: AOAM5338vPNv5PWXkyIscwIzxcyvpHyCoqzSGQ9EoGN4/j2ZBgzK02rg rW9RErNZfAoVT/mtW1S/ft6VnnNk6S// X-Received: by 2002:a25:8007:: with SMTP id m7mr31698114ybk.60.1594161972909; Tue, 07 Jul 2020 15:46:12 -0700 (PDT) Date: Tue, 7 Jul 2020 15:46:04 -0700 In-Reply-To: <20200707224604.3737893-1-rajatja@google.com> Message-Id: <20200707224604.3737893-4-rajatja@google.com> Mime-Version: 1.0 References: <20200707224604.3737893-1-rajatja@google.com> X-Mailer: git-send-email 2.27.0.383.g050319c2ae-goog Subject: [PATCH v4 4/4] PCI/ACS: Enable PCI_ACS_TB for untrusted/external-facing devices From: Rajat Jain To: 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 Cc: Rajat Jain 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 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"); + } + 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