From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jean-Philippe Brucker Subject: [PATCH 2/2] PCI: OF: Support external-facing property Date: Mon, 18 Mar 2019 18:21:24 +0000 Message-ID: <20190318182124.53859-3-jean-philippe.brucker@arm.com> References: <20190318182124.53859-1-jean-philippe.brucker@arm.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <20190318182124.53859-1-jean-philippe.brucker@arm.com> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=m.gmane.org@lists.infradead.org To: bhelgaas@google.com, robh+dt@kernel.org, mark.rutland@arm.com Cc: devicetree@vger.kernel.org, linux-pci@vger.kernel.org, Jeremy.Linton@arm.com, Grant.Likely@arm.com, Robin.Murphy@arm.com, linux-arm-kernel@lists.infradead.org List-Id: devicetree@vger.kernel.org Set the "untrusted" attribute to any PCIe port that has an "external-facing" device tree property. Any device downstream of this port will inherit the attribute and have only the strictest IOMMU protection. Signed-off-by: Jean-Philippe Brucker --- drivers/pci/of.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/pci/of.c b/drivers/pci/of.c index 3d32da15c215..3e7ac7748d90 100644 --- a/drivers/pci/of.c +++ b/drivers/pci/of.c @@ -35,6 +35,9 @@ void pci_set_bus_of_node(struct pci_bus *bus) bus->dev.of_node = pcibios_get_phb_of_node(bus); else bus->dev.of_node = of_node_get(bus->self->dev.of_node); + + if (of_get_property(bus->dev.of_node, "external-facing", NULL)) + bus->self->untrusted = true; } void pci_release_bus_of_node(struct pci_bus *bus) -- 2.21.0 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=-9.0 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_PASS,USER_AGENT_GIT autolearn=ham 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 7275AC43381 for ; Mon, 18 Mar 2019 18:24:47 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 506142133F for ; Mon, 18 Mar 2019 18:24:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726857AbfCRSYq (ORCPT ); Mon, 18 Mar 2019 14:24:46 -0400 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:39506 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726828AbfCRSYq (ORCPT ); Mon, 18 Mar 2019 14:24:46 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 5FFBE1682; Mon, 18 Mar 2019 11:24:46 -0700 (PDT) Received: from ostrya.cambridge.arm.com (ostrya.cambridge.arm.com [10.1.196.129]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id AE3923F614; Mon, 18 Mar 2019 11:24:44 -0700 (PDT) From: Jean-Philippe Brucker To: bhelgaas@google.com, robh+dt@kernel.org, mark.rutland@arm.com Cc: linux-pci@vger.kernel.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Grant.Likely@arm.com, Jeremy.Linton@arm.com, Robin.Murphy@arm.com Subject: [PATCH 2/2] PCI: OF: Support external-facing property Date: Mon, 18 Mar 2019 18:21:24 +0000 Message-Id: <20190318182124.53859-3-jean-philippe.brucker@arm.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190318182124.53859-1-jean-philippe.brucker@arm.com> References: <20190318182124.53859-1-jean-philippe.brucker@arm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org Set the "untrusted" attribute to any PCIe port that has an "external-facing" device tree property. Any device downstream of this port will inherit the attribute and have only the strictest IOMMU protection. Signed-off-by: Jean-Philippe Brucker --- drivers/pci/of.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/pci/of.c b/drivers/pci/of.c index 3d32da15c215..3e7ac7748d90 100644 --- a/drivers/pci/of.c +++ b/drivers/pci/of.c @@ -35,6 +35,9 @@ void pci_set_bus_of_node(struct pci_bus *bus) bus->dev.of_node = pcibios_get_phb_of_node(bus); else bus->dev.of_node = of_node_get(bus->self->dev.of_node); + + if (of_get_property(bus->dev.of_node, "external-facing", NULL)) + bus->self->untrusted = true; } void pci_release_bus_of_node(struct pci_bus *bus) -- 2.21.0 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=-9.0 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham 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 34494C43381 for ; Mon, 18 Mar 2019 18:25:06 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id D8FD720835 for ; Mon, 18 Mar 2019 18:25:05 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="li/fK28j" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D8FD720835 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=arm.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=PMNE9dHPoP4aPd0NRZf2LRQ0pkhPwk/D1hTfQeldS9I=; b=li/fK28jcGyj/3 1d9oARDtlYxGHveFuBTYgaOHe3b8uiW31DT7A1KdslX6dtNceGj/blSJBWEjevWAgQvdOrgu8Dhj+ qBsabmfxZaUE46ZVgOf0ZARH43ED70FHeAYn7hc+eWLe9E/5XeZKSxvXnEkV/GPGgpYKs27E0+d/n zHZT4oqg+R3q4P2D3OqTeDQZZIjO5KeSsS18g+pEOW9/HrVYU4n8eBSq+dsVqv9G+gBaNq/cH6o4U QacaHVoQ819hbHH8N4Yr45KTscgcm01hZuY3mW59Bi5EwBnuekwRhIYBDfHRtT+bp08vpnHGRjuki 9EWj5mU2BpnXsfQ5eU7A==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1h5wwT-0007uz-O1; Mon, 18 Mar 2019 18:24:57 +0000 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70] helo=foss.arm.com) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1h5wwJ-0007jj-L4 for linux-arm-kernel@lists.infradead.org; Mon, 18 Mar 2019 18:24:48 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 5FFBE1682; Mon, 18 Mar 2019 11:24:46 -0700 (PDT) Received: from ostrya.cambridge.arm.com (ostrya.cambridge.arm.com [10.1.196.129]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id AE3923F614; Mon, 18 Mar 2019 11:24:44 -0700 (PDT) From: Jean-Philippe Brucker To: bhelgaas@google.com, robh+dt@kernel.org, mark.rutland@arm.com Subject: [PATCH 2/2] PCI: OF: Support external-facing property Date: Mon, 18 Mar 2019 18:21:24 +0000 Message-Id: <20190318182124.53859-3-jean-philippe.brucker@arm.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190318182124.53859-1-jean-philippe.brucker@arm.com> References: <20190318182124.53859-1-jean-philippe.brucker@arm.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190318_112447_692360_C24506B2 X-CRM114-Status: GOOD ( 10.64 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: devicetree@vger.kernel.org, linux-pci@vger.kernel.org, Jeremy.Linton@arm.com, Grant.Likely@arm.com, Robin.Murphy@arm.com, linux-arm-kernel@lists.infradead.org Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org Set the "untrusted" attribute to any PCIe port that has an "external-facing" device tree property. Any device downstream of this port will inherit the attribute and have only the strictest IOMMU protection. Signed-off-by: Jean-Philippe Brucker --- drivers/pci/of.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/pci/of.c b/drivers/pci/of.c index 3d32da15c215..3e7ac7748d90 100644 --- a/drivers/pci/of.c +++ b/drivers/pci/of.c @@ -35,6 +35,9 @@ void pci_set_bus_of_node(struct pci_bus *bus) bus->dev.of_node = pcibios_get_phb_of_node(bus); else bus->dev.of_node = of_node_get(bus->self->dev.of_node); + + if (of_get_property(bus->dev.of_node, "external-facing", NULL)) + bus->self->untrusted = true; } void pci_release_bus_of_node(struct pci_bus *bus) -- 2.21.0 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel