Bug 1260913

Summary: [PCIe] Seabios goes into an endless loop when booted with 240 "-device xio3130-downstream"
Product: Red Hat Enterprise Linux 7 Reporter: huiqingding <huding>
Component: seabiosAssignee: Marcel Apfelbaum <marcel>
Status: CLOSED WONTFIX QA Contact: Virtualization Bugs <virt-bugs>
Severity: low Docs Contact:
Priority: low    
Version: 7.2CC: huding, juli, juzhang, knoel, marcel, virt-maint, xfu, yama
Target Milestone: rc   
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard: Won't fix
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2016-01-14 12:05:38 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 1227278    
Attachments:
Description Flags
qemu-kvm command line none

Description huiqingding 2015-09-08 08:26:59 UTC
Description of problem:
can not see seabios GUI when boot with 240 "-device xio3130-downstream" via PCIe-switch.
Also test with 239 "-device xio3130-downstream", not hit this issue.

Version-Release number of selected component (if applicable):
qemu-kvm-rhev-2.3.0-22.el7.x86_64
kernel-3.10.0-313.el7.x86_64
seabios-bin-1.7.5-11.el7.noarch

How reproducible:
100%

Steps to Reproduce:
1. boot guest with 240 "-device xio3130-downstream"
# sh multi-pcie.sh 240
# cat multi-pcie.sh
#!/bin/sh

MACHINE=q35
SMP=4,cores=2,threads=2,sockets=1
MEM=4G
GUEST_IMG=/mnt/rhel7.2.qcow2_bak
IMG_FORMAT=qcow2

CLI="/usr/libexec/qemu-kvm -enable-kvm -M $MACHINE -smp $SMP -m $MEM -name vm1 -drive file=$GUEST_IMG,if=none,id=guest-img,format=$IMG_FORMAT,werror=stop,rerror=stop -device ide-hd,drive=guest-img,bus=ide.0,unit=0,id=os-disk,bootindex=1 -spice port=5932,disable-ticketing -vga qxl  -monitor stdio -qmp tcp:0:6666,server,nowait -boot menu=on -chardev file,path=/home/seabios.log,id=seabios -device isa-debugcon,chardev=seabios,iobase=0x402"

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

2.
3.

Actual results:
Can not see seabios GUI via remoteview spice://$IP:$port
Using isa-debugcon debug, got the following messages:
SeaBIOS (version seabios-1.7.5-11.el7)
Running on QEMU (q35)
Running on KVM
RamSize: 0x80000000 [cmos]
Relocating init from 0x000e3f59 to 0x7ffb1cd0 (size 57960)
Found QEMU fw_cfg
RamBlock: addr 0x0000000000000000 len 0x0000000080000000 [e820]
RamBlock: addr 0x0000000100000000 len 0x0000000080000000 [e820]
Moving pm_base to 0x600
boot order:
1: /pci@i0cf8/pci8086,2922@1f,2/drive@0/disk@0
CPU Mhz=3396
=== PCI bus & bridge init ===
PCI: pci_bios_init_bus_rec bus = 0x0
PCI: pci_bios_init_bus_rec bdf = 0x18
PCI: primary bus = 0x0
PCI: secondary bus = 0xff -> 0x1
PCI: pci_bios_init_bus_rec bus = 0x1
PCI: pci_bios_init_bus_rec bdf = 0x100
PCI: primary bus = 0x0 -> 0x1
PCI: secondary bus = 0xff -> 0x2
PCI: pci_bios_init_bus_rec bus = 0x2
PCI: pci_bios_init_bus_rec bdf = 0x200
PCI: primary bus = 0x0 -> 0x2
PCI: secondary bus = 0xff -> 0x3
PCI: pci_bios_init_bus_rec bus = 0x3
PCI: subordinate bus = 0x0 -> 0x3
PCI: pci_bios_init_bus_rec bdf = 0x208
PCI: primary bus = 0x0 -> 0x2
PCI: secondary bus = 0xff -> 0x4
PCI: pci_bios_init_bus_rec bus = 0x4
PCI: subordinate bus = 0x0 -> 0x4
PCI: pci_bios_init_bus_rec bdf = 0x210
PCI: primary bus = 0x0 -> 0x2
PCI: secondary bus = 0xff -> 0x5
PCI: pci_bios_init_bus_rec bus = 0x5
PCI: subordinate bus = 0x0 -> 0x5
PCI: pci_bios_init_bus_rec bdf = 0x218
PCI: primary bus = 0x0 -> 0x2
PCI: secondary bus = 0xff -> 0x6
PCI: pci_bios_init_bus_rec bus = 0x6
PCI: subordinate bus = 0x0 -> 0x6
PCI: pci_bios_init_bus_rec bdf = 0x220
PCI: primary bus = 0x0 -> 0x2
PCI: secondary bus = 0xff -> 0x7
PCI: pci_bios_init_bus_rec bus = 0x7
PCI: subordinate bus = 0x0 -> 0x7
PCI: pci_bios_init_bus_rec bdf = 0x228
PCI: primary bus = 0x0 -> 0x2
PCI: secondary bus = 0xff -> 0x8
... ...

Expected results:
can see the seabio GUI and boot guest correctly.

Additional info:

Comment 1 huiqingding 2015-09-08 08:28:53 UTC
Created attachment 1071230 [details]
qemu-kvm command line

The command line of Comment #0 is as the attachment file.

Comment 4 Marcel Apfelbaum 2016-01-04 11:58:41 UTC
Hi,

The problem here is that the maximum bus number can be 255.
The mentioned script creates more than 255 buses when the parameter is > 240
and of course the SeaBIOS cannot continue.

Even if, as explained, this is not a bug, SeaBIOS does go into an endless loop which is not nice.
I posted a fix upstream:
     [SeaBIOS] [PATCH] pci: panic when out of bus numbers

Comment 5 Marcel Apfelbaum 2016-01-14 12:05:38 UTC
The patch was rejected by Gerd as being an illegal hardware configuration
and it should not be resolved in firmware, but in QEMU.

After I discussed it with Michael, the QEMU PCI maintainer we decided that we
should not follow this, see comment 4 for details.

Comment 6 Amnon Ilan 2016-02-24 18:25:51 UTC
*** Bug 1055416 has been marked as a duplicate of this bug. ***