qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Christian Borntraeger <borntraeger@de.ibm.com>
To: Alexander Graf <agraf@suse.de>
Cc: "Cornelia Huck" <cornelia.huck@de.ibm.com>,
	"Christian Borntraeger" <borntraeger@de.ibm.com>,
	"Jens Freimann" <jfrei@linux.vnet.ibm.com>,
	"Andreas Färber" <afaerber@suse.de>,
	qemu-devel <qemu-devel@nongnu.org>
Subject: [Qemu-devel] [PULL 3/6] s390/ipl: Fix waiting for virtio processing
Date: Tue,  3 Sep 2013 09:58:34 +0200	[thread overview]
Message-ID: <1378195117-60980-4-git-send-email-borntraeger@de.ibm.com> (raw)
In-Reply-To: <1378195117-60980-1-git-send-email-borntraeger@de.ibm.com>

From: Cornelia Huck <cornelia.huck@de.ibm.com>

The guest side must not manipulate the index for the used buffers. Instead,
remember the state of the used buffer locally and wait until it has moved.

Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
Acked-by: Alexander Graf <agraf@suse.de>
Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
---
 pc-bios/s390-ccw/virtio.c | 7 ++++---
 pc-bios/s390-ccw/virtio.h | 1 +
 2 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/pc-bios/s390-ccw/virtio.c b/pc-bios/s390-ccw/virtio.c
index 49f2d29..4d6e48f 100644
--- a/pc-bios/s390-ccw/virtio.c
+++ b/pc-bios/s390-ccw/virtio.c
@@ -123,6 +123,7 @@ static void vring_init(struct vring *vr, unsigned int num, void *p,
     /* We're running with interrupts off anyways, so don't bother */
     vr->used->flags = VRING_USED_F_NO_NOTIFY;
     vr->used->idx = 0;
+    vr->used_idx = 0;
 
     debug_print_addr("init vr", vr);
 }
@@ -150,8 +151,6 @@ static void vring_send_buf(struct vring *vr, void *p, int len, int flags)
     if (!(flags & VRING_DESC_F_NEXT)) {
         vr->avail->idx++;
     }
-
-    vr->used->idx = vr->next_idx;
 }
 
 static u64 get_clock(void)
@@ -180,7 +179,8 @@ static int vring_wait_reply(struct vring *vr, int timeout)
     struct subchannel_id schid = vr->schid;
     int r = 0;
 
-    while (vr->used->idx == vr->next_idx) {
+    /* Wait until the used index has moved. */
+    while (vr->used->idx == vr->used_idx) {
         vring_notify(schid);
         if (timeout && (get_second() >= target_second)) {
             r = 1;
@@ -189,6 +189,7 @@ static int vring_wait_reply(struct vring *vr, int timeout)
         yield();
     }
 
+    vr->used_idx = vr->used->idx;
     vr->next_idx = 0;
     vr->desc[0].len = 0;
     vr->desc[0].flags = 0;
diff --git a/pc-bios/s390-ccw/virtio.h b/pc-bios/s390-ccw/virtio.h
index 86fdd57..772a63f 100644
--- a/pc-bios/s390-ccw/virtio.h
+++ b/pc-bios/s390-ccw/virtio.h
@@ -115,6 +115,7 @@ struct vring_used {
 struct vring {
     unsigned int num;
     int next_idx;
+    int used_idx;
     struct vring_desc *desc;
     struct vring_avail *avail;
     struct vring_used *used;
-- 
1.8.3.1

  parent reply	other threads:[~2013-09-03  7:58 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-09-03  7:58 [Qemu-devel] [PULL 0/6] s390: cleanups and fixes Christian Borntraeger
2013-09-03  7:58 ` [Qemu-devel] [PULL 1/6] s390/kvm: Add check for priviledged SCLP handler Christian Borntraeger
2013-09-03  7:58 ` [Qemu-devel] [PULL 2/6] s390/dump: zero out padding bytes in notes sections Christian Borntraeger
2013-09-03  7:58 ` Christian Borntraeger [this message]
2013-09-03  7:58 ` [Qemu-devel] [PULL 4/6] s390/ipl: Update the s390-ccw.img rom Christian Borntraeger
2013-09-03  7:58 ` [Qemu-devel] [PULL 5/6] s390/cpu: Make setcc() function available to other files Christian Borntraeger
2013-09-03  7:58 ` [Qemu-devel] [PULL 6/6] s390/ioinst: Moved the CC setting to the IO instruction handlers Christian Borntraeger
2013-09-03 15:23 ` [Qemu-devel] [PULL 0/6] s390: cleanups and fixes Alexander Graf
2013-09-03 19:08 ` [Qemu-devel] [PULL] " Christian Borntraeger
2013-09-12 15:21   ` Christian Borntraeger
2013-09-12 17:15     ` Anthony Liguori

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1378195117-60980-4-git-send-email-borntraeger@de.ibm.com \
    --to=borntraeger@de.ibm.com \
    --cc=afaerber@suse.de \
    --cc=agraf@suse.de \
    --cc=cornelia.huck@de.ibm.com \
    --cc=jfrei@linux.vnet.ibm.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).