* [PATCH v2 1/6] tests/qtest/vhost-user-test.c: Use vhostforce=on
2022-01-18 20:38 [PATCH v2 0/6] qtests/libqos: Allow PCI tests to be run with virt-machine Eric Auger
@ 2022-01-18 20:38 ` Eric Auger
2022-01-20 14:23 ` Alex Bennée
2022-01-18 20:38 ` [PATCH v2 2/6] tests/qtest/libqos/pci: Introduce pio_limit Eric Auger
` (5 subsequent siblings)
6 siblings, 1 reply; 14+ messages in thread
From: Eric Auger @ 2022-01-18 20:38 UTC (permalink / raw)
To: eric.auger.pro, eric.auger, thuth, pbonzini, lvivier, qemu-arm,
qemu-devel, peter.maydell, mst, david, clg, eesposit
Cc: jean-philippe
-netdev vhost-user,vhostforce is deprecated and vhostforce=on
should be used instead.
Signed-off-by: Eric Auger <eric.auger@redhat.com>
Reviewed-by: Thomas Huth <thuth@redhat.com>
---
tests/qtest/vhost-user-test.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tests/qtest/vhost-user-test.c b/tests/qtest/vhost-user-test.c
index 3d6337fb5c..6e79935c47 100644
--- a/tests/qtest/vhost-user-test.c
+++ b/tests/qtest/vhost-user-test.c
@@ -42,7 +42,7 @@
#define QEMU_CMD_MEMFD " -m %d -object memory-backend-memfd,id=mem,size=%dM," \
" -numa node,memdev=mem"
#define QEMU_CMD_CHR " -chardev socket,id=%s,path=%s%s"
-#define QEMU_CMD_NETDEV " -netdev vhost-user,id=hs0,chardev=%s,vhostforce"
+#define QEMU_CMD_NETDEV " -netdev vhost-user,id=hs0,chardev=%s,vhostforce=on"
#define HUGETLBFS_MAGIC 0x958458f6
--
2.26.3
^ permalink raw reply related [flat|nested] 14+ messages in thread
* Re: [PATCH v2 1/6] tests/qtest/vhost-user-test.c: Use vhostforce=on
2022-01-18 20:38 ` [PATCH v2 1/6] tests/qtest/vhost-user-test.c: Use vhostforce=on Eric Auger
@ 2022-01-20 14:23 ` Alex Bennée
0 siblings, 0 replies; 14+ messages in thread
From: Alex Bennée @ 2022-01-20 14:23 UTC (permalink / raw)
To: Eric Auger
Cc: lvivier, peter.maydell, thuth, mst, eesposit, qemu-devel,
jean-philippe, qemu-arm, clg, pbonzini, david, eric.auger.pro
Eric Auger <eric.auger@redhat.com> writes:
> -netdev vhost-user,vhostforce is deprecated and vhostforce=on
> should be used instead.
>
> Signed-off-by: Eric Auger <eric.auger@redhat.com>
> Reviewed-by: Thomas Huth <thuth@redhat.com>
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
--
Alex Bennée
^ permalink raw reply [flat|nested] 14+ messages in thread
* [PATCH v2 2/6] tests/qtest/libqos/pci: Introduce pio_limit
2022-01-18 20:38 [PATCH v2 0/6] qtests/libqos: Allow PCI tests to be run with virt-machine Eric Auger
2022-01-18 20:38 ` [PATCH v2 1/6] tests/qtest/vhost-user-test.c: Use vhostforce=on Eric Auger
@ 2022-01-18 20:38 ` Eric Auger
2022-01-20 15:04 ` Alex Bennée
2022-01-18 20:38 ` [PATCH v2 3/6] tests/qtest/libqos: Skip hotplug tests if pci root bus is not hotpluggable Eric Auger
` (4 subsequent siblings)
6 siblings, 1 reply; 14+ messages in thread
From: Eric Auger @ 2022-01-18 20:38 UTC (permalink / raw)
To: eric.auger.pro, eric.auger, thuth, pbonzini, lvivier, qemu-arm,
qemu-devel, peter.maydell, mst, david, clg, eesposit
Cc: jean-philippe
At the moment the IO space limit is hardcoded to
QPCI_PIO_LIMIT = 0x10000. When accesses are performed to a bar,
the base address of this latter is compared against the limit
to decide whether we perform an IO or a memory access.
On ARM, we cannot keep this PIO limit as the arm-virt machine
uses [0x3eff0000, 0x3f000000 ] for the IO space map and we
are mandated to allocate at 0x0.
Add a new flag in QPCIBar indicating whether it is an IO bar
or a memory bar. This flag is set on QPCIBar allocation and
provisionned based on the BAR configuration. Then the new flag
is used in access functions and in iomap() function.
Signed-off-by: Eric Auger <eric.auger@redhat.com>
Reviewed-by: Thomas Huth <thuth@redhat.com>
---
tests/qtest/libqos/pci-pc.c | 1 +
tests/qtest/libqos/pci-spapr.c | 1 +
tests/qtest/libqos/pci.c | 78 ++++++++++++++++++++++------------
tests/qtest/libqos/pci.h | 5 +--
4 files changed, 54 insertions(+), 31 deletions(-)
diff --git a/tests/qtest/libqos/pci-pc.c b/tests/qtest/libqos/pci-pc.c
index f97844289f..8051a0881a 100644
--- a/tests/qtest/libqos/pci-pc.c
+++ b/tests/qtest/libqos/pci-pc.c
@@ -150,6 +150,7 @@ void qpci_init_pc(QPCIBusPC *qpci, QTestState *qts, QGuestAllocator *alloc)
qpci->bus.qts = qts;
qpci->bus.pio_alloc_ptr = 0xc000;
+ qpci->bus.pio_limit = 0x10000;
qpci->bus.mmio_alloc_ptr = 0xE0000000;
qpci->bus.mmio_limit = 0x100000000ULL;
diff --git a/tests/qtest/libqos/pci-spapr.c b/tests/qtest/libqos/pci-spapr.c
index 262226985f..870ffdd8b5 100644
--- a/tests/qtest/libqos/pci-spapr.c
+++ b/tests/qtest/libqos/pci-spapr.c
@@ -197,6 +197,7 @@ void qpci_init_spapr(QPCIBusSPAPR *qpci, QTestState *qts,
qpci->bus.qts = qts;
qpci->bus.pio_alloc_ptr = 0xc000;
+ qpci->bus.pio_limit = 0x10000;
qpci->bus.mmio_alloc_ptr = qpci->mmio32.pci_base;
qpci->bus.mmio_limit = qpci->mmio32.pci_base + qpci->mmio32.size;
diff --git a/tests/qtest/libqos/pci.c b/tests/qtest/libqos/pci.c
index 3a9076ae58..b23d72346b 100644
--- a/tests/qtest/libqos/pci.c
+++ b/tests/qtest/libqos/pci.c
@@ -398,44 +398,56 @@ void qpci_config_writel(QPCIDevice *dev, uint8_t offset, uint32_t value)
uint8_t qpci_io_readb(QPCIDevice *dev, QPCIBar token, uint64_t off)
{
- if (token.addr < QPCI_PIO_LIMIT) {
- return dev->bus->pio_readb(dev->bus, token.addr + off);
+ QPCIBus *bus = dev->bus;
+
+ if (token.is_io) {
+ return bus->pio_readb(bus, token.addr + off);
} else {
uint8_t val;
- dev->bus->memread(dev->bus, token.addr + off, &val, sizeof(val));
+
+ bus->memread(dev->bus, token.addr + off, &val, sizeof(val));
return val;
}
}
uint16_t qpci_io_readw(QPCIDevice *dev, QPCIBar token, uint64_t off)
{
- if (token.addr < QPCI_PIO_LIMIT) {
- return dev->bus->pio_readw(dev->bus, token.addr + off);
+ QPCIBus *bus = dev->bus;
+
+ if (token.is_io) {
+ return bus->pio_readw(bus, token.addr + off);
} else {
uint16_t val;
- dev->bus->memread(dev->bus, token.addr + off, &val, sizeof(val));
+
+ bus->memread(bus, token.addr + off, &val, sizeof(val));
return le16_to_cpu(val);
}
}
uint32_t qpci_io_readl(QPCIDevice *dev, QPCIBar token, uint64_t off)
{
- if (token.addr < QPCI_PIO_LIMIT) {
- return dev->bus->pio_readl(dev->bus, token.addr + off);
+ QPCIBus *bus = dev->bus;
+
+ if (token.is_io) {
+ return bus->pio_readl(bus, token.addr + off);
} else {
uint32_t val;
- dev->bus->memread(dev->bus, token.addr + off, &val, sizeof(val));
+
+ bus->memread(dev->bus, token.addr + off, &val, sizeof(val));
return le32_to_cpu(val);
}
}
uint64_t qpci_io_readq(QPCIDevice *dev, QPCIBar token, uint64_t off)
{
- if (token.addr < QPCI_PIO_LIMIT) {
- return dev->bus->pio_readq(dev->bus, token.addr + off);
+ QPCIBus *bus = dev->bus;
+
+ if (token.is_io) {
+ return bus->pio_readq(bus, token.addr + off);
} else {
uint64_t val;
- dev->bus->memread(dev->bus, token.addr + off, &val, sizeof(val));
+
+ bus->memread(bus, token.addr + off, &val, sizeof(val));
return le64_to_cpu(val);
}
}
@@ -443,57 +455,65 @@ uint64_t qpci_io_readq(QPCIDevice *dev, QPCIBar token, uint64_t off)
void qpci_io_writeb(QPCIDevice *dev, QPCIBar token, uint64_t off,
uint8_t value)
{
- if (token.addr < QPCI_PIO_LIMIT) {
- dev->bus->pio_writeb(dev->bus, token.addr + off, value);
+ QPCIBus *bus = dev->bus;
+
+ if (token.is_io) {
+ bus->pio_writeb(bus, token.addr + off, value);
} else {
- dev->bus->memwrite(dev->bus, token.addr + off, &value, sizeof(value));
+ bus->memwrite(bus, token.addr + off, &value, sizeof(value));
}
}
void qpci_io_writew(QPCIDevice *dev, QPCIBar token, uint64_t off,
uint16_t value)
{
- if (token.addr < QPCI_PIO_LIMIT) {
- dev->bus->pio_writew(dev->bus, token.addr + off, value);
+ QPCIBus *bus = dev->bus;
+
+ if (token.is_io) {
+ bus->pio_writew(bus, token.addr + off, value);
} else {
value = cpu_to_le16(value);
- dev->bus->memwrite(dev->bus, token.addr + off, &value, sizeof(value));
+ bus->memwrite(bus, token.addr + off, &value, sizeof(value));
}
}
void qpci_io_writel(QPCIDevice *dev, QPCIBar token, uint64_t off,
uint32_t value)
{
- if (token.addr < QPCI_PIO_LIMIT) {
- dev->bus->pio_writel(dev->bus, token.addr + off, value);
+ QPCIBus *bus = dev->bus;
+
+ if (token.is_io) {
+ bus->pio_writel(bus, token.addr + off, value);
} else {
value = cpu_to_le32(value);
- dev->bus->memwrite(dev->bus, token.addr + off, &value, sizeof(value));
+ bus->memwrite(bus, token.addr + off, &value, sizeof(value));
}
}
void qpci_io_writeq(QPCIDevice *dev, QPCIBar token, uint64_t off,
uint64_t value)
{
- if (token.addr < QPCI_PIO_LIMIT) {
- dev->bus->pio_writeq(dev->bus, token.addr + off, value);
+ QPCIBus *bus = dev->bus;
+
+ if (token.is_io) {
+ bus->pio_writeq(bus, token.addr + off, value);
} else {
value = cpu_to_le64(value);
- dev->bus->memwrite(dev->bus, token.addr + off, &value, sizeof(value));
+ bus->memwrite(bus, token.addr + off, &value, sizeof(value));
}
}
void qpci_memread(QPCIDevice *dev, QPCIBar token, uint64_t off,
void *buf, size_t len)
{
- g_assert(token.addr >= QPCI_PIO_LIMIT);
+ g_assert(!token.is_io);
dev->bus->memread(dev->bus, token.addr + off, buf, len);
}
void qpci_memwrite(QPCIDevice *dev, QPCIBar token, uint64_t off,
const void *buf, size_t len)
{
- g_assert(token.addr >= QPCI_PIO_LIMIT);
+ g_assert(!token.is_io);
dev->bus->memwrite(dev->bus, token.addr + off, buf, len);
}
@@ -534,9 +554,10 @@ QPCIBar qpci_iomap(QPCIDevice *dev, int barno, uint64_t *sizeptr)
loc = QEMU_ALIGN_UP(bus->pio_alloc_ptr, size);
g_assert(loc >= bus->pio_alloc_ptr);
- g_assert(loc + size <= QPCI_PIO_LIMIT); /* Keep PIO below 64kiB */
+ g_assert(loc + size <= bus->pio_limit);
bus->pio_alloc_ptr = loc + size;
+ bar.is_io = true;
qpci_config_writel(dev, bar_reg, loc | PCI_BASE_ADDRESS_SPACE_IO);
} else {
@@ -547,6 +568,7 @@ QPCIBar qpci_iomap(QPCIDevice *dev, int barno, uint64_t *sizeptr)
g_assert(loc + size <= bus->mmio_limit);
bus->mmio_alloc_ptr = loc + size;
+ bar.is_io = false;
qpci_config_writel(dev, bar_reg, loc);
}
@@ -562,7 +584,7 @@ void qpci_iounmap(QPCIDevice *dev, QPCIBar bar)
QPCIBar qpci_legacy_iomap(QPCIDevice *dev, uint16_t addr)
{
- QPCIBar bar = { .addr = addr };
+ QPCIBar bar = { .addr = addr, .is_io = true };
return bar;
}
diff --git a/tests/qtest/libqos/pci.h b/tests/qtest/libqos/pci.h
index becb800f9e..44f6806fe4 100644
--- a/tests/qtest/libqos/pci.h
+++ b/tests/qtest/libqos/pci.h
@@ -16,8 +16,6 @@
#include "libqtest.h"
#include "qgraph.h"
-#define QPCI_PIO_LIMIT 0x10000
-
#define QPCI_DEVFN(dev, fn) (((dev) << 3) | (fn))
typedef struct QPCIDevice QPCIDevice;
@@ -51,7 +49,7 @@ struct QPCIBus {
uint8_t offset, uint32_t value);
QTestState *qts;
- uint16_t pio_alloc_ptr;
+ uint64_t pio_alloc_ptr, pio_limit;
uint64_t mmio_alloc_ptr, mmio_limit;
bool has_buggy_msi; /* TRUE for spapr, FALSE for pci */
@@ -59,6 +57,7 @@ struct QPCIBus {
struct QPCIBar {
uint64_t addr;
+ bool is_io;
};
struct QPCIDevice
--
2.26.3
^ permalink raw reply related [flat|nested] 14+ messages in thread
* Re: [PATCH v2 2/6] tests/qtest/libqos/pci: Introduce pio_limit
2022-01-18 20:38 ` [PATCH v2 2/6] tests/qtest/libqos/pci: Introduce pio_limit Eric Auger
@ 2022-01-20 15:04 ` Alex Bennée
0 siblings, 0 replies; 14+ messages in thread
From: Alex Bennée @ 2022-01-20 15:04 UTC (permalink / raw)
To: Eric Auger
Cc: lvivier, peter.maydell, thuth, mst, eesposit, qemu-devel,
jean-philippe, qemu-arm, clg, pbonzini, david, eric.auger.pro
Eric Auger <eric.auger@redhat.com> writes:
> At the moment the IO space limit is hardcoded to
> QPCI_PIO_LIMIT = 0x10000. When accesses are performed to a bar,
> the base address of this latter is compared against the limit
> to decide whether we perform an IO or a memory access.
>
> On ARM, we cannot keep this PIO limit as the arm-virt machine
> uses [0x3eff0000, 0x3f000000 ] for the IO space map and we
> are mandated to allocate at 0x0.
>
> Add a new flag in QPCIBar indicating whether it is an IO bar
> or a memory bar. This flag is set on QPCIBar allocation and
> provisionned based on the BAR configuration. Then the new flag
> is used in access functions and in iomap() function.
>
> Signed-off-by: Eric Auger <eric.auger@redhat.com>
> Reviewed-by: Thomas Huth <thuth@redhat.com>
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
--
Alex Bennée
^ permalink raw reply [flat|nested] 14+ messages in thread
* [PATCH v2 3/6] tests/qtest/libqos: Skip hotplug tests if pci root bus is not hotpluggable
2022-01-18 20:38 [PATCH v2 0/6] qtests/libqos: Allow PCI tests to be run with virt-machine Eric Auger
2022-01-18 20:38 ` [PATCH v2 1/6] tests/qtest/vhost-user-test.c: Use vhostforce=on Eric Auger
2022-01-18 20:38 ` [PATCH v2 2/6] tests/qtest/libqos/pci: Introduce pio_limit Eric Auger
@ 2022-01-18 20:38 ` Eric Auger
2022-01-20 15:37 ` Alex Bennée
2022-01-18 20:38 ` [PATCH v2 4/6] tests/qtest/vhost-user-blk-test: Setup MSIx to avoid error on aarch64 Eric Auger
` (3 subsequent siblings)
6 siblings, 1 reply; 14+ messages in thread
From: Eric Auger @ 2022-01-18 20:38 UTC (permalink / raw)
To: eric.auger.pro, eric.auger, thuth, pbonzini, lvivier, qemu-arm,
qemu-devel, peter.maydell, mst, david, clg, eesposit
Cc: jean-philippe
ARM does not not support hotplug on pcie.0. Add a flag on the bus
which tells if devices can be hotplugged and skip hotplug tests
if the bus cannot be hotplugged. This is a temporary solution to
enable the other pci tests on aarch64.
Signed-off-by: Eric Auger <eric.auger@redhat.com>
Acked-by: Thomas Huth <thuth@redhat.com>
---
v1 ->v2:
- reword g_test_skip msg into "pci bus does not support hotplug"
---
tests/qtest/e1000e-test.c | 6 ++++++
tests/qtest/libqos/pci.h | 1 +
tests/qtest/vhost-user-blk-test.c | 10 ++++++++++
tests/qtest/virtio-blk-test.c | 5 +++++
tests/qtest/virtio-net-test.c | 5 +++++
tests/qtest/virtio-rng-test.c | 5 +++++
6 files changed, 32 insertions(+)
diff --git a/tests/qtest/e1000e-test.c b/tests/qtest/e1000e-test.c
index 0273fe4c15..48f3dbb0fd 100644
--- a/tests/qtest/e1000e-test.c
+++ b/tests/qtest/e1000e-test.c
@@ -235,6 +235,12 @@ static void test_e1000e_multiple_transfers(void *obj, void *data,
static void test_e1000e_hotplug(void *obj, void *data, QGuestAllocator * alloc)
{
QTestState *qts = global_qtest; /* TODO: get rid of global_qtest here */
+ QE1000E_PCI *dev = obj;
+
+ if (dev->pci_dev.bus->not_hotpluggable) {
+ g_test_skip("pci bus does not support hotplug");
+ return;
+ }
qtest_qmp_device_add(qts, "e1000e", "e1000e_net", "{'addr': '0x06'}");
qpci_unplug_acpi_device_test(qts, "e1000e_net", 0x06);
diff --git a/tests/qtest/libqos/pci.h b/tests/qtest/libqos/pci.h
index 44f6806fe4..6a28b40522 100644
--- a/tests/qtest/libqos/pci.h
+++ b/tests/qtest/libqos/pci.h
@@ -52,6 +52,7 @@ struct QPCIBus {
uint64_t pio_alloc_ptr, pio_limit;
uint64_t mmio_alloc_ptr, mmio_limit;
bool has_buggy_msi; /* TRUE for spapr, FALSE for pci */
+ bool not_hotpluggable; /* TRUE if devices cannot be hotplugged */
};
diff --git a/tests/qtest/vhost-user-blk-test.c b/tests/qtest/vhost-user-blk-test.c
index 62e670f39b..1316aae0fa 100644
--- a/tests/qtest/vhost-user-blk-test.c
+++ b/tests/qtest/vhost-user-blk-test.c
@@ -676,6 +676,11 @@ static void pci_hotplug(void *obj, void *data, QGuestAllocator *t_alloc)
QVirtioPCIDevice *dev;
QTestState *qts = dev1->pdev->bus->qts;
+ if (dev1->pdev->bus->not_hotpluggable) {
+ g_test_skip("pci bus does not support hotplug");
+ return;
+ }
+
/* plug secondary disk */
qtest_qmp_device_add(qts, "vhost-user-blk-pci", "drv1",
"{'addr': %s, 'chardev': 'char2'}",
@@ -703,6 +708,11 @@ static void multiqueue(void *obj, void *data, QGuestAllocator *t_alloc)
uint64_t features;
uint16_t num_queues;
+ if (pdev1->pdev->bus->not_hotpluggable) {
+ g_test_skip("bus pci.0 does not support hotplug");
+ return;
+ }
+
/*
* The primary device has 1 queue and VIRTIO_BLK_F_MQ is not enabled. The
* VIRTIO specification allows VIRTIO_BLK_F_MQ to be enabled when there is
diff --git a/tests/qtest/virtio-blk-test.c b/tests/qtest/virtio-blk-test.c
index 2a23698211..acb44c9fb8 100644
--- a/tests/qtest/virtio-blk-test.c
+++ b/tests/qtest/virtio-blk-test.c
@@ -701,6 +701,11 @@ static void pci_hotplug(void *obj, void *data, QGuestAllocator *t_alloc)
QVirtioPCIDevice *dev;
QTestState *qts = dev1->pdev->bus->qts;
+ if (dev1->pdev->bus->not_hotpluggable) {
+ g_test_skip("pci bus does not support hotplug");
+ return;
+ }
+
/* plug secondary disk */
qtest_qmp_device_add(qts, "virtio-blk-pci", "drv1",
"{'addr': %s, 'drive': 'drive1'}",
diff --git a/tests/qtest/virtio-net-test.c b/tests/qtest/virtio-net-test.c
index 8bf74e516c..af3027144f 100644
--- a/tests/qtest/virtio-net-test.c
+++ b/tests/qtest/virtio-net-test.c
@@ -174,6 +174,11 @@ static void hotplug(void *obj, void *data, QGuestAllocator *t_alloc)
QTestState *qts = dev->pdev->bus->qts;
const char *arch = qtest_get_arch();
+ if (dev->pdev->bus->not_hotpluggable) {
+ g_test_skip("pci bus does not support hotplug");
+ return;
+ }
+
qtest_qmp_device_add(qts, "virtio-net-pci", "net1",
"{'addr': %s}", stringify(PCI_SLOT_HP));
diff --git a/tests/qtest/virtio-rng-test.c b/tests/qtest/virtio-rng-test.c
index e6b8cd8e0c..5ce444ad72 100644
--- a/tests/qtest/virtio-rng-test.c
+++ b/tests/qtest/virtio-rng-test.c
@@ -20,6 +20,11 @@ static void rng_hotplug(void *obj, void *data, QGuestAllocator *alloc)
QVirtioPCIDevice *dev = obj;
QTestState *qts = dev->pdev->bus->qts;
+ if (dev->pdev->bus->not_hotpluggable) {
+ g_test_skip("pci bus does not support hotplug");
+ return;
+ }
+
const char *arch = qtest_get_arch();
qtest_qmp_device_add(qts, "virtio-rng-pci", "rng1",
--
2.26.3
^ permalink raw reply related [flat|nested] 14+ messages in thread
* Re: [PATCH v2 3/6] tests/qtest/libqos: Skip hotplug tests if pci root bus is not hotpluggable
2022-01-18 20:38 ` [PATCH v2 3/6] tests/qtest/libqos: Skip hotplug tests if pci root bus is not hotpluggable Eric Auger
@ 2022-01-20 15:37 ` Alex Bennée
0 siblings, 0 replies; 14+ messages in thread
From: Alex Bennée @ 2022-01-20 15:37 UTC (permalink / raw)
To: Eric Auger
Cc: lvivier, peter.maydell, thuth, mst, eesposit, qemu-devel,
jean-philippe, qemu-arm, clg, pbonzini, david, eric.auger.pro
Eric Auger <eric.auger@redhat.com> writes:
> ARM does not not support hotplug on pcie.0. Add a flag on the bus
> which tells if devices can be hotplugged and skip hotplug tests
> if the bus cannot be hotplugged. This is a temporary solution to
> enable the other pci tests on aarch64.
>
> Signed-off-by: Eric Auger <eric.auger@redhat.com>
> Acked-by: Thomas Huth <thuth@redhat.com>
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
--
Alex Bennée
^ permalink raw reply [flat|nested] 14+ messages in thread
* [PATCH v2 4/6] tests/qtest/vhost-user-blk-test: Setup MSIx to avoid error on aarch64
2022-01-18 20:38 [PATCH v2 0/6] qtests/libqos: Allow PCI tests to be run with virt-machine Eric Auger
` (2 preceding siblings ...)
2022-01-18 20:38 ` [PATCH v2 3/6] tests/qtest/libqos: Skip hotplug tests if pci root bus is not hotpluggable Eric Auger
@ 2022-01-18 20:38 ` Eric Auger
2022-02-04 19:34 ` Michael S. Tsirkin
2022-01-18 20:38 ` [PATCH v2 5/6] tests/qtest/vhost-user-blk-test: Factorize vq setup code Eric Auger
` (2 subsequent siblings)
6 siblings, 1 reply; 14+ messages in thread
From: Eric Auger @ 2022-01-18 20:38 UTC (permalink / raw)
To: eric.auger.pro, eric.auger, thuth, pbonzini, lvivier, qemu-arm,
qemu-devel, peter.maydell, mst, david, clg, eesposit
Cc: jean-philippe
When run on ARM, basic and indirect tests currently fail with the
following error:
ERROR:../tests/qtest/libqos/virtio.c:224:qvirtio_wait_used_elem:
assertion failed (got_desc_idx == desc_idx): (50331648 == 0)
Bail out! ERROR:../tests/qtest/libqos/virtio.c:224: qvirtio_wait_used_elem:
assertion failed (got_desc_idx == desc_idx): (50331648 == 0)
Setting up and enabling MSIX fixes the issue.
Also remove the useless libqos/libqos-pc.h header inclusion.
Signed-off-by: Eric Auger <eric.auger@redhat.com>
Acked-by: Thomas Huth <thuth@redhat.com>
---
tests/qtest/vhost-user-blk-test.c | 16 +++++++++++++++-
1 file changed, 15 insertions(+), 1 deletion(-)
diff --git a/tests/qtest/vhost-user-blk-test.c b/tests/qtest/vhost-user-blk-test.c
index 1316aae0fa..2606428df3 100644
--- a/tests/qtest/vhost-user-blk-test.c
+++ b/tests/qtest/vhost-user-blk-test.c
@@ -19,7 +19,6 @@
#include "standard-headers/linux/virtio_pci.h"
#include "libqos/qgraph.h"
#include "libqos/vhost-user-blk.h"
-#include "libqos/libqos-pc.h"
#define TEST_IMAGE_SIZE (64 * 1024 * 1024)
#define QVIRTIO_BLK_TIMEOUT_US (30 * 1000 * 1000)
@@ -224,6 +223,10 @@ static QVirtQueue *test_basic(QVirtioDevice *dev, QGuestAllocator *alloc)
char *data;
QTestState *qts = global_qtest;
QVirtQueue *vq;
+ QVirtioPCIDevice *vpcidev = container_of(dev, QVirtioPCIDevice, vdev);
+
+ qpci_msix_enable(vpcidev->pdev);
+ qvirtio_pci_set_msix_configuration_vector(vpcidev, alloc, 0);
features = qvirtio_get_features(dev);
features = features & ~(QVIRTIO_F_BAD_FEATURE |
@@ -236,9 +239,12 @@ static QVirtQueue *test_basic(QVirtioDevice *dev, QGuestAllocator *alloc)
g_assert_cmpint(capacity, ==, TEST_IMAGE_SIZE / 512);
vq = qvirtqueue_setup(dev, alloc, 0);
+ qvirtqueue_pci_msix_setup(vpcidev, (QVirtQueuePCI *)vq, alloc, 1);
qvirtio_set_driver_ok(dev);
+ qvirtio_wait_queue_isr(qts, dev, vq, QVIRTIO_BLK_TIMEOUT_US);
+
/* Write and read with 3 descriptor layout */
/* Write request */
req.type = VIRTIO_BLK_T_OUT;
@@ -468,6 +474,10 @@ static void indirect(void *obj, void *u_data, QGuestAllocator *t_alloc)
uint8_t status;
char *data;
QTestState *qts = global_qtest;
+ QVirtioPCIDevice *vpcidev = container_of(dev, QVirtioPCIDevice, vdev);
+
+ qpci_msix_enable(vpcidev->pdev);
+ qvirtio_pci_set_msix_configuration_vector(vpcidev, t_alloc, 0);
features = qvirtio_get_features(dev);
g_assert_cmphex(features & (1u << VIRTIO_RING_F_INDIRECT_DESC), !=, 0);
@@ -480,8 +490,12 @@ static void indirect(void *obj, void *u_data, QGuestAllocator *t_alloc)
g_assert_cmpint(capacity, ==, TEST_IMAGE_SIZE / 512);
vq = qvirtqueue_setup(dev, t_alloc, 0);
+ qvirtqueue_pci_msix_setup(vpcidev, (QVirtQueuePCI *)vq, t_alloc, 1);
+
qvirtio_set_driver_ok(dev);
+ qvirtio_wait_queue_isr(qts, dev, vq, QVIRTIO_BLK_TIMEOUT_US);
+
/* Write request */
req.type = VIRTIO_BLK_T_OUT;
req.ioprio = 1;
--
2.26.3
^ permalink raw reply related [flat|nested] 14+ messages in thread
* Re: [PATCH v2 4/6] tests/qtest/vhost-user-blk-test: Setup MSIx to avoid error on aarch64
2022-01-18 20:38 ` [PATCH v2 4/6] tests/qtest/vhost-user-blk-test: Setup MSIx to avoid error on aarch64 Eric Auger
@ 2022-02-04 19:34 ` Michael S. Tsirkin
0 siblings, 0 replies; 14+ messages in thread
From: Michael S. Tsirkin @ 2022-02-04 19:34 UTC (permalink / raw)
To: Eric Auger
Cc: lvivier, peter.maydell, thuth, jean-philippe, eesposit,
qemu-devel, qemu-arm, clg, pbonzini, david, eric.auger.pro
On Tue, Jan 18, 2022 at 09:38:31PM +0100, Eric Auger wrote:
> When run on ARM, basic and indirect tests currently fail with the
> following error:
>
> ERROR:../tests/qtest/libqos/virtio.c:224:qvirtio_wait_used_elem:
> assertion failed (got_desc_idx == desc_idx): (50331648 == 0)
> Bail out! ERROR:../tests/qtest/libqos/virtio.c:224: qvirtio_wait_used_elem:
> assertion failed (got_desc_idx == desc_idx): (50331648 == 0)
>
> Setting up and enabling MSIX fixes the issue.
>
> Also remove the useless libqos/libqos-pc.h header inclusion.
>
> Signed-off-by: Eric Auger <eric.auger@redhat.com>
> Acked-by: Thomas Huth <thuth@redhat.com>
Seems to cause a make check failure:
▶ 71/713 ERROR:../tests/qtest/libqos/pci.c:232:qpci_device_enable: assertion failed (cmd & PCI_COMMAND_IO == PCI_COMMAND_IO): (0x00000000
+== 0x00000001) ERROR
^CWARNING: Received SIGTERM, exiting
> ---
> tests/qtest/vhost-user-blk-test.c | 16 +++++++++++++++-
> 1 file changed, 15 insertions(+), 1 deletion(-)
>
> diff --git a/tests/qtest/vhost-user-blk-test.c b/tests/qtest/vhost-user-blk-test.c
> index 1316aae0fa..2606428df3 100644
> --- a/tests/qtest/vhost-user-blk-test.c
> +++ b/tests/qtest/vhost-user-blk-test.c
> @@ -19,7 +19,6 @@
> #include "standard-headers/linux/virtio_pci.h"
> #include "libqos/qgraph.h"
> #include "libqos/vhost-user-blk.h"
> -#include "libqos/libqos-pc.h"
>
> #define TEST_IMAGE_SIZE (64 * 1024 * 1024)
> #define QVIRTIO_BLK_TIMEOUT_US (30 * 1000 * 1000)
> @@ -224,6 +223,10 @@ static QVirtQueue *test_basic(QVirtioDevice *dev, QGuestAllocator *alloc)
> char *data;
> QTestState *qts = global_qtest;
> QVirtQueue *vq;
> + QVirtioPCIDevice *vpcidev = container_of(dev, QVirtioPCIDevice, vdev);
> +
> + qpci_msix_enable(vpcidev->pdev);
> + qvirtio_pci_set_msix_configuration_vector(vpcidev, alloc, 0);
>
> features = qvirtio_get_features(dev);
> features = features & ~(QVIRTIO_F_BAD_FEATURE |
> @@ -236,9 +239,12 @@ static QVirtQueue *test_basic(QVirtioDevice *dev, QGuestAllocator *alloc)
> g_assert_cmpint(capacity, ==, TEST_IMAGE_SIZE / 512);
>
> vq = qvirtqueue_setup(dev, alloc, 0);
> + qvirtqueue_pci_msix_setup(vpcidev, (QVirtQueuePCI *)vq, alloc, 1);
>
> qvirtio_set_driver_ok(dev);
>
> + qvirtio_wait_queue_isr(qts, dev, vq, QVIRTIO_BLK_TIMEOUT_US);
> +
> /* Write and read with 3 descriptor layout */
> /* Write request */
> req.type = VIRTIO_BLK_T_OUT;
> @@ -468,6 +474,10 @@ static void indirect(void *obj, void *u_data, QGuestAllocator *t_alloc)
> uint8_t status;
> char *data;
> QTestState *qts = global_qtest;
> + QVirtioPCIDevice *vpcidev = container_of(dev, QVirtioPCIDevice, vdev);
> +
> + qpci_msix_enable(vpcidev->pdev);
> + qvirtio_pci_set_msix_configuration_vector(vpcidev, t_alloc, 0);
>
> features = qvirtio_get_features(dev);
> g_assert_cmphex(features & (1u << VIRTIO_RING_F_INDIRECT_DESC), !=, 0);
> @@ -480,8 +490,12 @@ static void indirect(void *obj, void *u_data, QGuestAllocator *t_alloc)
> g_assert_cmpint(capacity, ==, TEST_IMAGE_SIZE / 512);
>
> vq = qvirtqueue_setup(dev, t_alloc, 0);
> + qvirtqueue_pci_msix_setup(vpcidev, (QVirtQueuePCI *)vq, t_alloc, 1);
> +
> qvirtio_set_driver_ok(dev);
>
> + qvirtio_wait_queue_isr(qts, dev, vq, QVIRTIO_BLK_TIMEOUT_US);
> +
> /* Write request */
> req.type = VIRTIO_BLK_T_OUT;
> req.ioprio = 1;
> --
> 2.26.3
^ permalink raw reply [flat|nested] 14+ messages in thread
* [PATCH v2 5/6] tests/qtest/vhost-user-blk-test: Factorize vq setup code
2022-01-18 20:38 [PATCH v2 0/6] qtests/libqos: Allow PCI tests to be run with virt-machine Eric Auger
` (3 preceding siblings ...)
2022-01-18 20:38 ` [PATCH v2 4/6] tests/qtest/vhost-user-blk-test: Setup MSIx to avoid error on aarch64 Eric Auger
@ 2022-01-18 20:38 ` Eric Auger
2022-01-18 20:38 ` [PATCH v2 6/6] tests/qtest/libqos: Add generic pci host bridge in arm-virt machine Eric Auger
2022-02-05 1:43 ` [PATCH v2 0/6] qtests/libqos: Allow PCI tests to be run with virt-machine Michael S. Tsirkin
6 siblings, 0 replies; 14+ messages in thread
From: Eric Auger @ 2022-01-18 20:38 UTC (permalink / raw)
To: eric.auger.pro, eric.auger, thuth, pbonzini, lvivier, qemu-arm,
qemu-devel, peter.maydell, mst, david, clg, eesposit
Cc: jean-philippe
The vq setup code is repeated several times and can be
easily factorized.
Signed-off-by: Eric Auger <eric.auger@redhat.com>
Reviewed-by: Thomas Huth <thuth@redhat.com>
---
tests/qtest/vhost-user-blk-test.c | 33 +++++++++++++++----------------
1 file changed, 16 insertions(+), 17 deletions(-)
diff --git a/tests/qtest/vhost-user-blk-test.c b/tests/qtest/vhost-user-blk-test.c
index 2606428df3..9567f3dc42 100644
--- a/tests/qtest/vhost-user-blk-test.c
+++ b/tests/qtest/vhost-user-blk-test.c
@@ -211,6 +211,19 @@ static void test_invalid_discard_write_zeroes(QVirtioDevice *dev,
guest_free(alloc, req_addr);
}
+static QVirtQueue *setup_vq(QVirtioDevice *dev, QGuestAllocator *alloc)
+{
+ QVirtioPCIDevice *vpcidev = container_of(dev, QVirtioPCIDevice, vdev);
+ QVirtQueue *vq;
+
+ qpci_msix_enable(vpcidev->pdev);
+ qvirtio_pci_set_msix_configuration_vector(vpcidev, alloc, 0);
+
+ vq = qvirtqueue_setup(dev, alloc, 0);
+ qvirtqueue_pci_msix_setup(vpcidev, (QVirtQueuePCI *)vq, alloc, 1);
+ return vq;
+}
+
/* Returns the request virtqueue so the caller can perform further tests */
static QVirtQueue *test_basic(QVirtioDevice *dev, QGuestAllocator *alloc)
{
@@ -223,10 +236,6 @@ static QVirtQueue *test_basic(QVirtioDevice *dev, QGuestAllocator *alloc)
char *data;
QTestState *qts = global_qtest;
QVirtQueue *vq;
- QVirtioPCIDevice *vpcidev = container_of(dev, QVirtioPCIDevice, vdev);
-
- qpci_msix_enable(vpcidev->pdev);
- qvirtio_pci_set_msix_configuration_vector(vpcidev, alloc, 0);
features = qvirtio_get_features(dev);
features = features & ~(QVIRTIO_F_BAD_FEATURE |
@@ -238,8 +247,7 @@ static QVirtQueue *test_basic(QVirtioDevice *dev, QGuestAllocator *alloc)
capacity = qvirtio_config_readq(dev, 0);
g_assert_cmpint(capacity, ==, TEST_IMAGE_SIZE / 512);
- vq = qvirtqueue_setup(dev, alloc, 0);
- qvirtqueue_pci_msix_setup(vpcidev, (QVirtQueuePCI *)vq, alloc, 1);
+ vq = setup_vq(dev, alloc);
qvirtio_set_driver_ok(dev);
@@ -474,10 +482,6 @@ static void indirect(void *obj, void *u_data, QGuestAllocator *t_alloc)
uint8_t status;
char *data;
QTestState *qts = global_qtest;
- QVirtioPCIDevice *vpcidev = container_of(dev, QVirtioPCIDevice, vdev);
-
- qpci_msix_enable(vpcidev->pdev);
- qvirtio_pci_set_msix_configuration_vector(vpcidev, t_alloc, 0);
features = qvirtio_get_features(dev);
g_assert_cmphex(features & (1u << VIRTIO_RING_F_INDIRECT_DESC), !=, 0);
@@ -489,8 +493,7 @@ static void indirect(void *obj, void *u_data, QGuestAllocator *t_alloc)
capacity = qvirtio_config_readq(dev, 0);
g_assert_cmpint(capacity, ==, TEST_IMAGE_SIZE / 512);
- vq = qvirtqueue_setup(dev, t_alloc, 0);
- qvirtqueue_pci_msix_setup(vpcidev, (QVirtQueuePCI *)vq, t_alloc, 1);
+ vq = setup_vq(dev, t_alloc);
qvirtio_set_driver_ok(dev);
@@ -576,9 +579,6 @@ static void idx(void *obj, void *u_data, QGuestAllocator *t_alloc)
return;
}
- qpci_msix_enable(pdev->pdev);
- qvirtio_pci_set_msix_configuration_vector(pdev, t_alloc, 0);
-
features = qvirtio_get_features(dev);
features = features & ~(QVIRTIO_F_BAD_FEATURE |
(1u << VIRTIO_RING_F_INDIRECT_DESC) |
@@ -589,8 +589,7 @@ static void idx(void *obj, void *u_data, QGuestAllocator *t_alloc)
capacity = qvirtio_config_readq(dev, 0);
g_assert_cmpint(capacity, ==, TEST_IMAGE_SIZE / 512);
- vq = qvirtqueue_setup(dev, t_alloc, 0);
- qvirtqueue_pci_msix_setup(pdev, (QVirtQueuePCI *)vq, t_alloc, 1);
+ vq = setup_vq(dev, t_alloc);
qvirtio_set_driver_ok(dev);
--
2.26.3
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH v2 6/6] tests/qtest/libqos: Add generic pci host bridge in arm-virt machine
2022-01-18 20:38 [PATCH v2 0/6] qtests/libqos: Allow PCI tests to be run with virt-machine Eric Auger
` (4 preceding siblings ...)
2022-01-18 20:38 ` [PATCH v2 5/6] tests/qtest/vhost-user-blk-test: Factorize vq setup code Eric Auger
@ 2022-01-18 20:38 ` Eric Auger
2022-01-19 9:08 ` Paolo Bonzini
2022-02-05 1:43 ` [PATCH v2 0/6] qtests/libqos: Allow PCI tests to be run with virt-machine Michael S. Tsirkin
6 siblings, 1 reply; 14+ messages in thread
From: Eric Auger @ 2022-01-18 20:38 UTC (permalink / raw)
To: eric.auger.pro, eric.auger, thuth, pbonzini, lvivier, qemu-arm,
qemu-devel, peter.maydell, mst, david, clg, eesposit
Cc: jean-philippe
Up to now the virt-machine node contains a virtio-mmio node.
However no driver produces any PCI interface node. Hence, PCI
tests cannot be run with aarch64 binary.
Add a GPEX driver node that produces a pci interface node. This latter
then can be consumed by all the pci tests. One of the first motivation
was to be able to run the virtio-iommu-pci tests.
We still face an issue with pci hotplug tests as hotplug cannot happen
on the pcie root bus and require a generic root port. This will be
addressed later on.
Signed-off-by: Eric Auger <eric.auger@redhat.com>
---
v1 -> v2:
- copyright updated to 2022
- QPCIBusARM renamed into QGenericPCIBus
- QGenericPCIHost declarations and definitions moved in the same
place as the generic pci implementation
- rename pci-arm.c/h in generic-pcihost.c/h and remove any ref to
ARM there
- remove qos_node_produces_opts, qpci_new_arm, qpci_free_arm
- ecam_alloc_ptr now is a field of QGenericPCIBus and not QPCIBus
- new libqos_init to create generic-pcihost driver that contains
pci-bus-generic
- QGenericPCIHost moved in the same place as the generic pci
bindings
---
tests/qtest/libqos/arm-virt-machine.c | 18 +-
tests/qtest/libqos/generic-pcihost.c | 231 ++++++++++++++++++++++++++
tests/qtest/libqos/generic-pcihost.h | 54 ++++++
tests/qtest/libqos/meson.build | 1 +
4 files changed, 300 insertions(+), 4 deletions(-)
create mode 100644 tests/qtest/libqos/generic-pcihost.c
create mode 100644 tests/qtest/libqos/generic-pcihost.h
diff --git a/tests/qtest/libqos/arm-virt-machine.c b/tests/qtest/libqos/arm-virt-machine.c
index e0f5932284..a2cc1790b5 100644
--- a/tests/qtest/libqos/arm-virt-machine.c
+++ b/tests/qtest/libqos/arm-virt-machine.c
@@ -22,6 +22,8 @@
#include "malloc.h"
#include "qgraph.h"
#include "virtio-mmio.h"
+#include "generic-pcihost.h"
+#include "hw/pci/pci_regs.h"
#define ARM_PAGE_SIZE 4096
#define VIRTIO_MMIO_BASE_ADDR 0x0A003E00
@@ -35,6 +37,7 @@ struct QVirtMachine {
QOSGraphObject obj;
QGuestAllocator alloc;
QVirtioMMIODevice virtio_mmio;
+ QGenericPCIHost bridge;
};
static void virt_destructor(QOSGraphObject *obj)
@@ -57,11 +60,13 @@ static void *virt_get_driver(void *object, const char *interface)
static QOSGraphObject *virt_get_device(void *obj, const char *device)
{
QVirtMachine *machine = obj;
- if (!g_strcmp0(device, "virtio-mmio")) {
+ if (!g_strcmp0(device, "generic-pcihost")) {
+ return &machine->bridge.obj;
+ } else if (!g_strcmp0(device, "virtio-mmio")) {
return &machine->virtio_mmio.obj;
}
- fprintf(stderr, "%s not present in arm/virtio\n", device);
+ fprintf(stderr, "%s not present in arm/virt\n", device);
g_assert_not_reached();
}
@@ -76,16 +81,21 @@ static void *qos_create_machine_arm_virt(QTestState *qts)
qvirtio_mmio_init_device(&machine->virtio_mmio, qts, VIRTIO_MMIO_BASE_ADDR,
VIRTIO_MMIO_SIZE);
+ qos_create_generic_pcihost(&machine->bridge, qts, &machine->alloc);
+
machine->obj.get_device = virt_get_device;
machine->obj.get_driver = virt_get_driver;
machine->obj.destructor = virt_destructor;
return machine;
}
-static void virtio_mmio_register_nodes(void)
+static void virt_machine_register_nodes(void)
{
qos_node_create_machine("arm/virt", qos_create_machine_arm_virt);
qos_node_contains("arm/virt", "virtio-mmio", NULL);
+
+ qos_node_create_machine("aarch64/virt", qos_create_machine_arm_virt);
+ qos_node_contains("aarch64/virt", "generic-pcihost", NULL);
}
-libqos_init(virtio_mmio_register_nodes);
+libqos_init(virt_machine_register_nodes);
diff --git a/tests/qtest/libqos/generic-pcihost.c b/tests/qtest/libqos/generic-pcihost.c
new file mode 100644
index 0000000000..704bbc3473
--- /dev/null
+++ b/tests/qtest/libqos/generic-pcihost.c
@@ -0,0 +1,231 @@
+/*
+ * libqos PCI bindings for generic PCI
+ *
+ * Copyright Red Hat Inc., 2022
+ *
+ * Authors:
+ * Eric Auger <eric.auger@redhat.com>
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
+ * See the COPYING file in the top-level directory.
+ */
+
+#include "qemu/osdep.h"
+#include "libqtest.h"
+#include "generic-pcihost.h"
+#include "qapi/qmp/qdict.h"
+#include "hw/pci/pci_regs.h"
+
+#include "qemu/module.h"
+
+/* QGenericPCIHost */
+
+QOSGraphObject *generic_pcihost_get_device(void *obj, const char *device)
+{
+ QGenericPCIHost *host = obj;
+ if (!g_strcmp0(device, "pci-bus-generic")) {
+ return &host->pci.obj;
+ }
+ fprintf(stderr, "%s not present in generic-pcihost\n", device);
+ g_assert_not_reached();
+}
+
+void qos_create_generic_pcihost(QGenericPCIHost *host,
+ QTestState *qts,
+ QGuestAllocator *alloc)
+{
+ host->obj.get_device = generic_pcihost_get_device;
+ qpci_init_generic(&host->pci, qts, alloc, false);
+}
+
+static uint8_t qpci_generic_pio_readb(QPCIBus *bus, uint32_t addr)
+{
+ QGenericPCIBus *s = container_of(bus, QGenericPCIBus, bus);
+
+ return qtest_readb(bus->qts, s->gpex_pio_base + addr);
+}
+
+static void qpci_generic_pio_writeb(QPCIBus *bus, uint32_t addr, uint8_t val)
+{
+ QGenericPCIBus *s = container_of(bus, QGenericPCIBus, bus);
+
+ qtest_writeb(bus->qts, s->gpex_pio_base + addr, val);
+}
+
+static uint16_t qpci_generic_pio_readw(QPCIBus *bus, uint32_t addr)
+{
+ QGenericPCIBus *s = container_of(bus, QGenericPCIBus, bus);
+
+ return qtest_readw(bus->qts, s->gpex_pio_base + addr);
+}
+
+static void qpci_generic_pio_writew(QPCIBus *bus, uint32_t addr, uint16_t val)
+{
+ QGenericPCIBus *s = container_of(bus, QGenericPCIBus, bus);
+
+ qtest_writew(bus->qts, s->gpex_pio_base + addr, val);
+}
+
+static uint32_t qpci_generic_pio_readl(QPCIBus *bus, uint32_t addr)
+{
+ QGenericPCIBus *s = container_of(bus, QGenericPCIBus, bus);
+
+ return qtest_readl(bus->qts, s->gpex_pio_base + addr);
+}
+
+static void qpci_generic_pio_writel(QPCIBus *bus, uint32_t addr, uint32_t val)
+{
+ QGenericPCIBus *s = container_of(bus, QGenericPCIBus, bus);
+
+ qtest_writel(bus->qts, s->gpex_pio_base + addr, val);
+}
+
+static uint64_t qpci_generic_pio_readq(QPCIBus *bus, uint32_t addr)
+{
+ QGenericPCIBus *s = container_of(bus, QGenericPCIBus, bus);
+
+ return qtest_readq(bus->qts, s->gpex_pio_base + addr);
+}
+
+static void qpci_generic_pio_writeq(QPCIBus *bus, uint32_t addr, uint64_t val)
+{
+ QGenericPCIBus *s = container_of(bus, QGenericPCIBus, bus);
+
+ qtest_writeq(bus->qts, s->gpex_pio_base + addr, val);
+}
+
+static void qpci_generic_memread(QPCIBus *bus, uint32_t addr, void *buf, size_t len)
+{
+ qtest_memread(bus->qts, addr, buf, len);
+}
+
+static void qpci_generic_memwrite(QPCIBus *bus, uint32_t addr,
+ const void *buf, size_t len)
+{
+ qtest_memwrite(bus->qts, addr, buf, len);
+}
+
+static uint8_t qpci_generic_config_readb(QPCIBus *bus, int devfn, uint8_t offset)
+{
+ QGenericPCIBus *gbus = container_of(bus, QGenericPCIBus, bus);
+ uint64_t addr = gbus->ecam_alloc_ptr + ((0 << 20) | (devfn << 12) | offset);
+ uint8_t val;
+
+ qtest_memread(bus->qts, addr, &val, 1);
+ return val;
+}
+
+static uint16_t qpci_generic_config_readw(QPCIBus *bus, int devfn, uint8_t offset)
+{
+ QGenericPCIBus *gbus = container_of(bus, QGenericPCIBus, bus);
+ uint64_t addr = gbus->ecam_alloc_ptr + ((0 << 20) | (devfn << 12) | offset);
+ uint16_t val;
+
+ qtest_memread(bus->qts, addr, &val, 2);
+ return val;
+}
+
+static uint32_t qpci_generic_config_readl(QPCIBus *bus, int devfn, uint8_t offset)
+{
+ QGenericPCIBus *gbus = container_of(bus, QGenericPCIBus, bus);
+ uint64_t addr = gbus->ecam_alloc_ptr + ((0 << 20) | (devfn << 12) | offset);
+ uint32_t val;
+
+ qtest_memread(bus->qts, addr, &val, 4);
+ return val;
+}
+
+static void
+qpci_generic_config_writeb(QPCIBus *bus, int devfn, uint8_t offset, uint8_t value)
+{
+ QGenericPCIBus *gbus = container_of(bus, QGenericPCIBus, bus);
+ uint64_t addr = gbus->ecam_alloc_ptr + ((0 << 20) | (devfn << 12) | offset);
+ uint32_t val = value;
+
+ qtest_memwrite(bus->qts, addr, &val, 1);
+}
+
+static void
+qpci_generic_config_writew(QPCIBus *bus, int devfn, uint8_t offset, uint16_t value)
+{
+ QGenericPCIBus *gbus = container_of(bus, QGenericPCIBus, bus);
+ uint64_t addr = gbus->ecam_alloc_ptr + ((0 << 20) | (devfn << 12) | offset);
+ uint32_t val = value;
+
+ qtest_memwrite(bus->qts, addr, &val, 2);
+}
+
+static void
+qpci_generic_config_writel(QPCIBus *bus, int devfn, uint8_t offset, uint32_t value)
+{
+ QGenericPCIBus *gbus = container_of(bus, QGenericPCIBus, bus);
+ uint64_t addr = gbus->ecam_alloc_ptr + ((0 << 20) | (devfn << 12) | offset);
+ uint32_t val = value;
+
+ qtest_memwrite(bus->qts, addr, &val, 4);
+}
+
+static void *qpci_generic_get_driver(void *obj, const char *interface)
+{
+ QGenericPCIBus *qpci = obj;
+ if (!g_strcmp0(interface, "pci-bus")) {
+ return &qpci->bus;
+ }
+ fprintf(stderr, "%s not present in pci-bus-generic\n", interface);
+ g_assert_not_reached();
+}
+
+void qpci_init_generic(QGenericPCIBus *qpci, QTestState *qts,
+ QGuestAllocator *alloc, bool hotpluggable)
+{
+ assert(qts);
+
+ qpci->gpex_pio_base = 0x3eff0000;
+ qpci->bus.not_hotpluggable = !hotpluggable;
+ qpci->bus.has_buggy_msi = false;
+
+ qpci->bus.pio_readb = qpci_generic_pio_readb;
+ qpci->bus.pio_readw = qpci_generic_pio_readw;
+ qpci->bus.pio_readl = qpci_generic_pio_readl;
+ qpci->bus.pio_readq = qpci_generic_pio_readq;
+
+ qpci->bus.pio_writeb = qpci_generic_pio_writeb;
+ qpci->bus.pio_writew = qpci_generic_pio_writew;
+ qpci->bus.pio_writel = qpci_generic_pio_writel;
+ qpci->bus.pio_writeq = qpci_generic_pio_writeq;
+
+ qpci->bus.memread = qpci_generic_memread;
+ qpci->bus.memwrite = qpci_generic_memwrite;
+
+ qpci->bus.config_readb = qpci_generic_config_readb;
+ qpci->bus.config_readw = qpci_generic_config_readw;
+ qpci->bus.config_readl = qpci_generic_config_readl;
+
+ qpci->bus.config_writeb = qpci_generic_config_writeb;
+ qpci->bus.config_writew = qpci_generic_config_writew;
+ qpci->bus.config_writel = qpci_generic_config_writel;
+
+ qpci->bus.qts = qts;
+ qpci->bus.pio_alloc_ptr = 0x0000;
+ qpci->bus.pio_limit = 0x10000;
+ qpci->bus.mmio_alloc_ptr = 0x10000000;
+ qpci->bus.mmio_limit = 0x2eff0000;
+ qpci->ecam_alloc_ptr = 0x4010000000;
+
+ qpci->obj.get_driver = qpci_generic_get_driver;
+}
+
+static void qpci_generic_register_nodes(void)
+{
+ qos_node_create_driver("pci-bus-generic", NULL);
+ qos_node_produces("pci-bus-generic", "pci-bus");
+}
+
+static void qpci_generic_pci_register_nodes(void)
+{
+ qos_node_create_driver("generic-pcihost", NULL);
+ qos_node_contains("generic-pcihost", "pci-bus-generic", NULL);
+}
+
+libqos_init(qpci_generic_register_nodes);
+libqos_init(qpci_generic_pci_register_nodes);
diff --git a/tests/qtest/libqos/generic-pcihost.h b/tests/qtest/libqos/generic-pcihost.h
new file mode 100644
index 0000000000..c693c769df
--- /dev/null
+++ b/tests/qtest/libqos/generic-pcihost.h
@@ -0,0 +1,54 @@
+/*
+ * libqos Generic PCI bindings and generic pci host bridge
+ *
+ * Copyright Red Hat Inc., 2022
+ *
+ * Authors:
+ * Eric Auger <eric.auger@redhat.com>
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
+ * See the COPYING file in the top-level directory.
+ */
+
+#ifndef LIBQOS_GENERIC_PCIHOST_H
+#define LIBQOS_GENERIC_PCIHOST_H
+
+#include "pci.h"
+#include "malloc.h"
+#include "qgraph.h"
+
+typedef struct QGenericPCIBus {
+ QOSGraphObject obj;
+ QPCIBus bus;
+ uint64_t gpex_pio_base;
+ uint64_t ecam_alloc_ptr;
+} QGenericPCIBus;
+
+/*
+ * qpci_init_generic():
+ * @ret: A valid QGenericPCIBus * pointer
+ * @qts: The %QTestState
+ * @alloc: A previously initialized @alloc providing memory for @qts
+ * @bool: devices can be hotplugged on this bus
+ *
+ * This function initializes an already allocated
+ * QGenericPCIBus object.
+ */
+void qpci_init_generic(QGenericPCIBus *ret, QTestState *qts,
+ QGuestAllocator *alloc, bool hotpluggable);
+
+/* QGenericPCIHost */
+
+typedef struct QGenericPCIHost QGenericPCIHost;
+
+struct QGenericPCIHost {
+ QOSGraphObject obj;
+ QGenericPCIBus pci;
+};
+
+QOSGraphObject *generic_pcihost_get_device(void *obj, const char *device);
+void qos_create_generic_pcihost(QGenericPCIHost *host,
+ QTestState *qts,
+ QGuestAllocator *alloc);
+
+#endif
diff --git a/tests/qtest/libqos/meson.build b/tests/qtest/libqos/meson.build
index e988d15791..8c8ee15553 100644
--- a/tests/qtest/libqos/meson.build
+++ b/tests/qtest/libqos/meson.build
@@ -42,6 +42,7 @@ libqos_srcs = files('../libqtest.c',
'virtio-scsi.c',
'virtio-serial.c',
'virtio-iommu.c',
+ 'generic-pcihost.c',
# qgraph machines:
'aarch64-xlnx-zcu102-machine.c',
--
2.26.3
^ permalink raw reply related [flat|nested] 14+ messages in thread
* Re: [PATCH v2 6/6] tests/qtest/libqos: Add generic pci host bridge in arm-virt machine
2022-01-18 20:38 ` [PATCH v2 6/6] tests/qtest/libqos: Add generic pci host bridge in arm-virt machine Eric Auger
@ 2022-01-19 9:08 ` Paolo Bonzini
0 siblings, 0 replies; 14+ messages in thread
From: Paolo Bonzini @ 2022-01-19 9:08 UTC (permalink / raw)
To: Eric Auger, eric.auger.pro, thuth, lvivier, qemu-arm, qemu-devel,
peter.maydell, mst, david, clg, eesposit
Cc: jean-philippe
On 1/18/22 21:38, Eric Auger wrote:
> +
> +typedef struct QGenericPCIBus {
> + QOSGraphObject obj;
> + QPCIBus bus;
> + uint64_t gpex_pio_base;
> + uint64_t ecam_alloc_ptr;
> +} QGenericPCIBus;
> +
> +/*
> + * qpci_init_generic():
> + * @ret: A valid QGenericPCIBus * pointer
> + * @qts: The %QTestState
> + * @alloc: A previously initialized @alloc providing memory for @qts
> + * @bool: devices can be hotplugged on this bus
> + *
> + * This function initializes an already allocated
> + * QGenericPCIBus object.
> + */
> +void qpci_init_generic(QGenericPCIBus *ret, QTestState *qts,
> + QGuestAllocator *alloc, bool hotpluggable);
> +
> +/* QGenericPCIHost */
> +
> +typedef struct QGenericPCIHost QGenericPCIHost;
> +
> +struct QGenericPCIHost {
> + QOSGraphObject obj;
> + QGenericPCIBus pci;
> +};
> +
> +QOSGraphObject *generic_pcihost_get_device(void *obj, const char *device);
> +void qos_create_generic_pcihost(QGenericPCIHost *host,
> + QTestState *qts,
> + QGuestAllocator *alloc);
> +
> +#endif
Ok, now I understand why you had it in arm-virt-machine.c in v1 (the
hard-coded addresses). :) But it's okay this way too, since you keep
the maybe I'll get to generalize it a bit later.
Paolo
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH v2 0/6] qtests/libqos: Allow PCI tests to be run with virt-machine
2022-01-18 20:38 [PATCH v2 0/6] qtests/libqos: Allow PCI tests to be run with virt-machine Eric Auger
` (5 preceding siblings ...)
2022-01-18 20:38 ` [PATCH v2 6/6] tests/qtest/libqos: Add generic pci host bridge in arm-virt machine Eric Auger
@ 2022-02-05 1:43 ` Michael S. Tsirkin
2022-02-07 21:59 ` Eric Auger
6 siblings, 1 reply; 14+ messages in thread
From: Michael S. Tsirkin @ 2022-02-05 1:43 UTC (permalink / raw)
To: Eric Auger
Cc: lvivier, peter.maydell, thuth, jean-philippe, eesposit,
qemu-devel, qemu-arm, clg, pbonzini, david, eric.auger.pro
On Tue, Jan 18, 2022 at 09:38:27PM +0100, Eric Auger wrote:
> Up to now the virt-machine node only contains a virtio-mmio
> driver node but no driver that eventually produces any pci-bus
> interface.
>
> Hence, PCI libqos tests cannot be run with aarch64 binary.
>
> This series brings the pieces needed to be able to run PCI tests
> with the aarch64 binary: a generic-pcihost driver node gets
> instantiated by the machine. This later contains a pci-bus-generic
> driver which produces a pci-bus interface. Then all tests
> consuming the pci-bus interface can be run with the libqos arm
> virt machine.
>
> One of the first goal was to be able to run the virtio-iommu-pci
> tests as the virtio-iommu was initially targetting ARM and it
> was awkard to be run the test with the pc machine. This is now
> possible.
>
> Only the tests doing hotplug cannot be run yet as hotplug is
> not possible on the root bus. This will be dealt with separately
> by adding a root port to the object tree.
>
> Best Regards
>
> Eric
>
> This series can be found at:
> https://github.com/eauger/qemu/tree/libqos-pci-arm-v2
>
> History
I dropped this due to make check failures. Pls make sure
to make and test all targets. Thanks!
> v1 -> v2:
> - copyright updated to 2022
> - QPCIBusARM renamed into QGenericPCIBus
> - QGenericPCIHost declarations and definitions moved in the same
> place as the generic pci implementation
> - rename pci-arm.c/h in generic-pcihost.c/h and remove any ref to
> ARM there
> - remove qos_node_produces_opts, qpci_new_arm, qpci_free_arm
> - ecam_alloc_ptr now is a field of QGenericPCIBus and not QPCIBus
> - new libqos_init to create generic-pcihost driver that contains
> pci-bus-generic
> - QGenericPCIHost moved in the same place as the generic pci
> bindings
> - collected Thomas A-b/R-b
>
>
> Eric Auger (6):
> tests/qtest/vhost-user-test.c: Use vhostforce=on
> tests/qtest/libqos/pci: Introduce pio_limit
> tests/qtest/libqos: Skip hotplug tests if pci root bus is not
> hotpluggable
> tests/qtest/vhost-user-blk-test: Setup MSIx to avoid error on aarch64
> tests/qtest/vhost-user-blk-test: Factorize vq setup code
> tests/qtest/libqos: Add generic pci host bridge in arm-virt machine
>
> tests/qtest/e1000e-test.c | 6 +
> tests/qtest/libqos/arm-virt-machine.c | 18 +-
> tests/qtest/libqos/generic-pcihost.c | 231 ++++++++++++++++++++++++++
> tests/qtest/libqos/generic-pcihost.h | 54 ++++++
> tests/qtest/libqos/meson.build | 1 +
> tests/qtest/libqos/pci-pc.c | 1 +
> tests/qtest/libqos/pci-spapr.c | 1 +
> tests/qtest/libqos/pci.c | 78 +++++----
> tests/qtest/libqos/pci.h | 6 +-
> tests/qtest/vhost-user-blk-test.c | 39 ++++-
> tests/qtest/vhost-user-test.c | 2 +-
> tests/qtest/virtio-blk-test.c | 5 +
> tests/qtest/virtio-net-test.c | 5 +
> tests/qtest/virtio-rng-test.c | 5 +
> 14 files changed, 408 insertions(+), 44 deletions(-)
> create mode 100644 tests/qtest/libqos/generic-pcihost.c
> create mode 100644 tests/qtest/libqos/generic-pcihost.h
>
> --
> 2.26.3
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH v2 0/6] qtests/libqos: Allow PCI tests to be run with virt-machine
2022-02-05 1:43 ` [PATCH v2 0/6] qtests/libqos: Allow PCI tests to be run with virt-machine Michael S. Tsirkin
@ 2022-02-07 21:59 ` Eric Auger
0 siblings, 0 replies; 14+ messages in thread
From: Eric Auger @ 2022-02-07 21:59 UTC (permalink / raw)
To: Michael S. Tsirkin
Cc: lvivier, peter.maydell, thuth, jean-philippe, eesposit,
qemu-devel, qemu-arm, clg, pbonzini, david, eric.auger.pro
Hi Michael,
On 2/5/22 2:43 AM, Michael S. Tsirkin wrote:
> On Tue, Jan 18, 2022 at 09:38:27PM +0100, Eric Auger wrote:
>> Up to now the virt-machine node only contains a virtio-mmio
>> driver node but no driver that eventually produces any pci-bus
>> interface.
>>
>> Hence, PCI libqos tests cannot be run with aarch64 binary.
>>
>> This series brings the pieces needed to be able to run PCI tests
>> with the aarch64 binary: a generic-pcihost driver node gets
>> instantiated by the machine. This later contains a pci-bus-generic
>> driver which produces a pci-bus interface. Then all tests
>> consuming the pci-bus interface can be run with the libqos arm
>> virt machine.
>>
>> One of the first goal was to be able to run the virtio-iommu-pci
>> tests as the virtio-iommu was initially targetting ARM and it
>> was awkard to be run the test with the pc machine. This is now
>> possible.
>>
>> Only the tests doing hotplug cannot be run yet as hotplug is
>> not possible on the root bus. This will be dealt with separately
>> by adding a root port to the object tree.
>>
>> Best Regards
>>
>> Eric
>>
>> This series can be found at:
>> https://github.com/eauger/qemu/tree/libqos-pci-arm-v2
>>
>> History
>
> I dropped this due to make check failures. Pls make sure
> to make and test all targets. Thanks!
Sorry for the inconvenience.
qos-test now is failing on aarch64 and definitively it was passing when
I submitted the patches (ie. with above branch).
I bisected and d9afe24c29a0 ("hw/arm/virt: Disable highmem devices that
don't fit in the PA range") recenly applied upstream changed the way the
test behave and now is causing
/aarch64/virt/generic-pcihost/pci-bus-generic/pci-bus/megasas/megasas-tests/dcmd/pd-get-info/fuzz
to fail.
This is due to the fact GPA is limited to 32b and the device seems to
require high ECAM. I will fix that.
Thanks
Eric
>
>> v1 -> v2:
>> - copyright updated to 2022
>> - QPCIBusARM renamed into QGenericPCIBus
>> - QGenericPCIHost declarations and definitions moved in the same
>> place as the generic pci implementation
>> - rename pci-arm.c/h in generic-pcihost.c/h and remove any ref to
>> ARM there
>> - remove qos_node_produces_opts, qpci_new_arm, qpci_free_arm
>> - ecam_alloc_ptr now is a field of QGenericPCIBus and not QPCIBus
>> - new libqos_init to create generic-pcihost driver that contains
>> pci-bus-generic
>> - QGenericPCIHost moved in the same place as the generic pci
>> bindings
>> - collected Thomas A-b/R-b
>>
>>
>> Eric Auger (6):
>> tests/qtest/vhost-user-test.c: Use vhostforce=on
>> tests/qtest/libqos/pci: Introduce pio_limit
>> tests/qtest/libqos: Skip hotplug tests if pci root bus is not
>> hotpluggable
>> tests/qtest/vhost-user-blk-test: Setup MSIx to avoid error on aarch64
>> tests/qtest/vhost-user-blk-test: Factorize vq setup code
>> tests/qtest/libqos: Add generic pci host bridge in arm-virt machine
>>
>> tests/qtest/e1000e-test.c | 6 +
>> tests/qtest/libqos/arm-virt-machine.c | 18 +-
>> tests/qtest/libqos/generic-pcihost.c | 231 ++++++++++++++++++++++++++
>> tests/qtest/libqos/generic-pcihost.h | 54 ++++++
>> tests/qtest/libqos/meson.build | 1 +
>> tests/qtest/libqos/pci-pc.c | 1 +
>> tests/qtest/libqos/pci-spapr.c | 1 +
>> tests/qtest/libqos/pci.c | 78 +++++----
>> tests/qtest/libqos/pci.h | 6 +-
>> tests/qtest/vhost-user-blk-test.c | 39 ++++-
>> tests/qtest/vhost-user-test.c | 2 +-
>> tests/qtest/virtio-blk-test.c | 5 +
>> tests/qtest/virtio-net-test.c | 5 +
>> tests/qtest/virtio-rng-test.c | 5 +
>> 14 files changed, 408 insertions(+), 44 deletions(-)
>> create mode 100644 tests/qtest/libqos/generic-pcihost.c
>> create mode 100644 tests/qtest/libqos/generic-pcihost.h
>>
>> --
>> 2.26.3
^ permalink raw reply [flat|nested] 14+ messages in thread