remarkable-linux/arch/arm64
Will Deacon d86b8da04d arm64: spinlock: serialise spin_unlock_wait against concurrent lockers
Boqun Feng reported a rather nasty ordering issue with spin_unlock_wait
on architectures implementing spin_lock with LL/SC sequences and acquire
semantics:

 | CPU 1                   CPU 2                     CPU 3
 | ==================      ====================      ==============
 |                                                   spin_unlock(&lock);
 |                         spin_lock(&lock):
 |                           r1 = *lock; // r1 == 0;
 |                         o = READ_ONCE(object); // reordered here
 | object = NULL;
 | smp_mb();
 | spin_unlock_wait(&lock);
 |                           *lock = 1;
 | smp_mb();
 | o->dead = true;
 |                         if (o) // true
 |                           BUG_ON(o->dead); // true!!

The crux of the problem is that spin_unlock_wait(&lock) can return on
CPU 1 whilst CPU 2 is in the process of taking the lock. This can be
resolved by upgrading spin_unlock_wait to a LOCK operation, forcing it
to serialise against a concurrent locker and giving it acquire semantics
in the process (although it is not at all clear whether this is needed -
different callers seem to assume different things about the barrier
semantics and architectures are similarly disjoint in their
implementations of the macro).

This patch implements spin_unlock_wait using an LL/SC sequence with
acquire semantics on arm64. For v8.1 systems with the LSE atomics, the
exclusive writeback is omitted, since the spin_lock operation is
indivisible and no intermediate state can be observed.

Signed-off-by: Will Deacon <will.deacon@arm.com>
2015-12-03 19:37:59 +00:00
..
boot ARM: DT updates for v4.4 2015-11-10 15:06:26 -08:00
configs arm64 fixes and clean-ups: 2015-11-12 15:33:11 -08:00
crypto arm64: crypto: reduce priority of core AES cipher 2015-11-18 12:09:08 +00:00
include arm64: spinlock: serialise spin_unlock_wait against concurrent lockers 2015-12-03 19:37:59 +00:00
kernel arm64: add __init/__initdata section marker to some functions/variables 2015-12-02 12:17:11 +00:00
kvm arm64: kvm: report original PAR_EL1 upon panic 2015-11-24 18:20:58 +01:00
lib arm64: add KASAN support 2015-10-12 17:46:36 +01:00
mm arm64: add __init/__initdata section marker to some functions/variables 2015-12-02 12:17:11 +00:00
net Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net 2015-11-17 13:52:59 -08:00
xen
Kconfig arm64: enable HAVE_IRQ_TIME_ACCOUNTING 2015-12-03 19:37:10 +00:00
Kconfig.debug arm64: remove redundant FRAME_POINTER kconfig option and force to select it 2015-11-10 10:36:00 +00:00
Kconfig.platforms ARM: DT updates for v4.4 2015-11-10 15:06:26 -08:00
Makefile arm64 updates for 4.4: 2015-11-04 14:47:13 -08:00