[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 04/38] tests/libqos/pci-pc: Fix qpci_pc_iomap() to m
From: |
Markus Armbruster |
Subject: |
[Qemu-devel] [PATCH 04/38] tests/libqos/pci-pc: Fix qpci_pc_iomap() to map BARs aligned |
Date: |
Mon, 29 Feb 2016 19:40:20 +0100 |
qpci_pc_iomap() maps BARs one after the other, without padding. This
is wrong. PCI Local Bus Specification Revision 3.0, 6.2.5.1. Address
Maps: "all address spaces used are a power of two in size and are
naturally aligned". That's because the size of a BAR is given by the
number of address bits the device decodes, and the BAR needs to be
mapped at a multiple of that size to ensure the address decoding
works.
Fix qpci_pc_iomap() accordingly. This takes care of a FIXME in
ivshmem-test.
Signed-off-by: Markus Armbruster <address@hidden>
---
tests/ivshmem-test.c | 17 ++++++++---------
tests/libqos/pci-pc.c | 8 ++++++--
2 files changed, 14 insertions(+), 11 deletions(-)
diff --git a/tests/ivshmem-test.c b/tests/ivshmem-test.c
index e184c67..e118377 100644
--- a/tests/ivshmem-test.c
+++ b/tests/ivshmem-test.c
@@ -110,19 +110,18 @@ static void setup_vm_cmd(IVState *s, const char *cmd,
bool msix)
s->pcibus = qpci_init_pc();
s->dev = get_device(s->pcibus);
- /* FIXME: other bar order fails, mappings changes */
- s->mem_base = qpci_iomap(s->dev, 2, &barsize);
- g_assert_nonnull(s->mem_base);
- g_assert_cmpuint(barsize, ==, TMPSHMSIZE);
-
- if (msix) {
- qpci_msix_enable(s->dev);
- }
-
s->reg_base = qpci_iomap(s->dev, 0, &barsize);
g_assert_nonnull(s->reg_base);
g_assert_cmpuint(barsize, ==, 256);
+ if (msix) {
+ qpci_msix_enable(s->dev);
+ }
+
+ s->mem_base = qpci_iomap(s->dev, 2, &barsize);
+ g_assert_nonnull(s->mem_base);
+ g_assert_cmpuint(barsize, ==, TMPSHMSIZE);
+
qpci_device_enable(s->dev);
}
diff --git a/tests/libqos/pci-pc.c b/tests/libqos/pci-pc.c
index 08167c0..77f15e5 100644
--- a/tests/libqos/pci-pc.c
+++ b/tests/libqos/pci-pc.c
@@ -184,7 +184,9 @@ static void *qpci_pc_iomap(QPCIBus *bus, QPCIDevice *dev,
int barno, uint64_t *s
if (io_type == PCI_BASE_ADDRESS_SPACE_IO) {
uint16_t loc;
- g_assert((s->pci_iohole_alloc + size) <= s->pci_iohole_size);
+ g_assert(QEMU_ALIGN_UP(s->pci_iohole_alloc, size) + size
+ <= s->pci_iohole_size);
+ s->pci_iohole_alloc = QEMU_ALIGN_UP(s->pci_iohole_alloc, size);
loc = s->pci_iohole_start + s->pci_iohole_alloc;
s->pci_iohole_alloc += size;
@@ -194,7 +196,9 @@ static void *qpci_pc_iomap(QPCIBus *bus, QPCIDevice *dev,
int barno, uint64_t *s
} else {
uint64_t loc;
- g_assert((s->pci_hole_alloc + size) <= s->pci_hole_size);
+ g_assert(QEMU_ALIGN_UP(s->pci_hole_alloc, size) + size
+ <= s->pci_hole_size);
+ s->pci_hole_alloc = QEMU_ALIGN_UP(s->pci_hole_alloc, size);
loc = s->pci_hole_start + s->pci_hole_alloc;
s->pci_hole_alloc += size;
--
2.4.3
- [Qemu-devel] [PATCH 03/38] event_notifier: Make event_notifier_init_fd() #ifdef CONFIG_EVENTFD, (continued)
- [Qemu-devel] [PATCH 03/38] event_notifier: Make event_notifier_init_fd() #ifdef CONFIG_EVENTFD, Markus Armbruster, 2016/02/29
- [Qemu-devel] [PATCH 13/38] ivshmem: Don't destroy the chardev on version mismatch, Markus Armbruster, 2016/02/29
- [Qemu-devel] [PATCH 21/38] ivshmem: Disentangle ivshmem_read(), Markus Armbruster, 2016/02/29
- [Qemu-devel] [PATCH 32/38] qdev: New DEFINE_PROP_ON_OFF_AUTO, Markus Armbruster, 2016/02/29
- [Qemu-devel] [PATCH 26/38] ivshmem: Drop the hackish test for UNIX domain chardev, Markus Armbruster, 2016/02/29
- [Qemu-devel] [PATCH 19/38] ivshmem: Assert interrupts are set up once, Markus Armbruster, 2016/02/29
- [Qemu-devel] [PATCH 28/38] ivshmem: Tighten check of property "size", Markus Armbruster, 2016/02/29
- [Qemu-devel] [PATCH 30/38] ivshmem: Simplify memory regions for BAR 2 (shared memory), Markus Armbruster, 2016/02/29
- [Qemu-devel] [PATCH 38/38] contrib/ivshmem-server: Print "not for production" warning, Markus Armbruster, 2016/02/29
- [Qemu-devel] [PATCH 25/38] ivshmem: Rely on server sending the ID right after the version, Markus Armbruster, 2016/02/29
- [Qemu-devel] [PATCH 04/38] tests/libqos/pci-pc: Fix qpci_pc_iomap() to map BARs aligned,
Markus Armbruster <=
- [Qemu-devel] [PATCH 08/38] ivshmem: Rewrite specification document, Markus Armbruster, 2016/02/29
- [Qemu-devel] [PATCH 37/38] ivshmem: Require master to have ID zero, Markus Armbruster, 2016/02/29
- [Qemu-devel] [PATCH 36/38] ivshmem: Drop ivshmem property x-memdev, Markus Armbruster, 2016/02/29
- [Qemu-devel] [PATCH 24/38] ivshmem: Propagate errors through ivshmem_recv_setup(), Markus Armbruster, 2016/02/29
- [Qemu-devel] [PATCH 23/38] ivshmem: Receive shared memory synchronously in realize(), Markus Armbruster, 2016/02/29
- [Qemu-devel] [PATCH 18/38] ivshmem: Leave INTx alone when using MSI-X, Markus Armbruster, 2016/02/29
- [Qemu-devel] [PATCH 31/38] ivshmem: Inline check_shm_size() into its only caller, Markus Armbruster, 2016/02/29
- [Qemu-devel] [PATCH 35/38] ivshmem: Clean up after the previous commit, Markus Armbruster, 2016/02/29
- [Qemu-devel] [PATCH 29/38] ivshmem: Implement shm=... with a memory backend, Markus Armbruster, 2016/02/29
- [Qemu-devel] [PATCH 27/38] ivshmem: Simplify how we cope with short reads from server, Markus Armbruster, 2016/02/29