From patchwork Fri Apr 9 10:20:48 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Isaku Yamahata X-Patchwork-Id: 49817 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id AAFDBB7CF5 for ; Fri, 9 Apr 2010 20:35:57 +1000 (EST) Received: from localhost ([127.0.0.1]:55020 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1O0BZ4-0002IK-Pu for incoming@patchwork.ozlabs.org; Fri, 09 Apr 2010 06:35:54 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1O0BNB-0005V3-SK for qemu-devel@nongnu.org; Fri, 09 Apr 2010 06:23:37 -0400 Received: from [140.186.70.92] (port=48913 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1O0BN7-0005RG-S4 for qemu-devel@nongnu.org; Fri, 09 Apr 2010 06:23:37 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1O0BN6-0004dd-EO for qemu-devel@nongnu.org; Fri, 09 Apr 2010 06:23:33 -0400 Received: from mail.valinux.co.jp ([210.128.90.3]:35514) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1O0BN6-0004dH-5f for qemu-devel@nongnu.org; Fri, 09 Apr 2010 06:23:32 -0400 Received: from ps.local.valinux.co.jp (vagw.valinux.co.jp [210.128.90.14]) by mail.valinux.co.jp (Postfix) with SMTP id 8A73B18596; Fri, 9 Apr 2010 19:23:29 +0900 (JST) Received: (nullmailer pid 344 invoked by uid 1000); Fri, 09 Apr 2010 10:20:48 -0000 Date: Fri, 9 Apr 2010 19:20:48 +0900 From: Isaku Yamahata To: qemu-devel@nongnu.org Message-ID: <20100409102048.GD14603@valinux.co.jp> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.19 (2009-01-05) X-Virus-Scanned: clamav-milter 0.95.2 at va-mail.local.valinux.co.jp X-Virus-Status: Clean X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) Cc: "Michael S. Tsirkin" Subject: [Qemu-devel] [PATCH] pci: fix pci_find_space() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org pci capability must be in PCI space. It can't lay in PCIe extended config space. Cc: "Michael S. Tsirkin" Signed-off-by: Isaku Yamahata --- hw/pci.c | 3 +-- 1 files changed, 1 insertions(+), 2 deletions(-) diff --git a/hw/pci.c b/hw/pci.c index 2f6907b..f50568c 100644 --- a/hw/pci.c +++ b/hw/pci.c @@ -1701,10 +1701,9 @@ PCIDevice *pci_create_simple(PCIBus *bus, int devfn, const char *name) static int pci_find_space(PCIDevice *pdev, uint8_t size) { - int config_size = pci_config_size(pdev); int offset = PCI_CONFIG_HEADER_SIZE; int i; - for (i = PCI_CONFIG_HEADER_SIZE; i < config_size; ++i) + for (i = PCI_CONFIG_HEADER_SIZE; i < PCI_CONFIG_SPACE_SIZE - size; ++i) if (pdev->used[i]) offset = i + 1; else if (i - offset + 1 == size)