From patchwork Sun Oct 25 13:28:53 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: 55753 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 n9PDVP7R026213 for ; Sun, 25 Oct 2009 13:31:25 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752099AbZJYNbO (ORCPT ); Sun, 25 Oct 2009 09:31:14 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1751819AbZJYNbO (ORCPT ); Sun, 25 Oct 2009 09:31:14 -0400 Received: from mx1.redhat.com ([209.132.183.28]:8354 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751800AbZJYNbN (ORCPT ); Sun, 25 Oct 2009 09:31:13 -0400 Received: from int-mx05.intmail.prod.int.phx2.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.18]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id n9PDVCRI007274; Sun, 25 Oct 2009 09:31:12 -0400 Received: from redhat.com (vpn-6-117.tlv.redhat.com [10.35.6.117]) by int-mx05.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with SMTP id n9PDV9jk032315; Sun, 25 Oct 2009 09:31:10 -0400 Date: Sun, 25 Oct 2009 15:28:53 +0200 From: "Michael S. Tsirkin" To: virtualization@lists.linux-foundation.org, kvm@vger.kernel.org, Rusty Russell Subject: [PATCHv2] virtio: order used ring after used index read Message-ID: <20091025132853.GA21301@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.18 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..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;