提交 38ea72bd 编写于 作者: A Alex Williamson 提交者: Bjorn Helgaas

PCI/MSI: Fix MSI IRQ domains for VFs on virtual buses

SR-IOV creates a virtual bus where bus->self is NULL.  When we add VFs and
scan for an MSI domain, pci_set_bus_msi_domain() dereferences bus->self,
which causes a kernel NULL pointer dereference oops.

Scan up to the parent bus until we find a real bridge where we can get the
MSI domain.

[bhelgaas: changelog]
Fixes: 44aa0c65 ("PCI/MSI: Add hooks to populate the msi_domain field")
Tested-by: NJoerg Roedel <joro@8bytes.org>
Signed-off-by: NAlex Williamson <alex.williamson@redhat.com>
Signed-off-by: NBjorn Helgaas <helgaas@kernel.org>
Acked-by: NMarc Zyngier <marc.zyngier@arm.com>
上级 b838b39e
...@@ -676,15 +676,20 @@ static struct irq_domain *pci_host_bridge_msi_domain(struct pci_bus *bus) ...@@ -676,15 +676,20 @@ static struct irq_domain *pci_host_bridge_msi_domain(struct pci_bus *bus)
static void pci_set_bus_msi_domain(struct pci_bus *bus) static void pci_set_bus_msi_domain(struct pci_bus *bus)
{ {
struct irq_domain *d; struct irq_domain *d;
struct pci_bus *b;
/* /*
* Either bus is the root, and we must obtain it from the * The bus can be a root bus, a subordinate bus, or a virtual bus
* firmware, or we inherit it from the bridge device. * created by an SR-IOV device. Walk up to the first bridge device
* found or derive the domain from the host bridge.
*/ */
if (pci_is_root_bus(bus)) for (b = bus, d = NULL; !d && !pci_is_root_bus(b); b = b->parent) {
d = pci_host_bridge_msi_domain(bus); if (b->self)
else d = dev_get_msi_domain(&b->self->dev);
d = dev_get_msi_domain(&bus->self->dev); }
if (!d)
d = pci_host_bridge_msi_domain(b);
dev_set_msi_domain(&bus->dev, d); dev_set_msi_domain(&bus->dev, d);
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册