aboutsummaryrefslogtreecommitdiff
path: root/hw
diff options
context:
space:
mode:
authorJens Freimann <jfrei@linux.vnet.ibm.com>2012-04-26 09:03:36 +0000
committerAlexander Graf <agraf@suse.de>2012-05-01 21:04:06 +0200
commit4170aea1a77d7adf9e35ab4d3c17086c38ca6c09 (patch)
tree4d4f50dff271275e102569c86aea1a12e96bdfc3 /hw
parenteca3ed0343ba413937f34ad4f8c4822dc82924e5 (diff)
downloadqemu-4170aea1a77d7adf9e35ab4d3c17086c38ca6c09.zip
qemu-4170aea1a77d7adf9e35ab4d3c17086c38ca6c09.tar.gz
qemu-4170aea1a77d7adf9e35ab4d3c17086c38ca6c09.tar.bz2
s390: reset avail and used index on reboot
reset the guest vring avail/used idx fields, otherwise it's possible that old values remain in memory which would cause a reboot to fail with a "Guest moved used index" message Signed-off-by: Jens Freimann <jfrei@linux.vnet.ibm.com> Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com> Signed-off-by: Alexander Graf <agraf@suse.de>
Diffstat (limited to 'hw')
-rw-r--r--hw/s390-virtio-bus.c19
-rw-r--r--hw/s390-virtio-bus.h4
-rw-r--r--hw/s390-virtio.c1
3 files changed, 23 insertions, 1 deletions
diff --git a/hw/s390-virtio-bus.c b/hw/s390-virtio-bus.c
index 74419b3..63ccd5c 100644
--- a/hw/s390-virtio-bus.c
+++ b/hw/s390-virtio-bus.c
@@ -63,6 +63,23 @@ static void s390_virtio_bus_reset(void *opaque)
bus->next_ring = bus->dev_page + TARGET_PAGE_SIZE;
}
+void s390_virtio_reset_idx(VirtIOS390Device *dev)
+{
+ int i;
+ target_phys_addr_t idx_addr;
+ uint8_t num_vq;
+
+ num_vq = s390_virtio_device_num_vq(dev);
+ for (i = 0; i < num_vq; i++) {
+ idx_addr = virtio_queue_get_avail_addr(dev->vdev, i) +
+ VIRTIO_VRING_AVAIL_IDX_OFFS;
+ stw_phys(idx_addr, 0);
+ idx_addr = virtio_queue_get_used_addr(dev->vdev, i) +
+ VIRTIO_VRING_USED_IDX_OFFS;
+ stw_phys(idx_addr, 0);
+ }
+}
+
VirtIOS390Bus *s390_virtio_bus_init(ram_addr_t *ram_size)
{
VirtIOS390Bus *bus;
@@ -121,7 +138,7 @@ static int s390_virtio_device_init(VirtIOS390Device *dev, VirtIODevice *vdev)
virtio_bind_device(vdev, &virtio_s390_bindings, dev);
dev->host_features = vdev->get_features(vdev, dev->host_features);
s390_virtio_device_sync(dev);
-
+ s390_virtio_reset_idx(dev);
if (dev->qdev.hotplugged) {
CPUS390XState *env = s390_cpu_addr2state(0);
s390_virtio_irq(env, VIRTIO_PARAM_DEV_ADD, dev->dev_offs);
diff --git a/hw/s390-virtio-bus.h b/hw/s390-virtio-bus.h
index 0e60bc0..49e6c46 100644
--- a/hw/s390-virtio-bus.h
+++ b/hw/s390-virtio-bus.h
@@ -34,6 +34,8 @@
#define VIRTIO_VQCONFIG_LEN 24
#define VIRTIO_RING_LEN (TARGET_PAGE_SIZE * 3)
+#define VIRTIO_VRING_AVAIL_IDX_OFFS 2
+#define VIRTIO_VRING_USED_IDX_OFFS 2
#define S390_DEVICE_PAGES 512
#define VIRTIO_PARAM_MASK 0xff
@@ -90,3 +92,5 @@ VirtIOS390Device *s390_virtio_bus_find_vring(VirtIOS390Bus *bus,
ram_addr_t mem, int *vq_num);
VirtIOS390Device *s390_virtio_bus_find_mem(VirtIOS390Bus *bus, ram_addr_t mem);
void s390_virtio_device_sync(VirtIOS390Device *dev);
+void s390_virtio_reset_idx(VirtIOS390Device *dev);
+
diff --git a/hw/s390-virtio.c b/hw/s390-virtio.c
index d7dc857..c0e19fd 100644
--- a/hw/s390-virtio.c
+++ b/hw/s390-virtio.c
@@ -99,6 +99,7 @@ int s390_virtio_hypercall(CPUS390XState *env, uint64_t mem, uint64_t hypercall)
virtio_reset(dev->vdev);
stb_phys(dev->dev_offs + VIRTIO_DEV_OFFS_STATUS, 0);
s390_virtio_device_sync(dev);
+ s390_virtio_reset_idx(dev);
break;
}
case KVM_S390_VIRTIO_SET_STATUS: