]> git.baikalelectronics.ru Git - kernel.git/commit
arm64: spinlock: Fix theoretical trylock() A-B-A with LSE atomics
authorWill Deacon <will.deacon@arm.com>
Wed, 31 Jan 2018 12:12:20 +0000 (12:12 +0000)
committerCatalin Marinas <catalin.marinas@arm.com>
Tue, 6 Feb 2018 22:53:11 +0000 (22:53 +0000)
commitbc901c8b34566d1ba87fdd9981e8d3d678b354a3
tree446a2926a21557be1efc95fa025f9ee30f330462
parent0d4c83b615c2294338f58b58e03de532f979eeda
arm64: spinlock: Fix theoretical trylock() A-B-A with LSE atomics

If the spinlock "next" ticket wraps around between the initial LDR
and the cmpxchg in the LSE version of spin_trylock, then we can erroneously
think that we have successfuly acquired the lock because we only check
whether the next ticket return by the cmpxchg is equal to the owner ticket
in our updated lock word.

This patch fixes the issue by performing a full 32-bit check of the lock
word when trying to determine whether or not the CASA instruction updated
memory.

Reported-by: Catalin Marinas <catalin.marinas@arm.com>
Signed-off-by: Will Deacon <will.deacon@arm.com>
Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
arch/arm64/include/asm/spinlock.h