summaryrefslogtreecommitdiffstats
path: root/qemu-barrier.h
Commit message (Collapse)AuthorAgeFilesLines
* qemu-barrier: Fix build failure on PowerPC Mac OS XEric Sunshine2011-11-011-1/+1
| | | | | | | | | qemu-barrier.h tests if macro __powerpc__ is defined, however, the preprocessor on PowerPC Mac OS X defines only __POWERPC__, not __powerpc__. Resolve by testing instead for qemu-provided _ARCH_PPC. Signed-off-by: Eric Sunshine <sunshine@sunshineco.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* Barriers in qemu-barrier.h should not be x86 specificDavid Gibson2011-09-231-3/+31
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | qemu-barrier.h contains a few macros implementing memory barrier primitives used in several places throughout qemu. However, apart from the compiler-only barrier, the defined wmb() is correct only for x86, or platforms which are similarly strongly ordered. This patch addresses the FIXME about this by making the wmb() macro arch dependent. On x86, it remains a compiler barrier only, but with a comment explaining in more detail the conditions under which this is correct. On weakly-ordered powerpc, an "eieio" instruction is used, again with explanation of the conditions under which it is sufficient. On other platforms, we use the __sync_synchronize() primitive, available in sufficiently recent gcc (4.2 and after?). This should implement a full barrier which will be sufficient on all platforms, although it may be overkill in some cases. Other platforms can add optimized versions in future if it's worth it for them. Without proper memory barriers, it is easy to reproduce ordering problems with virtio on powerpc; specifically, the QEMU puts new element into the "used" ring and then updates the ring free-running counter. Without a barrier between these under the right circumstances, the guest linux driver can receive an interrupt, read the counter change but find the ring element to be handled still has an old value, leading to an "id %u is not a head!\n" error message. Similar problems are likely to be possible with kvm on other weakly ordered platforms. Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru> Signed-off-by: David Gibson <david@gibson.dropbear.id.au> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* Introduce proper compiler barrierJan Kiszka2010-07-221-0/+3
| | | | | | | | | | Define barrier() as optimization barrier and replace (potentially unreliable) asm("") fences. Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> Acked-by: Paolo Bonzini <pbonzini@redhat.com> Reviewed-by: Marcelo Tosatti <mtosatti@redhat.com> Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
* kvm-all.c: define smp_wmb and use it for coalesced mmioMarcelo Tosatti2010-02-221-0/+7
Acked-by: "Michael S. Tsirkin" <mst@redhat.com> Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com> Signed-off-by: Avi Kivity <avi@redhat.com>
OpenPOWER on IntegriCloud