PCI: Scan all functions when running over Jailhouse
Per PCIe r4.0, sec 7.5.1.1.9, multi-function devices are required to have a function 0. Therefore, Linux scans for devices at function 0 (devfn 0/8/16/...) and only scans for other functions if function 0 has its Multi-Function Device bit set or ARI or SR-IOV indicate there are more functions. The Jailhouse hypervisor may pass individual functions of a multi-function device to a guest without passing function 0, which means a Linux guest won't find them. Change Linux PCI probing so it scans all function numbers when running as a guest over Jailhouse. This is technically prohibited by the spec, so it is possible that PCI devices without the Multi-Function Device bit set may have unexpected behavior in response to this probe. Originally-by: Benedikt Spranger <b.spranger@linutronix.de> Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com> Acked-by: Bjorn Helgaas <bhelgaas@google.com> Cc: jailhouse-dev@googlegroups.com Cc: Benedikt Spranger <b.spranger@linutronix.de> Cc: linux-pci@vger.kernel.org Cc: virtualization@lists.linux-foundation.org Link: https://lkml.kernel.org/r/06e279b2a3e06cf6689ab3975f8ab592bba02362.1520408357.git.jan.kiszka@siemens.com
This commit is contained in:

committed by
Thomas Gleixner

parent
63338a38db
commit
690f430410
@@ -4,6 +4,7 @@
|
||||
#include <linux/init.h>
|
||||
#include <linux/export.h>
|
||||
#include <linux/pci.h>
|
||||
#include <asm/jailhouse_para.h>
|
||||
#include <asm/pci_x86.h>
|
||||
|
||||
/*
|
||||
@@ -34,13 +35,14 @@ int __init pci_legacy_init(void)
|
||||
|
||||
void pcibios_scan_specific_bus(int busn)
|
||||
{
|
||||
int stride = jailhouse_paravirt() ? 1 : 8;
|
||||
int devfn;
|
||||
u32 l;
|
||||
|
||||
if (pci_find_bus(0, busn))
|
||||
return;
|
||||
|
||||
for (devfn = 0; devfn < 256; devfn += 8) {
|
||||
for (devfn = 0; devfn < 256; devfn += stride) {
|
||||
if (!raw_pci_read(0, busn, devfn, PCI_VENDOR_ID, 2, &l) &&
|
||||
l != 0x0000 && l != 0xffff) {
|
||||
DBG("Found device at %02x:%02x [%04x]\n", busn, devfn, l);
|
||||
|
Reference in New Issue
Block a user