Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1LWzXA-0003bs-61 for qemu-devel@nongnu.org; Tue, 10 Feb 2009 15:48:44 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1LWzX8-0003aY-1C for qemu-devel@nongnu.org; Tue, 10 Feb 2009 15:48:43 -0500 Received: from [199.232.76.173] (port=52942 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LWzX6-0003ZL-Vh for qemu-devel@nongnu.org; Tue, 10 Feb 2009 15:48:41 -0500 Received: from mx2.redhat.com ([66.187.237.31]:60761) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1LWzX4-0008PI-9h for qemu-devel@nongnu.org; Tue, 10 Feb 2009 15:48:38 -0500 Message-Id: <20090210203207.899779318@emt.localdomain> References: <20090210203051.064692466@emt.localdomain> Date: Tue, 10 Feb 2009 18:31:04 -0200 From: Marcelo Tosatti Content-Disposition: inline; filename=pci-warning-size Subject: [Qemu-devel] [patch 13/19] qemu: warn if PCI region is not power of two Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Anthony Liguori Cc: Marcelo Tosatti , qemu-devel Otherwise the PCI size for such regions can be calculated erroneously. Signed-off-by: Marcelo Tosatti Index: trunk/hw/pci.c =================================================================== --- trunk.orig/hw/pci.c +++ trunk/hw/pci.c @@ -247,6 +247,13 @@ void pci_register_io_region(PCIDevice *p 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; --