[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v4 02/16] libqos: read QVIRTIO_MMIO_VERSION register
From: |
Stefan Hajnoczi |
Subject: |
[PATCH v4 02/16] libqos: read QVIRTIO_MMIO_VERSION register |
Date: |
Wed, 23 Oct 2019 11:04:11 +0100 |
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 <address@hidden>
Reviewed-by: Thomas Huth <address@hidden>
---
tests/libqos/virtio-mmio.h | 1 +
tests/libqos/virtio-mmio.c | 3 +++
2 files changed, 4 insertions(+)
diff --git a/tests/libqos/virtio-mmio.h b/tests/libqos/virtio-mmio.h
index 17a17141c3..0e45778b07 100644
--- a/tests/libqos/virtio-mmio.h
+++ b/tests/libqos/virtio-mmio.h
@@ -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;
diff --git a/tests/libqos/virtio-mmio.c b/tests/libqos/virtio-mmio.c
index d0047876a8..7154b03c1d 100644
--- a/tests/libqos/virtio-mmio.c
+++ b/tests/libqos/virtio-mmio.c
@@ -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;
--
2.21.0
- [PATCH v4 00/16] libqos: add VIRTIO PCI 1.0 support, Stefan Hajnoczi, 2019/10/23
- [PATCH v4 01/16] tests/virtio-blk-test: read config space after feature negotiation, Stefan Hajnoczi, 2019/10/23
- [PATCH v4 02/16] libqos: read QVIRTIO_MMIO_VERSION register,
Stefan Hajnoczi <=
- [PATCH v4 04/16] virtio-scsi-test: add missing feature negotiation, Stefan Hajnoczi, 2019/10/23
- [PATCH v4 05/16] tests/virtio-blk-test: set up virtqueue after feature negotiation, Stefan Hajnoczi, 2019/10/23
- [PATCH v4 03/16] libqos: extend feature bits to 64-bit, Stefan Hajnoczi, 2019/10/23
- [PATCH v4 06/16] libqos: add missing virtio-9p feature negotiation, Stefan Hajnoczi, 2019/10/23
- [PATCH v4 07/16] libqos: enforce Device Initialization order, Stefan Hajnoczi, 2019/10/23
- [PATCH v4 08/16] libqos: implement VIRTIO 1.0 FEATURES_OK step, Stefan Hajnoczi, 2019/10/23