From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.1 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 95C76C433DF for ; Mon, 6 Jul 2020 23:30:52 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 72EDE206E9 for ; Mon, 6 Jul 2020 23:30:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1594078252; bh=f2hh0GUopLuKkcXDVWTmfciWI/Nf4mF/htzG+HH8RNU=; h=Date:From:To:Cc:Subject:In-Reply-To:List-ID:From; b=s333+Eo/4JH8sqFAp9PPUFXsB5KDbdwL2f4sCrNDgkZ1NCfJ9e4mXHxyuB6r0BizC KN4xumjTrcLvhcpRjD/2gY+s19Zb4+q/ftH/w1qtydtufBQjisj2Nb1qhnF+m/EGvM FmZT3SQvadmgdB6DVebYeZ8Pw/1ZzVWz9WoNv+kw= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727120AbgGFXas (ORCPT ); Mon, 6 Jul 2020 19:30:48 -0400 Received: from mail.kernel.org ([198.145.29.99]:35170 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726883AbgGFXas (ORCPT ); Mon, 6 Jul 2020 19:30:48 -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 1A937206DF; Mon, 6 Jul 2020 23:30:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1594078247; bh=f2hh0GUopLuKkcXDVWTmfciWI/Nf4mF/htzG+HH8RNU=; h=Date:From:To:Cc:Subject:In-Reply-To:From; b=f4JVsr+FBnvTXG/UGYU+BhWL5/GxgtIyQWiYhUmKhQntGNfdpLXH2OTsU18T84J6J rozvcMTQ33o4xawcau+dKYIVeXMZClT4LHt5FI2a32iIOtwL6UZQqex47R6nyu3Xiu 74ZKhPMc9knrbc6jjicKTbDTibtxKc9O39VOPWKg= Date: Mon, 6 Jul 2020 18:30:40 -0500 From: Bjorn Helgaas To: Rajat Jain 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 Subject: Re: [PATCH v2 2/7] PCI: Set "untrusted" flag for truly external devices only Message-ID: <20200706233040.GA169334@bjorn-Precision-5520> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org 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. > > 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".