mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-08-05 16:54:27 +00:00

Lockdep generates the following false positives with KMSAN on s390x: [ 6.063666] DEBUG_LOCKS_WARN_ON(lockdep_hardirqs_enabled()) [ ...] [ 6.577050] Call Trace: [ 6.619637] [<000000000690d2de>] check_flags+0x1fe/0x210 [ 6.665411] ([<000000000690d2da>] check_flags+0x1fa/0x210) [ 6.707478] [<00000000006cec1a>] lock_acquire+0x2ca/0xce0 [ 6.749959] [<00000000069820ea>] _raw_spin_lock_irqsave+0xea/0x190 [ 6.794912] [<00000000041fc988>] __stack_depot_save+0x218/0x5b0 [ 6.838420] [<000000000197affe>] __msan_poison_alloca+0xfe/0x1a0 [ 6.882985] [<0000000007c5827c>] start_kernel+0x70c/0xd50 [ 6.927454] [<0000000000100036>] startup_continue+0x36/0x40 Between trace_hardirqs_on() and `stosm __mask, 3` lockdep thinks that interrupts are on, but on the CPU they are still off. KMSAN instrumentation takes spinlocks, giving lockdep a chance to see and complain about this discrepancy. KMSAN instrumentation is inserted in order to poison the __mask variable. Disable instrumentation in the respective functions. They are very small and it's easy to see that no important metadata updates are lost because of this. Link: https://lkml.kernel.org/r/20240621113706.315500-31-iii@linux.ibm.com Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com> Reviewed-by: Alexander Potapenko <glider@google.com> Cc: Alexander Gordeev <agordeev@linux.ibm.com> Cc: Christian Borntraeger <borntraeger@linux.ibm.com> Cc: Christoph Lameter <cl@linux.com> Cc: David Rientjes <rientjes@google.com> Cc: Dmitry Vyukov <dvyukov@google.com> Cc: Heiko Carstens <hca@linux.ibm.com> Cc: Hyeonggon Yoo <42.hyeyoo@gmail.com> Cc: Joonsoo Kim <iamjoonsoo.kim@lge.com> Cc: <kasan-dev@googlegroups.com> Cc: Marco Elver <elver@google.com> Cc: Mark Rutland <mark.rutland@arm.com> Cc: Masami Hiramatsu (Google) <mhiramat@kernel.org> Cc: Pekka Enberg <penberg@kernel.org> Cc: Roman Gushchin <roman.gushchin@linux.dev> Cc: Steven Rostedt (Google) <rostedt@goodmis.org> Cc: Sven Schnelle <svens@linux.ibm.com> Cc: Vasily Gorbik <gor@linux.ibm.com> Cc: Vlastimil Babka <vbabka@suse.cz> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
89 lines
2.1 KiB
C
89 lines
2.1 KiB
C
/* SPDX-License-Identifier: GPL-2.0 */
|
|
/*
|
|
* Copyright IBM Corp. 2006, 2010
|
|
* Author(s): Martin Schwidefsky <schwidefsky@de.ibm.com>
|
|
*/
|
|
|
|
#ifndef __ASM_IRQFLAGS_H
|
|
#define __ASM_IRQFLAGS_H
|
|
|
|
#include <linux/types.h>
|
|
|
|
#define ARCH_IRQ_ENABLED (3UL << (BITS_PER_LONG - 8))
|
|
|
|
/* store then OR system mask. */
|
|
#define __arch_local_irq_stosm(__or) \
|
|
({ \
|
|
unsigned long __mask; \
|
|
asm volatile( \
|
|
" stosm %0,%1" \
|
|
: "=Q" (__mask) : "i" (__or) : "memory"); \
|
|
__mask; \
|
|
})
|
|
|
|
/* store then AND system mask. */
|
|
#define __arch_local_irq_stnsm(__and) \
|
|
({ \
|
|
unsigned long __mask; \
|
|
asm volatile( \
|
|
" stnsm %0,%1" \
|
|
: "=Q" (__mask) : "i" (__and) : "memory"); \
|
|
__mask; \
|
|
})
|
|
|
|
/* set system mask. */
|
|
static __always_inline void __arch_local_irq_ssm(unsigned long flags)
|
|
{
|
|
asm volatile("ssm %0" : : "Q" (flags) : "memory");
|
|
}
|
|
|
|
#ifdef CONFIG_KMSAN
|
|
#define arch_local_irq_attributes noinline notrace __no_sanitize_memory __maybe_unused
|
|
#else
|
|
#define arch_local_irq_attributes __always_inline
|
|
#endif
|
|
|
|
static arch_local_irq_attributes unsigned long arch_local_save_flags(void)
|
|
{
|
|
return __arch_local_irq_stnsm(0xff);
|
|
}
|
|
|
|
static arch_local_irq_attributes unsigned long arch_local_irq_save(void)
|
|
{
|
|
return __arch_local_irq_stnsm(0xfc);
|
|
}
|
|
|
|
static __always_inline void arch_local_irq_disable(void)
|
|
{
|
|
arch_local_irq_save();
|
|
}
|
|
|
|
static arch_local_irq_attributes void arch_local_irq_enable_external(void)
|
|
{
|
|
__arch_local_irq_stosm(0x01);
|
|
}
|
|
|
|
static arch_local_irq_attributes void arch_local_irq_enable(void)
|
|
{
|
|
__arch_local_irq_stosm(0x03);
|
|
}
|
|
|
|
/* This only restores external and I/O interrupt state */
|
|
static __always_inline void arch_local_irq_restore(unsigned long flags)
|
|
{
|
|
/* only disabled->disabled and disabled->enabled is valid */
|
|
if (flags & ARCH_IRQ_ENABLED)
|
|
arch_local_irq_enable();
|
|
}
|
|
|
|
static __always_inline bool arch_irqs_disabled_flags(unsigned long flags)
|
|
{
|
|
return !(flags & ARCH_IRQ_ENABLED);
|
|
}
|
|
|
|
static __always_inline bool arch_irqs_disabled(void)
|
|
{
|
|
return arch_irqs_disabled_flags(arch_local_save_flags());
|
|
}
|
|
|
|
#endif /* __ASM_IRQFLAGS_H */
|