diff options
author | Michael S. Tsirkin <mst@redhat.com> | 2010-05-20 16:36:32 +0300 |
---|---|---|
committer | Kevin O'Connor <kevin@koconnor.net> | 2010-05-26 20:52:06 -0400 |
commit | 0f3783b3cc9be767182bce8e7aeadab64db4e0aa (patch) | |
tree | b893dc2ecc86e3027b8162a135fb90773bdc23f3 /src/virtio-ring.h | |
parent | bfe4d6044c579e4b66566d10b4e25f3297f6c4ab (diff) | |
download | seabios-0f3783b3cc9be767182bce8e7aeadab64db4e0aa.tar.gz |
virtio: clean up memory barrier usage
cleanup memory barrier usage bringing it
in sync with what linux guest does.
The rules are simple:
- read barrier after index read
- write barrier before index write
Also, call macros smp_rmb/smp_wmb to stress
we are not syncing with a real io device here.
While I don't think compiler is crazy/powerful
enough to reorder these, anyway, the bogus
barriers we currently have in code will confuse
anyone who tries to copy/reuse it.
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Cc: Gleb Natapov <gleb@redhat.com>
Diffstat (limited to 'src/virtio-ring.h')
-rw-r--r-- | src/virtio-ring.h | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/src/virtio-ring.h b/src/virtio-ring.h index 014defc3..b7a7aafb 100644 --- a/src/virtio-ring.h +++ b/src/virtio-ring.h @@ -9,8 +9,9 @@ #define virt_to_phys(v) (unsigned long)(v) #define phys_to_virt(p) (void*)(p) -#define wmb() barrier() -#define mb() barrier() +/* Compiler barrier is enough as an x86 CPU does not reorder reads or writes */ +#define smp_rmb() barrier() +#define smp_wmb() barrier() /* Status byte for guest to report progress, and synchronize features. */ /* We have seen device and processed generic fields (VIRTIO_CONFIG_F_VIRTIO) */ |