qtests/libqos: Allow PCI tests to be run with virt-machine
v2 cover qtests/libqos: Allow PCI tests to be run with virt-machine
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
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
Signature · 1 line
2.26.3
PATCH v2 1/6 tests/qtest/vhost-user-test.c: Use vhostforce=on
-netdev vhost-user,vhostforce is deprecated and vhostforce=on should be used instead.
--- tests/qtest/vhost-user-test.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tests/qtest/vhost-user-test.c +1 -1
@@ -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
Signature · 1 line
2.26.3
PATCH v2 5/6 tests/qtest/vhost-user-blk-test: Factorize vq setup code
In reply to Eric AugerThe vq setup code is repeated several times and can be easily factorized.
--- tests/qtest/vhost-user-blk-test.c | 33 +++++++++++++++---------------- 1 file changed, 16 insertions(+), 17 deletions(-)
tests/qtest/vhost-user-blk-test.c +16 -17
@@ -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);
Signature · 1 line
2.26.3
PATCH v2 2/6 tests/qtest/libqos/pci: Introduce pio_limit
In reply to Eric AugerAt 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.
--- 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(-)
tests/qtest/libqos/pci-pc.c +1 -0
@@ -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 ;
tests/qtest/libqos/pci-spapr.c +1 -0
@@ -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;
tests/qtest/libqos/pci.c +50 -28
173 lines not on this page · raw message
tests/qtest/libqos/pci.h +2 -3
@@ -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
Signature · 1 line
2.26.3
PATCH v2 6/6 tests/qtest/libqos: Add generic pci host bridge in arm-virt machine
In reply to Eric AugerUp 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.
---
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
tests/qtest/libqos/arm-virt-machine.c +14 -4
@@ -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);
tests/qtest/libqos/generic-pcihost.c new file +231 -0
231 lines not on this page · raw message
tests/qtest/libqos/generic-pcihost.h new file +54 -0
54 lines not on this page · raw message
tests/qtest/libqos/meson.build +1 -0
@@ -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',
Signature · 1 line
2.26.3
PATCH v2 3/6 tests/qtest/libqos: Skip hotplug tests if pci root bus is not hotpluggable
In reply to Eric AugerARM 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.
---
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(+)
tests/qtest/e1000e-test.c +6 -0
@@ -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 );
tests/qtest/libqos/pci.h +1 -0
@@ -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 */ };
tests/qtest/vhost-user-blk-test.c +10 -0
@@ -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
tests/qtest/virtio-blk-test.c +5 -0
@@ -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'}",
tests/qtest/virtio-net-test.c +5 -0
@@ -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 ));
tests/qtest/virtio-rng-test.c +5 -0
@@ -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",
Signature · 1 line
2.26.3
PATCH v2 4/6 tests/qtest/vhost-user-blk-test: Setup MSIx to avoid error on aarch64
In reply to Eric AugerWhen 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.
--- tests/qtest/vhost-user-blk-test.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-)
tests/qtest/vhost-user-blk-test.c +15 -1
@@ -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 ;
Signature · 1 line
2.26.3
Re: [PATCH v2 6/6] tests/qtest/libqos: Add generic pci host bridge in arm-virt machine
In reply to Eric AugerQuoted 26 lines · Eric Auger
tests/qtest/libqos/generic-pcihost.h new file +26
-0+ +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 {
tests/qtest/libqos/generic-pcihost.h line 54
Quoted 10 lines
tests/qtest/libqos/generic-pcihost.h new file +10
-0+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
Re: [PATCH v2 1/6] tests/qtest/vhost-user-test.c: Use vhostforce=on
In reply to Eric AugerQuoted 5 lines · Eric Auger
-netdev vhost-user,vhostforce is deprecated and vhostforce=on should be used instead.
Signed-off-by Eric Auger <[email protected]>Reviewed-by Thomas Huth <[email protected]>
Signature · 1 line
Alex Bennée
Re: [PATCH v2 2/6] tests/qtest/libqos/pci: Introduce pio_limit
In reply to Eric AugerQuoted 9 lines · Eric Auger
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 at0x0.
Quoted 7 lines
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 <[email protected]>Reviewed-by Thomas Huth <[email protected]>
Signature · 1 line
Alex Bennée
Re: [PATCH v2 3/6] tests/qtest/libqos: Skip hotplug tests if pci root bus is not hotpluggable
In reply to Eric AugerQuoted 7 lines · Eric Auger
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 <[email protected]>Acked-by Thomas Huth <[email protected]>
Signature · 1 line
Alex Bennée
Re: [PATCH v2 4/6] tests/qtest/vhost-user-blk-test: Setup MSIx to avoid error on aarch64
In reply to Eric AugerQuoted 8 lines · Eric Auger
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)
Quoted 6 lines
Setting up and enabling MSIX fixes the issue.
Also remove the useless
libqos/libqos-pc.hheader inclusion.Signed-off-by Eric Auger <[email protected]>Acked-by Thomas Huth <[email protected]>
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
Quoted 66 lines
--- tests/qtest/vhost-user-blk-test.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-)tests/qtest/vhost-user-blk-test.c +15
-1@@ -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 ;Signature · 1 line
2.26.3
Quoted 22 lines · Eric Auger
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.
Quoted 8 lines
Best Regards
Eric
This series can be found at:
https://github.com/eauger/qemu/tree/libqos-pci-arm-v2History
I dropped this due to make check failures. Pls make sure to make and test all targets. Thanks!
Quoted 45 lines
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
- removeqos_node_produces_opts,qpci_new_arm,qpci_free_arm
-ecam_alloc_ptrnow is a field of QGenericPCIBus and not QPCIBus
- newlibqos_initto 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-bEric Auger (6):
tests/qtest/vhost-user-test.c: Use vhostforce=on tests/qtest/libqos/pci: Introducepio_limittests/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 machinetests/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.hSignature · 1 line
2.26.3
Hi Michael,
Quoted 27 lines · Michael S. Tsirkin
Quoted 26 lines · Eric Auger
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
Quoted 7 lines
Quoted 4 lines
This series can be found at:
https://github.com/eauger/qemu/tree/libqos-pci-arm-v2History
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
Quoted 46 lines
Quoted 46 lines
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
- removeqos_node_produces_opts,qpci_new_arm,qpci_free_arm
-ecam_alloc_ptrnow is a field of QGenericPCIBus and not QPCIBus
- newlibqos_initto 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-bEric Auger (6):
tests/qtest/vhost-user-test.c: Use vhostforce=on tests/qtest/libqos/pci: Introducepio_limittests/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 machinetests/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.hSignature · 1 line
2.26.3