From patchwork Tue Dec 15 11:11:01 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: 67591 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 nBFBE9Ok008775 for ; Tue, 15 Dec 2009 11:14:10 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1759765AbZLOLNt (ORCPT ); Tue, 15 Dec 2009 06:13:49 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1759925AbZLOLNr (ORCPT ); Tue, 15 Dec 2009 06:13:47 -0500 Received: from mx1.redhat.com ([209.132.183.28]:40244 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1759887AbZLOLNq (ORCPT ); Tue, 15 Dec 2009 06:13:46 -0500 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id nBFBDhr0020708 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Tue, 15 Dec 2009 06:13:43 -0500 Received: from redhat.com (dhcp-0-94.tlv.redhat.com [10.35.0.94]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with SMTP id nBFBDftA011052; Tue, 15 Dec 2009 06:13:42 -0500 Date: Tue, 15 Dec 2009 13:11:01 +0200 From: "Michael S. Tsirkin" To: Avi Kivity Cc: Hannes Reinecke , kvm@vger.kernel.org Subject: Re: Indefinite recursion in pci_default_read_config Message-ID: <20091215111101.GA13110@redhat.com> References: <4B276B81.4030709@suse.de> <4B276C1D.5060909@redhat.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <4B276C1D.5060909@redhat.com> User-Agent: Mutt/1.5.19 (2009-01-05) X-Scanned-By: MIMEDefang 2.67 on 10.5.11.12 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) } } +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,