]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
PCI: OF: Support "external-facing" property
authorJean-Philippe Brucker <jean-philippe.brucker@arm.com>
Thu, 11 Apr 2019 12:40:27 +0000 (13:40 +0100)
committerBjorn Helgaas <bhelgaas@google.com>
Thu, 11 Apr 2019 21:17:53 +0000 (16:17 -0500)
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 <jean-philippe.brucker@arm.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
drivers/pci/of.c

index 3d32da15c215d039d4c9b01d830c48460305d1df..67376cf4588019f039a023800af909c53def257c 100644 (file)
@@ -31,10 +31,16 @@ void pci_release_of_node(struct pci_dev *dev)
 
 void pci_set_bus_of_node(struct pci_bus *bus)
 {
-       if (bus->self == NULL)
-               bus->dev.of_node = pcibios_get_phb_of_node(bus);
-       else
-               bus->dev.of_node = of_node_get(bus->self->dev.of_node);
+       struct device_node *node;
+
+       if (bus->self == NULL) {
+               node = pcibios_get_phb_of_node(bus);
+       } else {
+               node = of_node_get(bus->self->dev.of_node);
+               if (node && of_property_read_bool(node, "external-facing"))
+                       bus->self->untrusted = true;
+       }
+       bus->dev.of_node = node;
 }
 
 void pci_release_bus_of_node(struct pci_bus *bus)