From patchwork Mon Dec 6 16:22:48 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Williamson X-Patchwork-Id: 378732 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id oB6GMqZY027984 for ; Mon, 6 Dec 2010 16:22:52 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753778Ab0LFQWu (ORCPT ); Mon, 6 Dec 2010 11:22:50 -0500 Received: from mx1.redhat.com ([209.132.183.28]:3954 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751779Ab0LFQWt (ORCPT ); Mon, 6 Dec 2010 11:22:49 -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 oB6GMnis025236 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Mon, 6 Dec 2010 11:22:49 -0500 Received: from s20.home (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id oB6GMmZq028610; Mon, 6 Dec 2010 11:22:48 -0500 From: Alex Williamson Subject: [PATCH v2 3/5] pci: Error on PCI capability collisions To: kvm@vger.kernel.org Cc: alex.williamson@redhat.com, ddutile@redhat.com, mst@redhat.com, chrisw@redhat.com Date: Mon, 06 Dec 2010 09:22:48 -0700 Message-ID: <20101206162244.4648.46666.stgit@s20.home> In-Reply-To: <20101206161810.4648.45658.stgit@s20.home> References: <20101206161810.4648.45658.stgit@s20.home> User-Agent: StGIT/0.14.3 MIME-Version: 1.0 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 X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter1.kernel.org [140.211.167.41]); Mon, 06 Dec 2010 16:22:53 +0000 (UTC) diff --git a/hw/pci.c b/hw/pci.c index b08113d..288d6fd 100644 --- a/hw/pci.c +++ b/hw/pci.c @@ -1845,6 +1845,20 @@ int pci_add_capability(PCIDevice *pdev, uint8_t cap_id, if (!offset) { return -ENOSPC; } + } else { + int i; + + for (i = offset; i < offset + size; i++) { + if (pdev->config_map[i]) { + fprintf(stderr, "ERROR: %04x:%02x:%02x.%x " + "Attempt to add PCI capability %x at offset " + "%x overlaps existing capability %x at offset %x\n", + pci_find_domain(pdev->bus), pci_bus_num(pdev->bus), + PCI_SLOT(pdev->devfn), PCI_FUNC(pdev->devfn), + cap_id, offset, pdev->config_map[i], i); + return -EFAULT; + } + } } config = pdev->config + offset;