Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp563215ybt; Mon, 6 Jul 2020 16:42:06 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwInmZwIrJlxViGp2Zix/EOWgQrICz76PLhOCbbP9xcFuPjC+2l62ydgezsRTs0dkVl6WEe X-Received: by 2002:a05:6402:1250:: with SMTP id l16mr59670103edw.362.1594078926045; Mon, 06 Jul 2020 16:42:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594078926; cv=none; d=google.com; s=arc-20160816; b=Tr0Bj3nANncatxVfRd1xrHSXOtClIXgKT6dBoYFUa/HB+aMkY0qzBBngyjpf6QzhkG UADmTQ9IlfBWt+FCsbbLiN8yujJbLbOMAE0gxkCyxVsgHwF/9fwXix7XbeOuBEIoYVwx nU8JFJZ10rAy35g0QHQ1IUqQEiGug74CY9HwbIk6alaApWpn6+JaLcl92AKIdgbPrw86 kzCwcZZaDbD776HNc1B9JquKwxObHQtlX6GBfHAI2yKl+EXBsq2HhlX8QIfdQL5a3Uxk oYL3qNo22ZPJLq24Y+0RRPmgXozBID1mPXse4y0AGJ8RiykhoPv9YvtMHdeoHrplGCC/ PdmQ== 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=Qj0obXfHw+PyCzXxfPBrAWthmmsaPQNxN4o0aIsqBxY=; b=fW2hH5Qz2M/NgyP2FlYh8hD6TQpC9Pqy3kvbj9xKq8ekKc2kJar93sypVnP9wG7Z1d kKw1gFrbEO78RBlJGIbgHvPzOSmhzuY6MUyJQR5nJ3H32oIEUdgs7i6u1BFo/bOPoUae e0DI48XXUk8vw7WSQpA09xlAi9QO8AZNxI89LelzxQoTEyXplFt0SlD0/U862A7oe9iF 5NwfJgyXDOb1bNc8ybYXIHq9R36SpPgsYV2XvvVb/4mPXd+WPwCTSnJAM4WM72BM1pLj 2BaR+nIoIs8CSpAbuR+YsY9zUnatqcXWbZJ6+QFoj1nqyzTUrp7lQw2ieLJP5jZu2J7x yz5A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=e4ZoJPfJ; 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 g9si13884886ejj.380.2020.07.06.16.41.42; Mon, 06 Jul 2020 16:42:06 -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=e4ZoJPfJ; 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 S1727120AbgGFXlT (ORCPT + 99 others); Mon, 6 Jul 2020 19:41:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56656 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726366AbgGFXlT (ORCPT ); Mon, 6 Jul 2020 19:41:19 -0400 Received: from mail-lj1-x242.google.com (mail-lj1-x242.google.com [IPv6:2a00:1450:4864:20::242]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A79ABC061794 for ; Mon, 6 Jul 2020 16:41:18 -0700 (PDT) Received: by mail-lj1-x242.google.com with SMTP id q7so34465157ljm.1 for ; Mon, 06 Jul 2020 16:41:18 -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=Qj0obXfHw+PyCzXxfPBrAWthmmsaPQNxN4o0aIsqBxY=; b=e4ZoJPfJCzUv6JiW/ZtKDNwoYQa+BkxY90CNz+S6LE9+7RRt6w4/OAJaTtKXSYhbbF oYS0eHWn6OMcxWzbDErcbfbew+X7a6zOBBM6D7f3BIbOaa3bo7kz7TEWGRTKU+1SMROJ Uwh+5IvhJYVUsrx3MhOx+3bLdeW7f6pDZsALQBMQiwWMlGokj2qDJ33L/f/aRPXd/Yec r7GUTyQDIUkMC7W5jzQUw97nbmg4R/8kNhWAmD/VgGQab7U+hMRgK/zmuD6xQSw28Ovt /77UzmwH9JzQPTeu0U2tUJjGo+FYeTGxCf8Ec8gnCy1loG1SpwudA757MIn0qLMe6X2I O63w== 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=Qj0obXfHw+PyCzXxfPBrAWthmmsaPQNxN4o0aIsqBxY=; b=WS34xXlsmbkoRybZvXkLs/tvUMX82I/+zmc6vUw5jNoTkk8j9//ND8F/w8pNNMMxQP OSQz5/x0aUmLNQnxKqc5a54g57gmQhK8P6wNQdzLKHw3D/xacDpWAzNmauyTGoS7OMhp vk4C4oLFD1ixMcU84a6rICxZkiHu+jp60lsOf4VKgC/5cHCUIH3Nm7DZvQ3lW5Jybhni +tAJJmcgonAYhgCxuG56jF05BbGsZpEgOHYnO4pz7DOV5mxKSuvKZuEs/lQad6gU/BZO JEmr1VoMO42r624g3QbL/jq9lAXrPJYV7coYgA2PqbW7YnYbDHOCFQmdEoQFD1Dml9Fi Fxng== X-Gm-Message-State: AOAM533E6yf7qg/eyD4XpSS5fJtzbRBZgPwnu/1K6UBgJWn5n+W0ECW/ feYr04O049oVTwLqvApnjqQjOgjXUnCDoEjwDvjn6A== X-Received: by 2002:a2e:858e:: with SMTP id b14mr30029014lji.301.1594078876784; Mon, 06 Jul 2020 16:41:16 -0700 (PDT) MIME-Version: 1.0 References: <20200706233040.GA169334@bjorn-Precision-5520> In-Reply-To: <20200706233040.GA169334@bjorn-Precision-5520> From: Rajat Jain Date: Mon, 6 Jul 2020 16:40:40 -0700 Message-ID: Subject: Re: [PATCH v2 2/7] PCI: Set "untrusted" flag for truly external devices only To: Bjorn Helgaas Cc: 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 , Raj Ashok , "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 Mon, Jul 6, 2020 at 4:30 PM Bjorn Helgaas wrote: > > On Mon, Jul 06, 2020 at 03:31:47PM -0700, Rajat Jain wrote: > > On Mon, Jul 6, 2020 at 9:38 AM Bjorn Helgaas wrote: > > > On Mon, Jun 29, 2020 at 09:49:38PM -0700, Rajat Jain wrote: > > > > > -static void pci_acpi_set_untrusted(struct pci_dev *dev) > > > > +static void pci_acpi_set_external_facing(struct pci_dev *dev) > > > > { > > > > u8 val; > > > > > > > > - if (pci_pcie_type(dev) != PCI_EXP_TYPE_ROOT_PORT) > > > > + if (pci_pcie_type(dev) != PCI_EXP_TYPE_ROOT_PORT && > > > > + pci_pcie_type(dev) != PCI_EXP_TYPE_DOWNSTREAM) > > > > > > This looks like a change worthy of its own patch. We used to look for > > > "ExternalFacingPort" only on Root Ports; now we'll also do it for > > > Switch Downstream Ports. > > > > Can do. (please see below) > > > > > Can you include DT and ACPI spec references if they exist? I found > > > this mention: > > > https://docs.microsoft.com/en-us/windows-hardware/drivers/pci/dsd-for-pcie-root-ports > > > which actually says it should only be implemented for Root Ports. > > > > I actually have no references. It seems to me that the microsoft spec > > assumes that all external ports must be implemented on root ports, but > > I think it would be equally fair for systems with PCIe switches to > > implement one on one of their switch downstream ports. I don't have an > > immediate use of this anyway, so if you think this should rather wait > > unless someone really has this case, this can wait. Let me know. > > I agree that it "makes sense" to pay attention to this property no > matter where it appears, but since that Microsoft doc went to the > trouble to restrict it to Root Ports, I think we should leave this > as-is and only look for it in the Root Port. Otherwise Linux will > accept something Windows will reject, and that seems like a needless > difference. > > We can at least include the above link to the Microsoft doc in the > commit log. Will do. > > > > It also mentions a "DmaProperty" that looks related. Maybe Linux > > > should also pay attention to this? > > > > Interesting. Since this is not in use currently by the kernel as well > > as not exposed by (our) BIOS, I don't have an immediate use case for > > this. I'd like to defer this for later (as-the-need-arises). > > I agree, you can defer this until you see a need for it. I just > pointed it out in case it would be useful to you. > > > > > + /* > > > > + * Devices are marked as external-facing using info from platform > > > > + * (ACPI / devicetree). An external-facing device is still an internal > > > > + * trusted device, but it faces external untrusted devices. Thus any > > > > + * devices enumerated downstream an external-facing device is marked > > > > + * as untrusted. > > > > > > This comment has a subject/verb agreement problem. > > > > I assume you meant s/is/are/ in last sentence. Will do. > > Right. There's also something wrong with "enumerated downstream an". I'm apparently really bad at English :-). This is what I have in my latest patch I am about to send out: "Thus any device enumerated downstream an external-facing device, is marked as untrusted." Are you suggesting s/an/a/ ? Please let me know what you would like to see and I'd copy it as-is :-) Thanks! Rajat