From patchwork Mon Oct 26 13:17:15 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: 36905 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 9C341B7BDE for ; Tue, 27 Oct 2009 00:20:14 +1100 (EST) Received: from localhost ([127.0.0.1]:35156 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1N2PUY-0002fv-Py for incoming@patchwork.ozlabs.org; Mon, 26 Oct 2009 09:20:10 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1N2PU7-0002fi-Pp for qemu-devel@nongnu.org; Mon, 26 Oct 2009 09:19:43 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1N2PU3-0002d9-Rr for qemu-devel@nongnu.org; Mon, 26 Oct 2009 09:19:43 -0400 Received: from [199.232.76.173] (port=45701 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1N2PU3-0002cy-M1 for qemu-devel@nongnu.org; Mon, 26 Oct 2009 09:19:39 -0400 Received: from mx1.redhat.com ([209.132.183.28]:32681) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1N2PU3-0002dM-9D for qemu-devel@nongnu.org; Mon, 26 Oct 2009 09:19: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 n9QDJaiA020472; Mon, 26 Oct 2009 09:19:37 -0400 Received: from redhat.com (vpn-6-108.tlv.redhat.com [10.35.6.108]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with SMTP id n9QDJWVM006573; Mon, 26 Oct 2009 09:19:33 -0400 Date: Mon, 26 Oct 2009 15:17:15 +0200 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org, anthony@codemonkey.ws Message-ID: <20091026131715.GA25271@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 X-detected-operating-system: by monty-python.gnu.org: Genre and OS details not recognized. Cc: Subject: [Qemu-devel] [PATCH] qemu/virtio: make wmb compiler barrier + comments X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org wmb must be at least a compiler barrier, even without SMP. Further, we likely need some rmb()/mb() as well: I have not audited the code but lguest has mb(), add a comment for now. Signed-off-by: Michael S. Tsirkin --- hw/virtio.c | 5 ++++- 1 files changed, 4 insertions(+), 1 deletions(-) diff --git a/hw/virtio.c b/hw/virtio.c index 337ff27..1f92171 100644 --- a/hw/virtio.c +++ b/hw/virtio.c @@ -23,8 +23,11 @@ /* QEMU doesn't strictly need write barriers since everything runs in * lock-step. We'll leave the calls to wmb() in though to make it obvious for * KVM or if kqemu gets SMP support. + * In any case, we must prevent the compiler from reordering the code. + * TODO: we likely need some rmb()/mb() as well. */ -#define wmb() do { } while (0) + +#define wmb() __asm__ __volatile__("": : :"memory") typedef struct VRingDesc {