summaryrefslogtreecommitdiff
path: root/arch/sh/src
diff options
context:
space:
mode:
authorRich Felker <dalias@aerifal.cx>2014-07-27 21:13:37 -0400
committerRich Felker <dalias@aerifal.cx>2014-07-27 21:13:37 -0400
commitc394763d350f92ff1dbfb79fcd7124da47bc7043 (patch)
tree176336ccc95f27c7b1a9a8bead48fb48c839997c /arch/sh/src
parent2068b4e8911a3a49cded44b4568f6c943a8c98f8 (diff)
downloadmusl-c394763d350f92ff1dbfb79fcd7124da47bc7043.tar.gz
musl-c394763d350f92ff1dbfb79fcd7124da47bc7043.tar.bz2
musl-c394763d350f92ff1dbfb79fcd7124da47bc7043.tar.xz
musl-c394763d350f92ff1dbfb79fcd7124da47bc7043.zip
fix insufficient synchronization in sh atomic asm
while other usage I've seen only has the synco instruction after the atomic operation, I cannot find any documentation indicating that this is correct. certainly all stores before the atomic need to have been synchronized before the atomic operation takes place.
Diffstat (limited to 'arch/sh/src')
-rw-r--r--arch/sh/src/atomic.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/arch/sh/src/atomic.c b/arch/sh/src/atomic.c
index d29b0538..13395673 100644
--- a/arch/sh/src/atomic.c
+++ b/arch/sh/src/atomic.c
@@ -1,7 +1,7 @@
#include "libc.h"
#define LLSC_CLOBBERS "r0", "t", "memory"
-#define LLSC_START(mem) \
+#define LLSC_START(mem) "synco\n" \
"0: movli.l @" mem ", r0\n"
#define LLSC_END(mem) \
"1: movco.l r0, @" mem "\n" \
@@ -99,6 +99,7 @@ void __sh_store(volatile int *p, int x)
{
if (__hwcap & CPU_HAS_LLSC) {
__asm__ __volatile__(
+ " synco\n"
" mov.l %1, @%0\n"
" synco\n"
: : "r"(p), "r"(x) : "memory");