[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH] pci: Error on PCI capability collisions
From: |
Michael S. Tsirkin |
Subject: |
Re: [Qemu-devel] [PATCH] pci: Error on PCI capability collisions |
Date: |
Wed, 24 Aug 2011 13:04:39 +0300 |
User-agent: |
Mutt/1.5.21 (2010-09-15) |
On Tue, Aug 23, 2011 at 07:28:08PM +0200, Jan Kiszka wrote:
> From: Alex Williamson <address@hidden>
>
> Nothing good can happen when we overlap capabilities
>
> [ Jan: rebased over qemu, minor formatting ]
>
> Signed-off-by: Jan Kiszka <address@hidden>
This doesn't build for me:
/scm/qemu/hw/pci.c: In function ‘pci_add_capability’:
/scm/qemu/hw/pci.c:1970:45: error: ‘PCIDevice’ has no member named ‘config_map’
I think that what that includes is the capability including each given
offset, right? It would be easy to write some code scanning the
capability list to figure this value out.
Something along the lines of (untested):
static
uint8_t pci_find_capability_at_offset(PCIDevice *pdev, uint8_t offset)
{
uint8_t next, prev, found = 0;
if (!(pdev->config[PCI_STATUS] & PCI_STATUS_CAP_LIST))
return 0;
for (prev = PCI_CAPABILITY_LIST; (next = pdev->config[prev]);
prev = next + PCI_CAP_LIST_NEXT)
if (next <= offset && next > found)
found = next;
return found;
}
> ---
> 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
- [Qemu-devel] [PATCH] pci: Error on PCI capability collisions, Jan Kiszka, 2011/08/23
- Re: [Qemu-devel] [PATCH] pci: Error on PCI capability collisions, Michael S. Tsirkin, 2011/08/23
- Re: [Qemu-devel] [PATCH] pci: Error on PCI capability collisions, Alex Williamson, 2011/08/23
- Re: [Qemu-devel] [PATCH] pci: Error on PCI capability collisions, Michael S. Tsirkin, 2011/08/23
- Re: [Qemu-devel] [PATCH] pci: Error on PCI capability collisions, Alex Williamson, 2011/08/23
- Re: [Qemu-devel] [PATCH] pci: Error on PCI capability collisions, Michael S. Tsirkin, 2011/08/23
- Re: [Qemu-devel] [PATCH] pci: Error on PCI capability collisions, Alex Williamson, 2011/08/23
- Re: [Qemu-devel] [PATCH] pci: Error on PCI capability collisions, Don Dutile, 2011/08/23
- Re: [Qemu-devel] [PATCH] pci: Error on PCI capability collisions, Michael S. Tsirkin, 2011/08/24
Re: [Qemu-devel] [PATCH] pci: Error on PCI capability collisions,
Michael S. Tsirkin <=
- Re: [Qemu-devel] [PATCH] pci: Error on PCI capability collisions, Jan Kiszka, 2011/08/24
- Re: [Qemu-devel] [PATCH] pci: Error on PCI capability collisions, Michael S. Tsirkin, 2011/08/24
- Re: [Qemu-devel] [PATCH] pci: Error on PCI capability collisions, Michael S. Tsirkin, 2011/08/24
- Re: [Qemu-devel] [PATCH] pci: Error on PCI capability collisions, Jan Kiszka, 2011/08/24
- Re: [Qemu-devel] [PATCH] pci: Error on PCI capability collisions, Michael S. Tsirkin, 2011/08/24
- Re: [Qemu-devel] [PATCH] pci: Error on PCI capability collisions, Jan Kiszka, 2011/08/24
- Re: [Qemu-devel] [PATCH] pci: Error on PCI capability collisions, Michael S. Tsirkin, 2011/08/24
- Re: [Qemu-devel] [PATCH] pci: Error on PCI capability collisions, Jan Kiszka, 2011/08/24
[Qemu-devel] [PATCH v2] pci: Error on PCI capability collisions, Jan Kiszka, 2011/08/24