From: Marco Elver <elver@google.com>
To: bp@alien8.de, dave.hansen@linux.intel.com, fenghua.yu@intel.com,
hpa@zytor.com, linux-kernel@vger.kernel.org, mingo@redhat.com,
syzkaller-bugs@googlegroups.com, tglx@linutronix.de,
tony.luck@intel.com, x86@kernel.org, yu-cheng.yu@intel.com,
peterz@infradead.org, jgross@suse.com, sdeep@vmware.com,
virtualization@lists.linux-foundation.org,
kasan-dev@googlegroups.com
Cc: syzbot <syzbot+8db9e1ecde74e590a657@syzkaller.appspotmail.com>
Subject: [PATCH] x86/paravirt: Add missing noinstr to arch_local*() helpers
Date: Wed, 5 Aug 2020 15:26:29 +0200 [thread overview]
Message-ID: <20200805132629.GA87338@elver.google.com> (raw)
In-Reply-To: <0000000000007d3b2d05ac1c303e@google.com>
Add missing noinstr to arch_local*() helpers, as they may be called from
noinstr code.
On a KCSAN config with CONFIG_PARAVIRT=y, syzbot stumbled across corrupt
IRQ trace state, with lockdep_assert_irqs_enabled() failing spuriously.
When enabling CONFIG_DEBUG_LOCKDEP=y, we get a warning about
DEBUG_LOCKS_WARN_ON(!lockdep_hardirqs_enabled())
which we had seen before due to KCSAN-lockdep recursion. Due to
"lockdep: Prepare for NMI IRQ state tracking", KCSAN was changed to use
non-raw local_irq_{save,restore}(), assuming there is no more
KCSAN-lockdep recursion.
It turns out that the arch_local*() helpers in paravirt.h were missing
noinstr, as they themselves are used from noinstr code that is called
from lockdep. When inserting debug-code that warns us if lockdep is in
the stacktrace from KCSAN, we get,
RIP: 0010:kcsan_setup_watchpoint[...]
[...]
Call Trace:
arch_local_save_flags+0x11/0x30 arch/x86/include/asm/paravirt.h:765
check_preemption_disabled+0x51/0x140 lib/smp_processor_id.c:19
__this_cpu_preempt_check+0x18/0x20 lib/smp_processor_id.c:65
lockdep_hardirqs_off+0xaa/0x130 kernel/locking/lockdep.c:3801
trace_hardirqs_off+0x14/0x80 kernel/trace/trace_preemptirq.c:76
__raw_spin_lock_irqsave include/linux/spinlock_api_smp.h:108 [inline]
_raw_spin_lock_irqsave+0x48/0x90 kernel/locking/spinlock.c:159
wake_up_new_task+0x2c/0x270 kernel/sched/core.c:3338
_do_fork+0x27b/0x4f0 kernel/fork.c:2474
kernel_thread+0x85/0xb0 kernel/fork.c:2502
create_kthread kernel/kthread.c:315 [inline]
kthreadd+0x427/0x500 kernel/kthread.c:634
ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:294
pointing to arch_local_save_flags() in paravirt.h, which is called from
noinstr functions in smp_processor_id.c, which in turn are called from
lockdep.
Link: https://lkml.kernel.org/r/0000000000007d3b2d05ac1c303e@google.com
Reported-by: syzbot+8db9e1ecde74e590a657@syzkaller.appspotmail.com
Signed-off-by: Marco Elver <elver@google.com>
---
arch/x86/include/asm/paravirt.h | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/arch/x86/include/asm/paravirt.h b/arch/x86/include/asm/paravirt.h
index 3d2afecde50c..a606f2ba2b5e 100644
--- a/arch/x86/include/asm/paravirt.h
+++ b/arch/x86/include/asm/paravirt.h
@@ -760,27 +760,27 @@ bool __raw_callee_save___native_vcpu_is_preempted(long cpu);
((struct paravirt_callee_save) { func })
#ifdef CONFIG_PARAVIRT_XXL
-static inline notrace unsigned long arch_local_save_flags(void)
+static inline noinstr unsigned long arch_local_save_flags(void)
{
return PVOP_CALLEE0(unsigned long, irq.save_fl);
}
-static inline notrace void arch_local_irq_restore(unsigned long f)
+static inline noinstr void arch_local_irq_restore(unsigned long f)
{
PVOP_VCALLEE1(irq.restore_fl, f);
}
-static inline notrace void arch_local_irq_disable(void)
+static inline noinstr void arch_local_irq_disable(void)
{
PVOP_VCALLEE0(irq.irq_disable);
}
-static inline notrace void arch_local_irq_enable(void)
+static inline noinstr void arch_local_irq_enable(void)
{
PVOP_VCALLEE0(irq.irq_enable);
}
-static inline notrace unsigned long arch_local_irq_save(void)
+static inline noinstr unsigned long arch_local_irq_save(void)
{
unsigned long f;
--
2.28.0.163.g6104cc2f0b6-goog
next prev parent reply other threads:[~2020-08-05 19:59 UTC|newest]
Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-08-05 7:19 upstream test error: WARNING in __local_bh_enable_ip syzbot
2020-08-05 13:26 ` Marco Elver [this message]
2020-08-05 13:42 ` [PATCH] x86/paravirt: Add missing noinstr to arch_local*() helpers peterz
2020-08-05 13:59 ` Marco Elver
2020-08-05 14:12 ` peterz
2020-08-05 14:17 ` Jürgen Groß
2020-08-05 14:17 ` peterz
2020-08-05 14:36 ` Marco Elver
2020-08-05 17:31 ` Marco Elver
2020-08-06 7:47 ` Marco Elver
2020-08-06 11:32 ` peterz
2020-08-06 13:17 ` Marco Elver
2020-08-06 16:06 ` Marco Elver
2020-08-07 9:01 ` Marco Elver
2020-08-07 9:24 ` Jürgen Groß
2020-08-07 9:50 ` Marco Elver
2020-08-07 10:35 ` Jürgen Groß
2020-08-07 11:38 ` Marco Elver
2020-08-07 12:04 ` Jürgen Groß
2020-08-07 12:08 ` Marco Elver
2020-08-07 15:19 ` Marco Elver
2020-08-11 7:00 ` Marco Elver
2020-08-11 7:04 ` Jürgen Groß
2020-08-11 7:41 ` Peter Zijlstra
2020-08-11 7:57 ` Jürgen Groß
2020-08-11 8:12 ` Peter Zijlstra
2020-08-11 8:18 ` Jürgen Groß
2020-08-11 8:38 ` Jürgen Groß
2020-08-11 9:20 ` peterz
2020-08-11 9:46 ` peterz
2020-08-11 20:17 ` peterz
2020-08-12 8:06 ` Marco Elver
2020-08-12 8:18 ` peterz
2020-08-12 8:57 ` peterz
2020-08-06 21:02 ` kernel test robot
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200805132629.GA87338@elver.google.com \
--to=elver@google.com \
--cc=bp@alien8.de \
--cc=dave.hansen@linux.intel.com \
--cc=fenghua.yu@intel.com \
--cc=hpa@zytor.com \
--cc=jgross@suse.com \
--cc=kasan-dev@googlegroups.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=peterz@infradead.org \
--cc=sdeep@vmware.com \
--cc=syzbot+8db9e1ecde74e590a657@syzkaller.appspotmail.com \
--cc=syzkaller-bugs@googlegroups.com \
--cc=tglx@linutronix.de \
--cc=tony.luck@intel.com \
--cc=virtualization@lists.linux-foundation.org \
--cc=x86@kernel.org \
--cc=yu-cheng.yu@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox