In OVMF PCI I/O space address distribution , according to the OvmfPkg/Library/PlatformInitLib/Platform.c 
VOID
EFIAPI
PlatformMemMapInitialization (
  IN OUT EFI_HOB_PLATFORM_INFO  *PlatformInfoHob
  )
{
  UINT64  PciIoBase;
  UINT64  PciIoSize;
  UINT64  PciExBarBase;
  UINT32  PciBase;
  UINT32  PciSize;

  PciIoBase = 0xC000;
  PciIoSize = 0x4000;
 
The PciIoBase and PciIoSize determine the I/O address space spare for PCI devices. In Ovmf, the two variables are fixed. The PciIoBase = 0xC000 and the PciIoSize = 0x4000 , which means the I/O space for PCI devices is 0x4000. In some circumstances, for example, when I attach many devices to the virtual machine , the 0x4000 is not enough. When I attach 8 PCI bridges and 100 netcards and 100 virtio disks, many devices are unusable. The I/O address of these devices become all 1, just as the following picture shows:
 
  I compared the ovmf with seaBIOS and found that the virtual machine using seaBIOS can work properly. I looked into the I/O space  distribution implement of seaBIOS and found that in qemu\roms\seabios\src\fw\pciinit.c, it says :
    /*
     * QEMU I/O address space usage:
     *   0000 - 0fff    legacy isa, pci config, pci root bus, ...
     *   1000 - 9fff    free
     *   a000 - afff    hotplug (cpu, pci via acpi, i440fx/piix only)
     *   b000 - bfff    power management (PORT_ACPI_PM_BASE)
     *                  [ qemu 1.4+ implements pci config registers
     *                    properly so guests can place the registers
     *                    where they want, on older versions its fixed ]
     *   c000 - ffff    free, traditionally used for pci io
     */
It seems that the 0x1000-0x9fff space can be used for PCI I/O space. In the seaBIOS, it calculates the total I/O space usage by PCI devices, if the total usage exceeds 0x4000, it use 0x1000-0x9fff for PCI I/O space, otherwise it uses 0xC000-0xFFFF:
    struct pci_region *r_io = &bus->r[PCI_REGION_TYPE_IO];
    u64 sum = pci_region_sum(r_io);
    if (sum < 0x4000) {
        /* traditional region is big enougth, use it */
        r_io->base = 0xc000;
    } else if (sum < pci_io_low_end - 0x1000) {
        /* use the larger region at 0x1000 */
        r_io->base = 0x1000;
    } else {
        /* not enouth io address space -> error out */
        return -1;
    }
 
  Due to the different implement of OVMF and seaBIOS, the OVMF can not know how much PCI I/O space all the devices use. So I am wondering that is it proper to change the default PCI I/O space to 0x1000-0x9FFF to fit more devices (for example , 100 netcards and 100 virtio disks).  In that case, the PciIoBase =0x1000 and PciIoSize = 0x9000.
  I am hoping that I can get a reply. Thank for you help.
 
_._,_._,_

Groups.io Links:

You receive all messages sent to this group.

View/Reply Online (#121027) | | Mute This Topic | New Topic
Your Subscription | Contact Group Owner | Unsubscribe [rebecca@openfw.io]

_._,_._,_