From: aliguori Date: Wed, 11 Feb 2009 15:21:16 +0000 (+0000) Subject: qemu: warn if PCI region is not power of two (Marcelo Tosatti) X-Git-Tag: release_0_10_0~82 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=a4c20c6a542da310eaa6930c2965845614808809;p=users%2Fdwmw2%2Fqemu.git 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 Signed-off-by: Anthony Liguori git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@6604 c046a42c-6fe2-441c-8c8c-71466251a162 --- diff --git a/hw/pci.c b/hw/pci.c index 5f97afad69..cd07273c83 100644 --- a/hw/pci.c +++ b/hw/pci.c @@ -247,6 +247,13 @@ void pci_register_io_region(PCIDevice *pci_dev, int region_num, if ((unsigned int)region_num >= PCI_NUM_REGIONS) return; + + if (size & (size-1)) { + fprintf(stderr, "ERROR: PCI region size must be pow2 " + "type=0x%x, size=0x%x\n", type, size); + exit(1); + } + r = &pci_dev->io_regions[region_num]; r->addr = -1; r->size = size;