From patchwork Tue Dec 15 12:58:53 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 67613 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id nBFD29sM024672 for ; Tue, 15 Dec 2009 13:02:09 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1759287AbZLONBl (ORCPT ); Tue, 15 Dec 2009 08:01:41 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1759085AbZLONBj (ORCPT ); Tue, 15 Dec 2009 08:01:39 -0500 Received: from mx1.redhat.com ([209.132.183.28]:47739 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757996AbZLONBi (ORCPT ); Tue, 15 Dec 2009 08:01:38 -0500 Received: from int-mx08.intmail.prod.int.phx2.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id nBFD1Z21027527 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Tue, 15 Dec 2009 08:01:36 -0500 Received: from redhat.com (dhcp-0-94.tlv.redhat.com [10.35.0.94]) by int-mx08.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with SMTP id nBFD1YBN013308; Tue, 15 Dec 2009 08:01:34 -0500 Date: Tue, 15 Dec 2009 14:58:53 +0200 From: "Michael S. Tsirkin" To: Hannes Reinecke Cc: Avi Kivity , kvm@vger.kernel.org Subject: qemu-kvm: fix infinite recursion in pci Message-ID: <20091215125853.GA20690@redhat.com> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.19 (2009-01-05) X-Scanned-By: MIMEDefang 2.67 on 10.5.11.21 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org diff --git a/hw/pci.c b/hw/pci.c index 110a5fc..a74d3d4 100644 --- a/hw/pci.c +++ b/hw/pci.c @@ -1016,19 +1016,26 @@ static void pci_update_irq_disabled(PCIDevice *d, int was_irq_disabled) } } +static uint32_t pci_read_config(PCIDevice *d, + uint32_t address, int len) +{ + uint32_t val = 0; + + len = MIN(len, pci_config_size(d) - address); + memcpy(&val, d->config + address, len); + return le32_to_cpu(val); +} + uint32_t pci_default_read_config(PCIDevice *d, uint32_t address, int len) { - uint32_t val = 0; assert(len == 1 || len == 2 || len == 4); if (pci_access_cap_config(d, address, len)) { return d->cap.config_read(d, address, len); } - len = MIN(len, pci_config_size(d) - address); - memcpy(&val, d->config + address, len); - return le32_to_cpu(val); + return pci_read_config(d, address, len); } static void pci_write_config(PCIDevice *pci_dev, @@ -1052,7 +1059,7 @@ int pci_access_cap_config(PCIDevice *pci_dev, uint32_t address, int len) uint32_t pci_default_cap_read_config(PCIDevice *pci_dev, uint32_t address, int len) { - return pci_default_read_config(pci_dev, address, len); + return pci_read_config(pci_dev, address, len); } void pci_default_cap_write_config(PCIDevice *pci_dev,