Skip to content

Commit 5c2fb57

Browse files
committed
Merge tag 'printk-for-5.8-kdb-nmi' of git://git.kernel.org/pub/scm/linux/kernel/git/printk/linux
Pull printk fix from Petr Mladek: "One more printk change for 5.8: make sure that messages printed from KDB context are redirected to KDB console handlers. It did not work when KDB interrupted NMI or printk_safe contexts. Arm people started hitting this problem more often recently. I forgot to add the fix into the previous pull request by mistake" * tag 'printk-for-5.8-kdb-nmi' of git://git.kernel.org/pub/scm/linux/kernel/git/printk/linux: printk/kdb: Redirect printk messages into kdb in any context
2 parents 923ea16 + 2a9e5de commit 5c2fb57

File tree

2 files changed

+8
-13
lines changed

2 files changed

+8
-13
lines changed

kernel/printk/printk.c

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@
3535
#include <linux/memblock.h>
3636
#include <linux/syscalls.h>
3737
#include <linux/crash_core.h>
38-
#include <linux/kdb.h>
3938
#include <linux/ratelimit.h>
4039
#include <linux/kmsg_dump.h>
4140
#include <linux/syslog.h>
@@ -2047,18 +2046,7 @@ EXPORT_SYMBOL(vprintk);
20472046

20482047
int vprintk_default(const char *fmt, va_list args)
20492048
{
2050-
int r;
2051-
2052-
#ifdef CONFIG_KGDB_KDB
2053-
/* Allow to pass printk() to kdb but avoid a recursion. */
2054-
if (unlikely(kdb_trap_printk && kdb_printf_cpu < 0)) {
2055-
r = vkdb_printf(KDB_MSGSRC_PRINTK, fmt, args);
2056-
return r;
2057-
}
2058-
#endif
2059-
r = vprintk_emit(0, LOGLEVEL_DEFAULT, NULL, 0, fmt, args);
2060-
2061-
return r;
2049+
return vprintk_emit(0, LOGLEVEL_DEFAULT, NULL, 0, fmt, args);
20622050
}
20632051
EXPORT_SYMBOL_GPL(vprintk_default);
20642052

kernel/printk/printk_safe.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#include <linux/preempt.h>
77
#include <linux/spinlock.h>
88
#include <linux/debug_locks.h>
9+
#include <linux/kdb.h>
910
#include <linux/smp.h>
1011
#include <linux/cpumask.h>
1112
#include <linux/irq_work.h>
@@ -360,6 +361,12 @@ void __printk_safe_exit(void)
360361

361362
__printf(1, 0) int vprintk_func(const char *fmt, va_list args)
362363
{
364+
#ifdef CONFIG_KGDB_KDB
365+
/* Allow to pass printk() to kdb but avoid a recursion. */
366+
if (unlikely(kdb_trap_printk && kdb_printf_cpu < 0))
367+
return vkdb_printf(KDB_MSGSRC_PRINTK, fmt, args);
368+
#endif
369+
363370
/*
364371
* Try to use the main logbuf even in NMI. But avoid calling console
365372
* drivers that might have their own locks.

0 commit comments

Comments
 (0)