parisc: Fix lightweight spinlock checks to not break futexes
authorHelge Deller <deller@gmx.de>
Wed, 9 Aug 2023 07:21:58 +0000 (09:21 +0200)
committerHelge Deller <deller@gmx.de>
Thu, 10 Aug 2023 15:32:09 +0000 (17:32 +0200)
commita0f4b7879f2e14986200747d1b545e5daac8c624
tree90c0f9302627476b43a470ad87cb33d24ec27c35
parenta027b2eca0b7e90b11a0b0ddfad0dc4068707799
parisc: Fix lightweight spinlock checks to not break futexes

The lightweight spinlock checks verify that a spinlock has either value
0 (spinlock locked) and that not any other bits than in
__ARCH_SPIN_LOCK_UNLOCKED_VAL is set.

This breaks the current LWS code, which writes the address of the lock
into the lock word to unlock it, which was an optimization to save one
assembler instruction.

Fix it by making spinlock_types.h accessible for asm code, change the
LWS spinlock-unlocking code to write __ARCH_SPIN_LOCK_UNLOCKED_VAL into
the lock word, and add some missing lightweight spinlock checks to the
LWS path. Finally, make the spinlock checks dependend on DEBUG_KERNEL.

Noticed-by: John David Anglin <dave.anglin@bell.net>
Signed-off-by: Helge Deller <deller@gmx.de>
Tested-by: John David Anglin <dave.anglin@bell.net>
Cc: stable@vger.kernel.org # v6.4+
Fixes: 15e64ef6520e ("parisc: Add lightweight spinlock checks")
arch/parisc/Kconfig.debug
arch/parisc/include/asm/spinlock.h
arch/parisc/include/asm/spinlock_types.h
arch/parisc/kernel/syscall.S