Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp557796ybt; Mon, 6 Jul 2020 16:31:22 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwuJ1IIkIHolvgBgRr1qkxs0x4kW/YRTbl8eRWEoT9qjxlZUTR04OoScCdm2D7l0ivT8tHP X-Received: by 2002:a17:906:e089:: with SMTP id gh9mr20959599ejb.482.1594078282033; Mon, 06 Jul 2020 16:31:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594078282; cv=none; d=google.com; s=arc-20160816; b=ppqREXsyWiIHOEP9luyZkuMKLpjxeAJ1ZJpo5BzZgxttJnGMNVeiZEki8KpdzjViHl BQXHpsrn11IaFXVnIeTuPyPGaXLdNNYttQ7cLN2elCuriCZghmD98QXv8Vf0vjwJbbdn 9+gc6cw/tAdhCRkDDO28ttYlq7kVBtVyAu7/TYnu6lBAdrYSuiNRyRzTeo2EgkGZ85tT 9wQjaN9+LAq6HCdA9KRh52k1zteCKPG29hpSHynfcvsKqA/ifBwpo7esJnGQR4p6ZRPn /5dwiDDwslIbkDZBjrhBVTkqP0pea+L6uyVZct9r3XKigifrzV1OF5rtS9c9nleqtDV4 /hyg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:message-id:subject:cc:to:from:date:dkim-signature; bh=7g+dQvPS5n0YGc3A4EffHq2mbl1/7iIFFMXuiTqNNC0=; b=COjrMf8niwtoUll7brsQevZRPfeIX/DFKxAhK2ERdGFnKABNQodT1ZdLz5KgOtk0ki NM71JR5tLXwr8d9L4edzimr+sqGGtU5OR/1MPbJQQbp3GDkLlDXXo1S3fAVQXQ6wvuSU 1DBWRFM/QvJg38P4u2AEh+1KBIACCw4iC7slQ4PpmSdjd2og+HsVoVCyZruT0Lrj5AIT c9KVReE4UW4mMo0TCBrUWp0AMrc4qMSjCZqb6Eii+hxrMDq52sblDngz0kr8uim2rX2Z mItvjgXt6b9AEG1aZa33gLCRo5K7kvo3DyZ8kYEpQ2+wXaOzZrT0wXIkwtN9cX44xJJR XtFg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=f4JVsr+F; 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=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a2si16046157edb.243.2020.07.06.16.30.57; Mon, 06 Jul 2020 16:31:22 -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=@kernel.org header.s=default header.b=f4JVsr+F; 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=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727789AbgGFXas (ORCPT + 99 others); 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-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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".