[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v2] Align PCI capabilities in pci_find_space
From: |
mjr |
Subject: |
[Qemu-devel] [PATCH v2] Align PCI capabilities in pci_find_space |
Date: |
Tue, 25 Sep 2012 20:01:53 -0500 |
From: Matt Renzelmann <address@hidden>
The current implementation of pci_find_space does not correctly align
PCI capabilities in the PCI configuration space. This patch fixes
this issue.
Signed-off-by: Matt Renzelmann <address@hidden>
---
Alex Williamson <address@hidden> wrote:
> I think you could just search every 4th byte. In fact, this whole used
> byte-map could be turned into a single uint64_t bitmap for standard
> config space. Thanks,
I've not tested this version of the patch, in contrast to the last, so
I'm a bit less confident of its correctness. I did not reimplement it
as suggested as I'm not that familiar with this code, and instead just
applied the every 4th byte strategy.
hw/pci.c | 12 ++++++++----
1 files changed, 8 insertions(+), 4 deletions(-)
diff --git a/hw/pci.c b/hw/pci.c
index f855cf3..e99866a 100644
--- a/hw/pci.c
+++ b/hw/pci.c
@@ -1631,11 +1631,15 @@ static int pci_find_space(PCIDevice *pdev, uint8_t size)
int config_size = pci_config_size(pdev);
int offset = PCI_CONFIG_HEADER_SIZE;
int i;
- for (i = PCI_CONFIG_HEADER_SIZE; i < config_size; ++i)
- if (pdev->used[i])
- offset = i + 1;
- else if (i - offset + 1 == size)
+
+ for (i = PCI_CONFIG_HEADER_SIZE; i < config_size; i += 4) {
+ if (pdev->used[i]) {
+ offset = i + 4;
+ } else if (i - offset + 1 == size) {
return offset;
+ }
+ }
+
return 0;
}
--
1.7.5.4
- [Qemu-devel] [PATCH v2] Align PCI capabilities in pci_find_space,
mjr <=