All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jan Kiszka <jan.kiszka@siemens.com>
To: "Michael S. Tsirkin" <mst@redhat.com>
Cc: Alex Williamson <alex.williamson@redhat.com>,
	qemu-devel <qemu-devel@nongnu.org>
Subject: [Qemu-devel] [PATCH] pci: Error on PCI capability collisions
Date: Tue, 23 Aug 2011 19:28:08 +0200	[thread overview]
Message-ID: <4E53E328.90601@siemens.com> (raw)

From: Alex Williamson <alex.williamson@redhat.com>

Nothing good can happen when we overlap capabilities

[ Jan: rebased over qemu, minor formatting ]

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
---
 hw/pci.c |   14 ++++++++++++++
 1 files changed, 14 insertions(+), 0 deletions(-)

diff --git a/hw/pci.c b/hw/pci.c
index 6124790..ff20631 100644
--- a/hw/pci.c
+++ b/hw/pci.c
@@ -1952,11 +1952,25 @@ int pci_add_capability(PCIDevice *pdev, uint8_t cap_id,
                        uint8_t offset, uint8_t size)
 {
     uint8_t *config;
+    int i;
+
     if (!offset) {
         offset = pci_find_space(pdev, size);
         if (!offset) {
             return -ENOSPC;
         }
+    } else {
+        for (i = offset; i < offset + size; i++) {
+            if (pdev->used[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;
-- 
1.7.3.4

             reply	other threads:[~2011-08-23 17:28 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-08-23 17:28 Jan Kiszka [this message]
2011-08-23 18:17 ` [Qemu-devel] [PATCH] pci: Error on PCI capability collisions Michael S. Tsirkin
2011-08-23 18:21   ` Alex Williamson
2011-08-23 18:26     ` Michael S. Tsirkin
2011-08-23 19:12       ` Alex Williamson
2011-08-23 19:30         ` Michael S. Tsirkin
2011-08-23 19:38           ` Alex Williamson
2011-08-23 20:59           ` Don Dutile
2011-08-24  9:51             ` Michael S. Tsirkin
2011-08-24 10:04 ` Michael S. Tsirkin
2011-08-24 10:10   ` Jan Kiszka
2011-08-24 11:01     ` Michael S. Tsirkin
2011-08-24 11:58     ` Michael S. Tsirkin
2011-08-24 12:29       ` Jan Kiszka
2011-08-24 12:34         ` Michael S. Tsirkin
2011-08-24 12:36           ` Jan Kiszka
2011-08-24 12:39             ` Michael S. Tsirkin
2011-08-24 12:39               ` Jan Kiszka
2011-08-24 12:29 ` [Qemu-devel] [PATCH v2] " Jan Kiszka
2011-08-24 12:53   ` Michael S. Tsirkin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4E53E328.90601@siemens.com \
    --to=jan.kiszka@siemens.com \
    --cc=alex.williamson@redhat.com \
    --cc=mst@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.