lkml.org 
[lkml]   [2020]   [May]   [22]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH] kdb: Make kdb_printf robust to run in NMI context
Date
While rounding up CPUs via NMIs, its possible that a rounded up CPU
maybe holding a console port lock leading to kgdb master CPU stuck in
a deadlock during invocation of console write operations. So in order
to avoid such a deadlock, invoke bust_spinlocks() prior to invocation
of console handlers.

Also, add a check for console port to be enabled prior to invocation of
corresponding handler.

Suggested-by: Petr Mladek <pmladek@suse.com>
Suggested-by: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
Signed-off-by: Sumit Garg <sumit.garg@linaro.org>
---
kernel/debug/kdb/kdb_io.c | 8 ++++++++
1 file changed, 8 insertions(+)

diff --git a/kernel/debug/kdb/kdb_io.c b/kernel/debug/kdb/kdb_io.c
index 924bc92..e32ece6 100644
--- a/kernel/debug/kdb/kdb_io.c
+++ b/kernel/debug/kdb/kdb_io.c
@@ -699,7 +699,11 @@ int vkdb_printf(enum kdb_msgsrc src, const char *fmt, va_list ap)
}
}
for_each_console(c) {
+ if (!(c->flags & CON_ENABLED))
+ continue;
+ bust_spinlocks(1);
c->write(c, cp, retlen - (cp - kdb_buffer));
+ bust_spinlocks(0);
touch_nmi_watchdog();
}
}
@@ -761,7 +765,11 @@ int vkdb_printf(enum kdb_msgsrc src, const char *fmt, va_list ap)
}
}
for_each_console(c) {
+ if (!(c->flags & CON_ENABLED))
+ continue;
+ bust_spinlocks(1);
c->write(c, moreprompt, strlen(moreprompt));
+ bust_spinlocks(0);
touch_nmi_watchdog();
}

--
2.7.4
\
 
 \ /
  Last update: 2020-05-22 12:04    [W:0.028 / U:11.192 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site