diff mbox

[06/17] kvm tools: pci: ensure BARs are naturally aligned

Message ID 1391532812-2043-7-git-send-email-will.deacon@arm.com (mailing list archive)
State New, archived
Headers show

Commit Message

Will Deacon Feb. 4, 2014, 4:53 p.m. UTC
BARs must be naturally aligned, so enforce this in the PCI IO space
allocator.

Signed-off-by: Will Deacon <will.deacon@arm.com>
---
 tools/kvm/pci.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
diff mbox

Patch

diff --git a/tools/kvm/pci.c b/tools/kvm/pci.c
index e735352eb042..c4442c85b5cf 100644
--- a/tools/kvm/pci.c
+++ b/tools/kvm/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;
 }