qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] qemu/virtio: make wmb compiler barrier + comments
@ 2009-10-26 13:17 Michael S. Tsirkin
  2009-11-11  1:34 ` Paul Brook
  0 siblings, 1 reply; 17+ messages in thread
From: Michael S. Tsirkin @ 2009-10-26 13:17 UTC (permalink / raw)
  To: qemu-devel, anthony

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 <mst@redhat.com>
---
 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
 {
-- 
1.6.5.rc2

^ permalink raw reply related	[flat|nested] 17+ messages in thread

end of thread, other threads:[~2009-11-13  3:00 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-10-26 13:17 [Qemu-devel] [PATCH] qemu/virtio: make wmb compiler barrier + comments Michael S. Tsirkin
2009-11-11  1:34 ` Paul Brook
2009-11-11  9:37   ` [Qemu-devel] " Michael S. Tsirkin
2009-11-11 13:01     ` Paul Brook
2009-11-11 13:12       ` Michael S. Tsirkin
2009-11-11 13:45         ` Paul Brook
2009-11-11 14:08           ` Michael S. Tsirkin
2009-11-11 14:16             ` Paul Brook
2009-11-11 14:34               ` Michael S. Tsirkin
2009-11-11 16:13                 ` Paul Brook
2009-11-11 17:18             ` Scott Tsai
2009-11-11 18:08               ` Michael S. Tsirkin
2009-11-11 18:09               ` Michael S. Tsirkin
2009-11-11 18:37                 ` Scott Tsai
2009-11-11 19:56                   ` Michael S. Tsirkin
2009-11-13  3:00               ` Jamie Lokier
2009-11-11 13:15       ` Michael S. Tsirkin

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).