summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael S. Tsirkin <mst@redhat.com>2012-10-22 12:35:00 +0200
committerMichael S. Tsirkin <mst@redhat.com>2012-10-29 17:59:06 +0200
commite26631b74663f59b5873a84ed5b92ee4ddf48255 (patch)
tree138a67a5726ff83a10517e14d7fd8f186c632037
parentdc59944bc9a5ad784572eea57610de60e4a2f4e5 (diff)
downloadqemu-e26631b74663f59b5873a84ed5b92ee4ddf48255.tar.gz
pci: make each capability DWORD aligned
PCI spec (see e.g. 6.7 Capabilities List in spec rev 3.0) requires that each capability is DWORD aligned. Ensure this when allocating space by rounding size up to 4. Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
-rw-r--r--hw/pci.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/hw/pci.c b/hw/pci.c
index 70b5fd965b..35cb374845 100644
--- a/hw/pci.c
+++ b/hw/pci.c
@@ -1906,7 +1906,7 @@ int pci_add_capability(PCIDevice *pdev, uint8_t cap_id,
config[PCI_CAP_LIST_NEXT] = pdev->config[PCI_CAPABILITY_LIST];
pdev->config[PCI_CAPABILITY_LIST] = offset;
pdev->config[PCI_STATUS] |= PCI_STATUS_CAP_LIST;
- memset(pdev->used + offset, 0xFF, size);
+ memset(pdev->used + offset, 0xFF, QEMU_ALIGN_UP(size, 4));
/* Make capability read-only by default */
memset(pdev->wmask + offset, 0, size);
/* Check capability by default */
@@ -1926,7 +1926,7 @@ void pci_del_capability(PCIDevice *pdev, uint8_t cap_id, uint8_t size)
memset(pdev->w1cmask + offset, 0, size);
/* Clear cmask as device-specific registers can't be checked */
memset(pdev->cmask + offset, 0, size);
- memset(pdev->used + offset, 0, size);
+ memset(pdev->used + offset, 0, QEMU_ALIGN_UP(size, 4));
if (!pdev->config[PCI_CAPABILITY_LIST])
pdev->config[PCI_STATUS] &= ~PCI_STATUS_CAP_LIST;