From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54938) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YqeH7-00040y-FC for qemu-devel@nongnu.org; Fri, 08 May 2015 05:08:54 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YqeH3-0001cV-Hy for qemu-devel@nongnu.org; Fri, 08 May 2015 05:08:53 -0400 Received: from e06smtp14.uk.ibm.com ([195.75.94.110]:60337) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YqeH3-0001bx-8l for qemu-devel@nongnu.org; Fri, 08 May 2015 05:08:49 -0400 Received: from /spool/local by e06smtp14.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 8 May 2015 10:08:48 +0100 Received: from b06cxnps4074.portsmouth.uk.ibm.com (d06relay11.portsmouth.uk.ibm.com [9.149.109.196]) by d06dlp01.portsmouth.uk.ibm.com (Postfix) with ESMTP id CB2A417D805D for ; Fri, 8 May 2015 10:09:30 +0100 (BST) Received: from d06av04.portsmouth.uk.ibm.com (d06av04.portsmouth.uk.ibm.com [9.149.37.216]) by b06cxnps4074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id t4898iL18258046 for ; Fri, 8 May 2015 09:08:44 GMT Received: from d06av04.portsmouth.uk.ibm.com (localhost [127.0.0.1]) by d06av04.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id t4898fVs027871 for ; Fri, 8 May 2015 03:08:44 -0600 From: Cornelia Huck Date: Fri, 8 May 2015 11:08:28 +0200 Message-Id: <1431076115-13153-2-git-send-email-cornelia.huck@de.ibm.com> In-Reply-To: <1431076115-13153-1-git-send-email-cornelia.huck@de.ibm.com> References: <1431076115-13153-1-git-send-email-cornelia.huck@de.ibm.com> Subject: [Qemu-devel] [PULL 1/8] s390-virtio: Accommodate guests using virtqueues too early List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: peter.maydell@linaro.org Cc: Cornelia Huck , borntraeger@de.ibm.com, jfrei@linux.vnet.ibm.com, qemu-devel@nongnu.org, agraf@suse.de From: Christian Borntraeger Feature updates are not a synchronuous operation for the legacy s390-virtio transport. This transport syncs the guest feature bits (those from finalize) on the set_status hypercall. Before that qemu thinks that features are zero, which means QEMU will misbehave, e.g. it will not write the event index, even if the guest asks for it. Let's detect the case where a kick happens before the driver is ready and force sync the features. With this workaround, it is now safe to switch to the common feature bit handling code as used by all other transports. Signed-off-by: Christian Borntraeger Reviewed-by: Cornelia Huck Signed-off-by: Cornelia Huck --- hw/s390x/s390-virtio.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/hw/s390x/s390-virtio.c b/hw/s390x/s390-virtio.c index 3a1b9ee..59750db 100644 --- a/hw/s390x/s390-virtio.c +++ b/hw/s390x/s390-virtio.c @@ -77,6 +77,16 @@ static int s390_virtio_hcall_notify(const uint64_t *args) if (mem > ram_size) { VirtIOS390Device *dev = s390_virtio_bus_find_vring(s390_bus, mem, &i); if (dev) { + /* + * Older kernels will use the virtqueue before setting DRIVER_OK. + * In this case the feature bits are not yet up to date, meaning + * that several funny things can happen, e.g. the guest thinks + * EVENT_IDX is on and QEMU thinks it is off. Let's force a feature + * and status sync. + */ + if (!(dev->vdev->status & VIRTIO_CONFIG_S_DRIVER_OK)) { + s390_virtio_device_update_status(dev); + } virtio_queue_notify(dev->vdev, i); } else { r = -EINVAL; -- 2.4.0