Commit 68d1aaa4 authored by Daniel Thompson's avatar Daniel Thompson Committed by Khalid Elmously

kgdb: Fix spurious true from in_dbg_master()

BugLink: https://bugs.launchpad.net/bugs/1884564

[ Upstream commit 3fec4aec ]

Currently there is a small window where a badly timed migration could
cause in_dbg_master() to spuriously return true. Specifically if we
migrate to a new core after reading the processor id and the previous
core takes a breakpoint then we will evaluate true if we read
kgdb_active before we get the IPI to bring us to halt.

Fix this by checking irqs_disabled() first. Interrupts are always
disabled when we are executing the kgdb trap so this is an acceptable
prerequisite. This also allows us to replace raw_smp_processor_id()
with smp_processor_id() since the short circuit logic will prevent
warnings from PREEMPT_DEBUG.

Fixes: dcc78711 ("kgdb: core changes to support kdb")
Suggested-by: default avatarWill Deacon <will@kernel.org>
Link: https://lore.kernel.org/r/20200506164223.2875760-1-daniel.thompson@linaro.orgReviewed-by: default avatarDouglas Anderson <dianders@chromium.org>
Signed-off-by: default avatarDaniel Thompson <daniel.thompson@linaro.org>
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
Signed-off-by: default avatarKamal Mostafa <kamal@canonical.com>
Signed-off-by: default avatarKhalid Elmously <khalid.elmously@canonical.com>
parent a2f20553
...@@ -317,7 +317,7 @@ extern void gdbstub_exit(int status); ...@@ -317,7 +317,7 @@ extern void gdbstub_exit(int status);
extern int kgdb_single_step; extern int kgdb_single_step;
extern atomic_t kgdb_active; extern atomic_t kgdb_active;
#define in_dbg_master() \ #define in_dbg_master() \
(raw_smp_processor_id() == atomic_read(&kgdb_active)) (irqs_disabled() && (smp_processor_id() == atomic_read(&kgdb_active)))
extern bool dbg_is_early; extern bool dbg_is_early;
extern void __init dbg_late_init(void); extern void __init dbg_late_init(void);
#else /* ! CONFIG_KGDB */ #else /* ! CONFIG_KGDB */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment