]> git.baikalelectronics.ru Git - kernel.git/commit
locking/xchg/alpha: Fix xchg() and cmpxchg() memory ordering bugs
authorAndrea Parri <parri.andrea@gmail.com>
Thu, 22 Feb 2018 09:24:48 +0000 (10:24 +0100)
committerIngo Molnar <mingo@kernel.org>
Fri, 23 Feb 2018 07:38:16 +0000 (08:38 +0100)
commit8925fbf1cfbcb431fade139317ee5a4a5d7b946f
tree8f91fed0fa1000eef3790b086903b6409ba50358
parentc5671a866756189d1d269726d4f08bb2c46d0306
locking/xchg/alpha: Fix xchg() and cmpxchg() memory ordering bugs

Successful RMW operations are supposed to be fully ordered, but
Alpha's xchg() and cmpxchg() do not meet this requirement.

Will Deacon noticed the bug:

  > So MP using xchg:
  >
  > WRITE_ONCE(x, 1)
  > xchg(y, 1)
  >
  > smp_load_acquire(y) == 1
  > READ_ONCE(x) == 0
  >
  > would be allowed.

... which thus violates the above requirement.

Fix it by adding a leading smp_mb() to the xchg() and cmpxchg() implementations.

Reported-by: Will Deacon <will.deacon@arm.com>
Signed-off-by: Andrea Parri <parri.andrea@gmail.com>
Acked-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
Cc: Alan Stern <stern@rowland.harvard.edu>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Ivan Kokshaysky <ink@jurassic.park.msu.ru>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Matt Turner <mattst88@gmail.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Richard Henderson <rth@twiddle.net>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: linux-alpha@vger.kernel.org
Link: http://lkml.kernel.org/r/1519291488-5752-1-git-send-email-parri.andrea@gmail.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
arch/alpha/include/asm/xchg.h