On 01/04/2016 01:43 PM, Marcel Apfelbaum wrote:
Currently the bios goes into an endless loop if more than 255 PCI buses are requested.
Hi,
This is the reproducing script:
cli="<qemu-bin> -M q35 <img>"
while [ ${i:=0} -lt ${1:-0} ] do dstreamId=$((i)) ustreamId=$((dstreamId/32)) chassisId=$((dstreamId+1)) blkDiskId=$((dstreamId))
if [ $((dstreamId%32)) -eq 0 ] then cli="$cli -device ioh3420,bus=pcie.0,id=root.$ustreamId,slot=$ustreamId" cli="$cli -device x3130-upstream,bus=root.$ustreamId,id=upstream$ustreamId" fi
cli="$cli -device xio3130-downstream,bus=upstream$ustreamId,id=downstream$dstreamId,chassis=$chassisId" i=$((i+1)) done
$cli
Run it with a numeric parameter > 240.
Thanks, Marcel
Change that to panic which is preferred in this case.
Signed-off-by: Marcel Apfelbaum marcel@redhat.com
Hi,
I am well aware that this is not a common scenario, but the bug was found and maybe it deserves a little attention.
I opted for using panic because I saw it used for other scenarios where the bios is out of resources.
Another way to look at this would be to *stop* registering buses over 255 and loose some of the devices, but bring the system up.
Thanks, Marcel
src/fw/pciinit.c | 3 +++ 1 file changed, 3 insertions(+)
diff --git a/src/fw/pciinit.c b/src/fw/pciinit.c index c31c2fa..5da6cf6 100644 --- a/src/fw/pciinit.c +++ b/src/fw/pciinit.c @@ -469,6 +469,9 @@ pci_bios_init_bus_rec(int bus, u8 *pci_bus)
u8 secbus = pci_config_readb(bdf, PCI_SECONDARY_BUS); (*pci_bus)++;
if (!(*pci_bus)) {
panic("PCI: out of bus numbers!\n");
} if (*pci_bus != secbus) { dprintf(1, "PCI: secondary bus = 0x%x -> 0x%x\n", secbus, *pci_bus);