All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] arm64: kexec: flush log to console in nmi_panic()
@ 2021-06-17 12:50 ` Huang Shijie
  0 siblings, 0 replies; 14+ messages in thread
From: Huang Shijie @ 2021-06-17 12:50 UTC (permalink / raw)
  To: catalin.marinas
  Cc: will, tabba, ardb, mark.rutland, pasha.tatashin,
	linux-arm-kernel, linux-kernel, patches, zwang, Huang Shijie

If kdump is configured, nmi_panic() may run to machine_kexec().

But in NMI context, the log is put in PER-CPU nmi_print_seq.
So we can not see any log on the console since we entered the NMI context,
such as the "Bye!" in previous line.

This patch fixes this issue by two steps:
	1) Uses printk_safe_flush_on_panic() to flush the log from
             nmi_print_seq to global printk ring buffer,
        2) Then uses console_flush_on_panic() to flush to console.

After this patch, we can see the "Bye!" log in the panic console.

Signed-off-by: Huang Shijie <shijie@os.amperecomputing.com>
---
 arch/arm64/kernel/machine_kexec.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/arch/arm64/kernel/machine_kexec.c b/arch/arm64/kernel/machine_kexec.c
index 213d56c14f60..0ab841dab9db 100644
--- a/arch/arm64/kernel/machine_kexec.c
+++ b/arch/arm64/kernel/machine_kexec.c
@@ -6,6 +6,7 @@
  * Copyright (C) Huawei Futurewei Technologies.
  */
 
+#include <linux/console.h>
 #include <linux/interrupt.h>
 #include <linux/irq.h>
 #include <linux/kernel.h>
@@ -189,6 +190,12 @@ void machine_kexec(struct kimage *kimage)
 
 	pr_info("Bye!\n");
 
+	if (in_nmi()) {
+		/* Flush the log to console if we are in NMI context */
+		printk_safe_flush_on_panic();
+		console_flush_on_panic(CONSOLE_FLUSH_PENDING);
+	}
+
 	local_daif_mask();
 
 	/*
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2021-06-22  2:17 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-17 12:50 [PATCH] arm64: kexec: flush log to console in nmi_panic() Huang Shijie
2021-06-17 12:50 ` Huang Shijie
2021-06-17 17:52 ` Will Deacon
2021-06-17 17:52   ` Will Deacon
2021-06-17 17:55   ` Pavel Tatashin
2021-06-17 17:55     ` Pavel Tatashin
2021-06-17 17:58     ` Will Deacon
2021-06-17 17:58       ` Will Deacon
2021-06-18  9:03       ` Huang Shijie
2021-06-18  9:03         ` Huang Shijie
2021-06-21 10:08         ` Will Deacon
2021-06-21 10:08           ` Will Deacon
2021-06-22 10:14           ` Huang Shijie
2021-06-22 10:14             ` Huang Shijie

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.