From: "Michael S. Tsirkin" <mst@redhat.com>
To: virtualization@lists.linux-foundation.org, kvm@vger.kernel.org,
Rusty Russell <rusty@rustcorp.com.au>
Subject: [PATCHv2] virtio: order used ring after used index read
Date: Sun, 25 Oct 2009 15:28:53 +0200 [thread overview]
Message-ID: <20091025132853.GA21301@redhat.com> (raw)
On SMP guests, reads from the ring might bypass
used index reads. This causes guest crashes
because host writes to used index to signal ring data
readiness.
Fix this by inserting rmb before used ring reads.
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
Change from v1: indent with TAB and not spaces. sorry about the noise.
Rusty, I see guest crashes with virtio net on vhost sometimes,
and the following seems to help.
This seems an obviously correct thing to do, anyway.
If you think so, too, can this be queued for 2.6.32 please?
Thanks,
drivers/virtio/virtio_ring.c | 3 +++
1 files changed, 3 insertions(+), 0 deletions(-)
diff --git a/drivers/virtio/virtio_ring.c b/drivers/virtio/virtio_ring.c
index f536005..fbd2ecd 100644
--- a/drivers/virtio/virtio_ring.c
+++ b/drivers/virtio/virtio_ring.c
@@ -285,6 +285,9 @@ static void *vring_get_buf(struct virtqueue *_vq, unsigned int *len)
return NULL;
}
+ /* Only get used array entries after they have been exposed by host. */
+ rmb();
+
i = vq->vring.used->ring[vq->last_used_idx%vq->vring.num].id;
*len = vq->vring.used->ring[vq->last_used_idx%vq->vring.num].len;
--
1.6.5.rc2
next reply other threads:[~2009-10-25 13:31 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-10-25 13:28 Michael S. Tsirkin [this message]
2009-10-25 23:55 ` [PATCHv2] virtio: order used ring after used index read Rusty Russell
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=20091025132853.GA21301@redhat.com \
--to=mst@redhat.com \
--cc=kvm@vger.kernel.org \
--cc=rusty@rustcorp.com.au \
--cc=virtualization@lists.linux-foundation.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