Commit a4c20c6a542da310eaa6930c2965845614808809

Authored by aliguori
1 parent 5851e08c

qemu: warn if PCI region is not power of two (Marcelo Tosatti)

Otherwise the PCI size for such regions can be calculated erroneously.

Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>


git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@6604 c046a42c-6fe2-441c-8c8c-71466251a162
Showing 1 changed file with 7 additions and 0 deletions
hw/pci.c
... ... @@ -247,6 +247,13 @@ void pci_register_io_region(PCIDevice *pci_dev, int region_num,
247 247  
248 248 if ((unsigned int)region_num >= PCI_NUM_REGIONS)
249 249 return;
  250 +
  251 + if (size & (size-1)) {
  252 + fprintf(stderr, "ERROR: PCI region size must be pow2 "
  253 + "type=0x%x, size=0x%x\n", type, size);
  254 + exit(1);
  255 + }
  256 +
250 257 r = &pci_dev->io_regions[region_num];
251 258 r->addr = -1;
252 259 r->size = size;
... ...