]> git.ipfire.org Git - thirdparty/qemu.git/commitdiff
libqos: read QVIRTIO_MMIO_VERSION register
authorStefan Hajnoczi <stefanha@redhat.com>
Wed, 23 Oct 2019 10:04:11 +0000 (11:04 +0100)
committerMichael S. Tsirkin <mst@redhat.com>
Fri, 25 Oct 2019 11:46:22 +0000 (07:46 -0400)
There was no real virtio-mmio ABI change between Legacy and VIRTIO 1.0
except that the Version field was incremented from 1 to 2.

However, QEMU does not allow Legacy drivers to perform VIRTIO 1.0
operations like accessing 64-bit feature bits.  Since we will introduce
64-bit feature bit support we need a way to differentiate between
virtio-mmio Version 1 and 2 to avoid upsetting QEMU when we operate in
Legacy mode.

Stash away the Version field so later patches can change behavior
depending on the version.

Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Message-Id: <20191023100425.12168-3-stefanha@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
tests/libqos/virtio-mmio.c
tests/libqos/virtio-mmio.h

index d0047876a8add9c981ead647d25e76984b09e0c9..7154b03c1dacff73f62cd81c78cefdd959dbda4c 100644 (file)
@@ -223,6 +223,9 @@ void qvirtio_mmio_init_device(QVirtioMMIODevice *dev, QTestState *qts,
     magic = qtest_readl(qts, addr + QVIRTIO_MMIO_MAGIC_VALUE);
     g_assert(magic == ('v' | 'i' << 8 | 'r' << 16 | 't' << 24));
 
+    dev->version = qtest_readl(qts, addr + QVIRTIO_MMIO_VERSION);
+    g_assert(dev->version == 1 || dev->version == 2);
+
     dev->qts = qts;
     dev->addr = addr;
     dev->page_size = page_size;
index 17a17141c3da64cc92b98b77bdaf58969a6538fc..0e45778b07def98adf3998b5bbba3c4d12d0627d 100644 (file)
@@ -40,6 +40,7 @@ typedef struct QVirtioMMIODevice {
     uint64_t addr;
     uint32_t page_size;
     uint32_t features; /* As it cannot be read later, save it */
+    uint32_t version;
 } QVirtioMMIODevice;
 
 extern const QVirtioBus qvirtio_mmio;