From: Laszlo Ersek Date: Mon, 23 Feb 2015 16:03:46 +0000 (+0000) Subject: ArmVirtualizationPkg/PciHostBridgeDxe: allocate IO BARs top-down X-Git-Tag: edk2-stable201903~10262 X-Git-Url: https://git.proxmox.com/?a=commitdiff_plain;h=ef8dba7da3bb9bef067d553a0ac53e216e085daf;p=mirror_edk2.git ArmVirtualizationPkg/PciHostBridgeDxe: allocate IO BARs top-down Currently we allocate IO BARs bottom-up in the EfiPciHostBridgeAllocateResources phase of the enumeration. > GCD:AddIoSpace(Base=0000000000000000,Length=0000000000010000) > GcdIoType = I/O > Status = Success > GCDIoType Range > ========== ================================= > I/O 0000000000000000-000000000000FFFF Because the IO aperture is based at zero, the first allocation happens to get the zero address. However, a zero address for a PCI BAR is considered unmapped; see eg.: - , - the (new_addr == 0) part in QEMU, pci_bar_address() [hw/pci/pci.c]: new_addr = pci_get_long(d->config + bar) & ~(size - 1); last_addr = new_addr + size - 1; /* Check if 32 bit BAR wraps around explicitly. * TODO: make priorities correct and remove this work around. */ if (last_addr <= new_addr || new_addr == 0 || last_addr >= UINT32_MAX) { return PCI_BAR_UNMAPPED; } We can avoid this problem by allocating top-down in the IO aperture. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Laszlo Ersek Reviewed-by: Olivier Martin git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@16905 6f19259b-4bc3-4df7-8a09-765794883524 --- diff --git a/ArmPlatformPkg/ArmVirtualizationPkg/PciHostBridgeDxe/PciHostBridge.c b/ArmPlatformPkg/ArmVirtualizationPkg/PciHostBridgeDxe/PciHostBridge.c index 17d4db85be..78c12d0009 100644 --- a/ArmPlatformPkg/ArmVirtualizationPkg/PciHostBridgeDxe/PciHostBridge.c +++ b/ArmPlatformPkg/ArmVirtualizationPkg/PciHostBridgeDxe/PciHostBridge.c @@ -389,8 +389,9 @@ NotifyPhase( BitsOfAlignment = 0; } + BaseAddress = mResAperture[0][0].IoLimit; Status = gDS->AllocateIoSpace ( - EfiGcdAllocateAnySearchBottomUp, + EfiGcdAllocateMaxAddressSearchTopDown, EfiGcdIoTypeIo, BitsOfAlignment, AddrLen,