From patchwork Sun Oct 25 12:22:18 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 55748 Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n9PCOkWW015101 for ; Sun, 25 Oct 2009 12:24:46 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753498AbZJYMYj (ORCPT ); Sun, 25 Oct 2009 08:24:39 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1753495AbZJYMYj (ORCPT ); Sun, 25 Oct 2009 08:24:39 -0400 Received: from mx1.redhat.com ([209.132.183.28]:55959 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753494AbZJYMYj (ORCPT ); Sun, 25 Oct 2009 08:24:39 -0400 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id n9PCOcTO029932; Sun, 25 Oct 2009 08:24:38 -0400 Received: from redhat.com (vpn-6-117.tlv.redhat.com [10.35.6.117]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with SMTP id n9PCOYqK029449; Sun, 25 Oct 2009 08:24:36 -0400 Date: Sun, 25 Oct 2009 14:22:18 +0200 From: "Michael S. Tsirkin" To: virtualization@lists.linux-foundation.org, kvm@vger.kernel.org, Rusty Russell Subject: [PATCH] virtio: order used ring after used index read Message-ID: <20091025122218.GA10992@redhat.com> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.19 (2009-01-05) X-Scanned-By: MIMEDefang 2.67 on 10.5.11.11 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org diff --git a/drivers/virtio/virtio_ring.c b/drivers/virtio/virtio_ring.c index f536005..4c4df3e 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;