@@ -170,7 +170,7 @@ static bool pci_alloc_resource(pcidevaddr_t dev, int bar_num, u64 *addr)
struct pci_host_bridge *host = pci_host_bridge;
struct pci_addr_space *as = &host->addr_space[0];
u32 bar;
- u64 size;
+ u64 size, pci_addr;
int type, i;
*addr = ~0;
@@ -199,8 +199,10 @@ static bool pci_alloc_resource(pcidevaddr_t dev, int bar_num, u64 *addr)
return false;
}
+ pci_addr = ALIGN(as->pci_start + as->allocated, size);
+ size += pci_addr - (as->pci_start + as->allocated);
assert(as->allocated + size <= as->size);
- *addr = as->pci_start + as->allocated;
+ *addr = pci_addr;
as->allocated += size;
return true;
PCI I/O and Memory must be allocated to a device in a naturally aligned way. For example, if a device asks for 0xB0 of PCI I/O space then it must be aligned on an address that is a multiple of 0xB0 (http://www.tldp.org/LDP/tlk/dd/pci.html) Cc: Thomas Huth <thuth@redhat.com> Cc: Andrew Jones <drjones@redhat.com> Reported-by: Andrew Jones <drjones@redhat.com> Signed-off-by: Alexander Gordeev <agordeev@redhat.com> --- lib/pci-host-generic.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)