From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52721) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VVy7U-0000Iv-0c for qemu-devel@nongnu.org; Tue, 15 Oct 2013 02:28:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VVy7O-00057d-04 for qemu-devel@nongnu.org; Tue, 15 Oct 2013 02:28:39 -0400 Received: from mx1.redhat.com ([209.132.183.28]:9152) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VVy7N-00057U-M5 for qemu-devel@nongnu.org; Tue, 15 Oct 2013 02:28:33 -0400 Date: Tue, 15 Oct 2013 09:31:03 +0300 From: "Michael S. Tsirkin" Message-ID: <1381818560-18367-16-git-send-email-mst@redhat.com> References: <1381818560-18367-1-git-send-email-mst@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1381818560-18367-1-git-send-email-mst@redhat.com> Subject: [Qemu-devel] [PULL v2 15/39] pci: fix up w64 size calculation helper List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org, Anthony Liguori Cc: peter.maydell@linaro.org, imammedo@redhat.com, mst@redhat.com, kraxel@redhat.com, marcel.a@redhat.com BAR base was calculated incorrectly. Use existing pci_bar_address to get it right. Tested-by: Igor Mammedov Reviewed-by: Igor Mammedov Signed-off-by: Michael S. Tsirkin --- hw/pci/pci.c | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/hw/pci/pci.c b/hw/pci/pci.c index ae23c58..a98c8a0 100644 --- a/hw/pci/pci.c +++ b/hw/pci/pci.c @@ -2306,7 +2306,7 @@ static void pci_dev_get_w64(PCIBus *b, PCIDevice *dev, void *opaque) Range *range = opaque; PCIDeviceClass *pc = PCI_DEVICE_GET_CLASS(dev); uint16_t cmd = pci_get_word(dev->config + PCI_COMMAND); - int r; + int i; if (!(cmd & PCI_COMMAND_MEMORY)) { return; @@ -2325,17 +2325,21 @@ static void pci_dev_get_w64(PCIBus *b, PCIDevice *dev, void *opaque) range_extend(range, &pref_range); } } - for (r = 0; r < PCI_NUM_REGIONS; ++r) { - PCIIORegion *region = &dev->io_regions[r]; + for (i = 0; i < PCI_NUM_REGIONS; ++i) { + PCIIORegion *r = &dev->io_regions[i]; Range region_range; - if (!region->size || - (region->type & PCI_BASE_ADDRESS_SPACE_IO) || - !(region->type & PCI_BASE_ADDRESS_MEM_TYPE_64)) { + if (!r->size || + (r->type & PCI_BASE_ADDRESS_SPACE_IO) || + !(r->type & PCI_BASE_ADDRESS_MEM_TYPE_64)) { + continue; + } + region_range.begin = pci_bar_address(dev, i, r->type, r->size); + region_range.end = region_range.begin + r->size; + + if (region_range.begin == PCI_BAR_UNMAPPED) { continue; } - region_range.begin = pci_get_quad(dev->config + pci_bar(dev, r)); - region_range.end = region_range.begin + region->size; region_range.begin = MAX(region_range.begin, 0x1ULL << 32); -- MST