From patchwork Wed Oct 12 04:44:52 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Gibson X-Patchwork-Id: 9372057 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id B1CC3607FD for ; Wed, 12 Oct 2016 04:45:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A95D32094F for ; Wed, 12 Oct 2016 04:45:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9E59B290D3; Wed, 12 Oct 2016 04:45:56 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id CC1BC2094F for ; Wed, 12 Oct 2016 04:45:51 +0000 (UTC) Received: from localhost ([::1]:59194 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1buBQN-0004eu-0C for patchwork-qemu-devel@patchwork.kernel.org; Wed, 12 Oct 2016 00:45:51 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41577) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1buBPh-0004Vg-C7 for qemu-devel@nongnu.org; Wed, 12 Oct 2016 00:45:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1buBPg-0001NW-Eg for qemu-devel@nongnu.org; Wed, 12 Oct 2016 00:45:09 -0400 Received: from ozlabs.org ([2401:3900:2:1::2]:40783) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1buBPf-0001Jj-PW; Wed, 12 Oct 2016 00:45:08 -0400 Received: by ozlabs.org (Postfix, from userid 1007) id 3sv1W511p1z9t0p; Wed, 12 Oct 2016 15:45:04 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1476247505; bh=CxT87Zw/LYrJ4cWak65Pyey6scP6GOpgJlMdLM0m2WI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LZgXRIcxpcIlaohn6muJaIWKUjuoCXezxUOMowv1QZzFmk0eK3dInmWlUsOx9y3yP vN9LO2Oij/XRFhjncKLCrkKgWhJOoWaciP4DGtLCEibqwEL8daIorcPmnhcIDSowS2 EA/4xXzry3KBn/vNYGF7RWWSlh++S7Ls5RWdAauc= From: David Gibson To: lvivier@redhat.com, agraf@suse.de Date: Wed, 12 Oct 2016 15:44:52 +1100 Message-Id: <1476247497-6976-3-git-send-email-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1476247497-6976-1-git-send-email-david@gibson.dropbear.id.au> References: <1476247497-6976-1-git-send-email-david@gibson.dropbear.id.au> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2401:3900:2:1::2 Subject: [Qemu-devel] [PATCHv2 2/7] libqos: Correct error in PCI hole sizing for spapr X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: mst@redhat.com, aik@ozlabs.ru, mdroth@linux.vnet.ibm.com, qemu-devel@nongnu.org, qemu-ppc@nongnu.org, abolonga@redhat.com, David Gibson Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP In pci-spapr.c (as in pci-pc.c from which it was derived), the pci_hole_start/pci_hole_size and pci_iohole_start/pci_iohole_size pairs[1] essentially define the region of PCI (not CPU) addresses in which MMIO or PIO BARs respectively will be allocated. The size value is relative to the start value. But in pci-spapr.c it is set to the entire size of the window supported by the (emulated) hardware, but the start values are *not* at the beginning of the emulated windows. That means if you tried to map enough PCI BARs, we'd messily overrun the IO windows, instead of failing in iomap as we should. This patch corrects this by calculating the hole sizes from the location of the window in PCI space and the hole start. [1] Those are bad names, but that's a problem for another time. Signed-off-by: David Gibson Reviewed-by: Laurent Vivier --- tests/libqos/pci-spapr.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/libqos/pci-spapr.c b/tests/libqos/pci-spapr.c index 1765a54..3192903 100644 --- a/tests/libqos/pci-spapr.c +++ b/tests/libqos/pci-spapr.c @@ -285,11 +285,13 @@ QPCIBus *qpci_init_spapr(QGuestAllocator *alloc) ret->mmio.size = SPAPR_PCI_MMIO_WIN_SIZE; ret->pci_hole_start = 0xC0000000; - ret->pci_hole_size = SPAPR_PCI_MMIO_WIN_SIZE; + ret->pci_hole_size = + ret->mmio.pci_base + ret->mmio.size - ret->pci_hole_start; ret->pci_hole_alloc = 0; ret->pci_iohole_start = 0xc000; - ret->pci_iohole_size = SPAPR_PCI_IO_WIN_SIZE; + ret->pci_iohole_size = + ret->pio.pci_base + ret->pio.size - ret->pci_iohole_start; ret->pci_iohole_alloc = 0; return &ret->bus;