From patchwork Thu Oct 3 15:04:43 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 280351 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id E9E6D2C00C6 for ; Fri, 4 Oct 2013 01:04:21 +1000 (EST) Received: from localhost ([::1]:43635 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VRkRv-0004OG-VC for incoming@patchwork.ozlabs.org; Thu, 03 Oct 2013 11:04:19 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45798) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VRkQF-00042m-Iu for qemu-devel@nongnu.org; Thu, 03 Oct 2013 11:02:41 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VRkQ6-0007r7-Vu for qemu-devel@nongnu.org; Thu, 03 Oct 2013 11:02:35 -0400 Received: from mx1.redhat.com ([209.132.183.28]:58914) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VRkQ6-0007qy-Mf for qemu-devel@nongnu.org; Thu, 03 Oct 2013 11:02:26 -0400 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r93F2MDa016086 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Thu, 3 Oct 2013 11:02:23 -0400 Received: from redhat.com (vpn1-5-202.ams2.redhat.com [10.36.5.202]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with SMTP id r93F2K24005917; Thu, 3 Oct 2013 11:02:20 -0400 Date: Thu, 3 Oct 2013 18:04:43 +0300 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org, Anthony Liguori Message-ID: <1380812639-3868-5-git-send-email-mst@redhat.com> References: <1380812639-3868-1-git-send-email-mst@redhat.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <1380812639-3868-1-git-send-email-mst@redhat.com> X-Mutt-Fcc: =sent X-Scanned-By: MIMEDefang 2.67 on 10.5.11.11 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: pbonzini@redhat.com, imammedo@redhat.com, afaerber@suse.de, kraxel@redhat.com Subject: [Qemu-devel] [PATCH v8 04/26] pci: fix up w64 size calculation helper X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org BAR base was calculated incorrectly. Use existing pci_bar_address to get it right. Tested-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 00554a0..c3fdff4 100644 --- a/hw/pci/pci.c +++ b/hw/pci/pci.c @@ -2264,7 +2264,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; @@ -2283,17 +2283,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);