Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

powerpc/kcsan: Properly instrument arch_spin_unlock()

The following boottime error is encountered with SMP kernel:

kcsan: improperly instrumented type=(0): arch_spin_unlock(&arch_spinlock)
kcsan: improperly instrumented type=(0): spin_unlock(&test_spinlock)
kcsan: improperly instrumented type=(KCSAN_ACCESS_WRITE): arch_spin_unlock(&arch_spinlock)
kcsan: improperly instrumented type=(KCSAN_ACCESS_WRITE): spin_unlock(&test_spinlock)
kcsan: improperly instrumented type=(KCSAN_ACCESS_WRITE | KCSAN_ACCESS_COMPOUND): arch_spin_unlock(&arch_spinlock)
kcsan: improperly instrumented type=(KCSAN_ACCESS_WRITE | KCSAN_ACCESS_COMPOUND): spin_unlock(&test_spinlock)
kcsan: selftest: test_barrier failed
kcsan: selftest: 2/3 tests passed
Kernel panic - not syncing: selftests failed

Properly instrument arch_spin_unlock() with kcsan_mb().

Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
Acked-by: Marco Elver <elver@google.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://msgid.link/57834a703dfa5d6c27c9de0a01329059636e5ab7.1685080579.git.christophe.leroy@csgroup.eu

authored by

Christophe Leroy and committed by
Michael Ellerman
396f2b01 bcea4f7a

+2
+2
arch/powerpc/include/asm/simple_spinlock.h
··· 15 15 * (the type definitions are in asm/simple_spinlock_types.h) 16 16 */ 17 17 #include <linux/irqflags.h> 18 + #include <linux/kcsan-checks.h> 18 19 #include <asm/paravirt.h> 19 20 #include <asm/paca.h> 20 21 #include <asm/synch.h> ··· 127 126 128 127 static inline void arch_spin_unlock(arch_spinlock_t *lock) 129 128 { 129 + kcsan_mb(); 130 130 __asm__ __volatile__("# arch_spin_unlock\n\t" 131 131 PPC_RELEASE_BARRIER: : :"memory"); 132 132 lock->slock = 0;