aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWill Deacon <will.deacon@arm.com>2014-02-04 16:53:54 +0000
committerWill Deacon <will.deacon@arm.com>2015-06-01 16:39:55 +0100
commitc7575d177ba573e0e3e92e015adfdd00c7032145 (patch)
tree431456d15f0bfe89ccb46d4e31ee78e6dade1770
parentb403f2f7f7c1b85752e2d2bcf29bed358b024626 (diff)
downloadkvmtool-c7575d177ba573e0e3e92e015adfdd00c7032145.tar.gz
kvm tools: pci: ensure BARs are naturally aligned
BARs must be naturally aligned, so enforce this in the PCI IO space allocator. Signed-off-by: Will Deacon <will.deacon@arm.com> Signed-off-by: Pekka Enberg <penberg@kernel.org>
-rw-r--r--pci.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/pci.c b/pci.c
index e735352e..c4442c85 100644
--- a/pci.c
+++ b/pci.c
@@ -18,11 +18,13 @@ static union pci_config_address pci_config_address;
*/
static u32 io_space_blocks = KVM_PCI_MMIO_AREA;
+/*
+ * BARs must be naturally aligned, so enforce this in the allocator.
+ */
u32 pci_get_io_space_block(u32 size)
{
- u32 block = io_space_blocks;
- io_space_blocks += size;
-
+ u32 block = ALIGN(io_space_blocks, size);
+ io_space_blocks = block + size;
return block;
}