qtests/libqos: Allow PCI tests to be run with virt-machine
v6 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 run the tests 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-v6
History
v5 -> v6:
- change the libqtest.h header path after pull of
"tests: move libqtest.h back under qtest/"
v4 -> v5:
- Added Alex' R-b
- Removed [PATCH v3 4/5] tests/qtest/vhost-user-blk-test:
Temporary hack to get tests passing on aarch64 following Alex' fix
v3 -> v4:
- handle endianess when accessing the cfg space (fix PPC64 BE failure). Tested on such machine.
v2 -> v3:
- force -cpu=max along with aarch64/virt
- reduced the vhost-user-block-pci issue workaround to a single guest_alloc() instead of enabling MSIs. Call for help on this specific issue. The 2 tests which fail are:
test_basic and indirect.
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 (3):
tests/qtest/libqos/pci: Introduce pio_limit tests/qtest/libqos: Skip hotplug tests if pci root bus is not
hotpluggable
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 | 19 ++- 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 | 10 ++ tests/qtest/virtio-blk-test.c | 5 + tests/qtest/virtio-net-test.c | 5 + tests/qtest/virtio-rng-test.c | 5 + 13 files changed, 387 insertions(+), 35 deletions(-) create mode 100644 tests/qtest/libqos/generic-pcihost.c create mode 100644 tests/qtest/libqos/generic-pcihost.h
Signature · 1 line
2.35.1
PATCH v6 1/3 tests/qtest/libqos/pci: Introduce pio_limit
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.
--- 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.35.1
PATCH v6 2/3 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
@@ -233,6 +233,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
@@ -173,6 +173,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.35.1
PATCH v6 3/3 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.
We force cpu=max along with aarch64/virt machine as some PCI tests require high MMIO regions to be available.
---
v5 -> v6:
- change header path: #include "../libqtest.h"
v3 -> v4:
- properly handle le/cpu conversions on config access
v2 -> v3:
- force cpu=max with aarch64/virt
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 | 19 ++- tests/qtest/libqos/generic-pcihost.c | 231 ++++++++++++++++++++++++++ tests/qtest/libqos/generic-pcihost.h | 54 ++++++ tests/qtest/libqos/meson.build | 1 + 4 files changed, 301 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 +15 -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,22 @@ 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_args ("aarch64/virt" , qos_create_machine_arm_virt, +" -cpu max" ); +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
@@ -45,6 +45,7 @@ libqos_srcs = files( 'virtio-scsi.c', 'virtio-serial.c', 'virtio-iommu.c', + 'generic-pcihost.c', # qgraph machines: 'aarch64-xlnx-zcu102-machine.c',
Signature · 1 line
2.35.1
Re: [PATCH v6 3/3] tests/qtest/libqos: Add generic pci host bridge in arm-virt machine
Quoted 8 lines · Eric Auger
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.
Quoted 6 lines
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.
We force cpu=max along with aarch64/virt machine as some PCI tests require high MMIO regions to be available.
Where would I be able to force disable-legacy=off for the PCI device from? Building on this for GPIO I run into the following:
subprocess_run_one_test: /aarch64/virt/generic-pcihost/pci-bus-generic/pci-bus/vhost-user-gpio-pci/vhost-user-gpio/vhost-user-gpio-tests/read-guest-mem/memfile/subprocess
vhost_user_test_setup: -M virt, -cpu max -device vhost-user-gpio-pci,id=gpio0,addr=04.0,chardev=chr-vhost-user-test vu_gpio_get_protocol_features: 0x202
qemu-system-aarch64: -device vhost-user-gpio-pci,id=gpio0,addr=04.0,chardev=chr-vhost-user-test: Device doesn't support modern mode, and legacy mode is disabled Set disable-legacy to off
Broken pipe
and I think this needs to be applied to the root bus device?
Anyway otherwise it looks OK to me:
Signature · 1 line
Alex Bennée
Re: [PATCH v6 3/3] tests/qtest/libqos: Add generic pci host bridge in arm-virt machine
Hi Alex,
Quoted 10 lines · Alex Bennée
Quoted 8 lines · Eric Auger
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.
Quoted 7 lines
Quoted 6 lines
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.
We force cpu=max along with aarch64/virt machine as some PCI tests require high MMIO regions to be available.
Where would I be able to force disable-legacy=off for the PCI device
in libqos/vhost-user-gpio-pci.c qos_node_consumes("vhost-user-blk-pci", "pci-bus", &opts);
I think you can use opts to force disable-legacy to off.
see vhost-user-blk.c.
Quoted 10 lines
from? Building on this for GPIO I run into the following:
subprocess_run_one_test: /aarch64/virt/generic-pcihost/pci-bus-generic/pci-bus/vhost-user-gpio-pci/vhost-user-gpio/vhost-user-gpio-tests/read-guest-mem/memfile/subprocess
vhost_user_test_setup: -M virt, -cpu max -device vhost-user-gpio-pci,id=gpio0,addr=04.0,chardev=chr-vhost-user-testvu_gpio_get_protocol_features:0x202
qemu-system-aarch64: -device vhost-user-gpio-pci,id=gpio0,addr=04.0,chardev=chr-vhost-user-test: Device doesn't support modern mode, and legacy mode is disabled Set disable-legacy to off
Broken pipeand I think this needs to be applied to the root bus device?
you mean the disable-legacy? I guess it should be applied to your device?
Eric
Quoted 5 lines
Anyway otherwise it looks OK to me:
Reviewed-by Alex Bennée <[email protected]>
Hi,
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 run the tests 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 6 lines
Best Regards
Eric
This series can be found at:
https://github.com/eauger/qemu/tree/libqos-pci-arm-v6
A gentle ping on this series.
Now 5b4f72f5e86 ("tests/qtest: properly initialise the vring used idx") has landed and the all the enabled tests pass, Could someone please consider pulling it. I have rebased it on
907b5105f1b ("tests: move libqtest.h back under qtest")
so now I hope everything is OK
Thank you in advance
Eric
Quoted 62 lines
History
v5 -> v6:
- change thelibqtest.hheader path after pull of
"tests: movelibqtest.hback under qtest/"v4 -> v5:
- Added Alex' R-b
- Removed [PATCH v3 4/5] tests/qtest/vhost-user-blk-test:
Temporary hack to get tests passing on aarch64 following Alex' fixv3 -> v4:
- handle endianess when accessing the cfg space (fix PPC64 BE failure). Tested on such machine.v2 -> v3:
- force -cpu=max along with aarch64/virt
- reduced the vhost-user-block-pci issue workaround to a singleguest_alloc()instead of enabling MSIs. Call for help on this specific issue. The 2 tests which fail are:
test_basicand indirect.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 (3):
tests/qtest/libqos/pci: Introducepio_limittests/qtest/libqos: Skip hotplug tests if pci root bus is not
hotpluggable
tests/qtest/libqos: Add generic pci host bridge in arm-virt machinetests/qtest/e1000e-test.c | 6 + tests/qtest/libqos/arm-virt-machine.c | 19 ++- 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 | 10 ++ tests/qtest/virtio-blk-test.c | 5 + tests/qtest/virtio-net-test.c | 5 + tests/qtest/virtio-rng-test.c | 5 + 13 files changed, 387 insertions(+), 35 deletions(-) create mode 100644 tests/qtest/libqos/generic-pcihost.c create mode 100644 tests/qtest/libqos/generic-pcihost.h