diff options
author | Michael S. Tsirkin <mst@redhat.com> | 2012-10-22 12:35:00 +0200 |
---|---|---|
committer | Michael S. Tsirkin <mst@redhat.com> | 2012-10-29 17:59:06 +0200 |
commit | e26631b74663f59b5873a84ed5b92ee4ddf48255 (patch) | |
tree | 138a67a5726ff83a10517e14d7fd8f186c632037 /hw/pci.c | |
parent | dc59944bc9a5ad784572eea57610de60e4a2f4e5 (diff) | |
download | qemu-e26631b74663f59b5873a84ed5b92ee4ddf48255.zip qemu-e26631b74663f59b5873a84ed5b92ee4ddf48255.tar.gz qemu-e26631b74663f59b5873a84ed5b92ee4ddf48255.tar.bz2 |
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>
Diffstat (limited to 'hw/pci.c')
-rw-r--r-- | hw/pci.c | 4 |
1 files changed, 2 insertions, 2 deletions
@@ -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; |