Bug 1310446

Summary: PCI: BARs collision after resource re-balancing on Windows guests
Product: Red Hat Enterprise Linux 7 Reporter: Marcel Apfelbaum <marcel>
Component: qemu-kvm-rhevAssignee: Marcel Apfelbaum <marcel>
Status: CLOSED WONTFIX QA Contact: FuXiangChun <xfu>
Severity: low Docs Contact:
Priority: low    
Version: 7.3CC: ailan, chayang, imammedo, juzhang, kraxel, michen, mst, virt-maint, xfu
Target Milestone: rc   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2018-04-23 14:27:03 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:

Description Marcel Apfelbaum 2016-02-21 16:20:40 UTC
Description of problem:
If a PCI device has no driver install on a Windows guest, it will not
be part of resource re-balancing algorithm if triggered.
If the device has some BARs , the firmware already assigned to them a resource range. This is not seen by Windows and on resource re-balancing the same range
can be assigned to other PCI device.

Version-Release number of selected component (if applicable):


How reproducible:
100%

Steps to Reproduce:
#cat > t << EOF
pci_update_mappings_del
pci_update_mappings_add
EOF

#./x86_64-softmmu/qemu-system-x86_64 -snapshot -enable-kvm -snapshot \
   -monitor unix:/tmp/m,server,nowait -device pci-bridge,chassis_nr=1 \
   -boot menu=on -m 4G -trace events=t ws2012r2x64dc.img \
   -device ivshmem,id=foo,size=2M,shm,bus=pci.1,addr=01

wait till OS boots, note BARs programmed for ivshmem
   in my case it was
     01:01.0 0,0xfe800000+0x100
then execute script and watch pci_update_mappings* trace events

# for i in $(seq 3 18); do printf -- "device_add e1000,bus=pci.1,addr=%x\n" $i | nc -U /tmp/m; sleep 5; done;


Actual results:
hotplugging e1000,bus=pci.1,addr=12 triggers rebalancing where
Windows unmaps all BARs of nics on bridge but doesn't touch ivshmem
and then programs new BARs, where:
    pci_update_mappings_add d=0x7fa02ff0cf90 01:11.0 0,0xfe800000+0x20000
creates overlapping BAR with ivshmem 


Expected results:
no overlapping BARs or the ivshmem BAR should be disabled.

Comment 1 Marcel Apfelbaum 2016-03-01 12:03:43 UTC
Work plan:
QEMU

Comment 2 Marcel Apfelbaum 2016-03-01 12:06:34 UTC
Work plan:
 - QEMU: implement PNP CMOS flag
 - SeaBIOS: If OS supports PNP -> enable BARs only for bootable devices.