public inbox for linux-um@lists.infradead.org
 help / color / mirror / Atom feed
From: Richard Weinberger <richard@nod.at>
To: linux-um@lists.infradead.org
Cc: linux-kernel@vger.kernel.org, johannes.berg@intel.com,
	anton.ivanov@cambridgegreys.com,
	Richard Weinberger <richard@nod.at>
Subject: [PATCH 1/4] um: Run console exit code also upon kernel panic
Date: Sat,  1 Jan 2022 22:58:07 +0100	[thread overview]
Message-ID: <20220101215810.13260-2-richard@nod.at> (raw)
In-Reply-To: <20220101215810.13260-1-richard@nod.at>

Make sure that UML's console exit handler run also when the kernel
crashes.
That way settings and resources can get restored.

Signed-off-by: Richard Weinberger <richard@nod.at>
---
 arch/um/drivers/stdio_console.c      |  4 ++--
 arch/um/include/shared/uml_console.h | 11 +++++++++++
 arch/um/kernel/um_arch.c             |  8 +++++---
 3 files changed, 18 insertions(+), 5 deletions(-)
 create mode 100644 arch/um/include/shared/uml_console.h

diff --git a/arch/um/drivers/stdio_console.c b/arch/um/drivers/stdio_console.c
index e8b762f4d8c2..06612c3b6240 100644
--- a/arch/um/drivers/stdio_console.c
+++ b/arch/um/drivers/stdio_console.c
@@ -180,13 +180,13 @@ static int stdio_init(void)
 }
 late_initcall(stdio_init);
 
-static void console_exit(void)
+void uml_console_exit(void)
 {
 	if (!con_init_done)
 		return;
 	close_lines(vts, ARRAY_SIZE(vts));
 }
-__uml_exitcall(console_exit);
+__uml_exitcall(uml_console_exit);
 
 static int console_chan_setup(char *str)
 {
diff --git a/arch/um/include/shared/uml_console.h b/arch/um/include/shared/uml_console.h
new file mode 100644
index 000000000000..aa8d02fe5e90
--- /dev/null
+++ b/arch/um/include/shared/uml_console.h
@@ -0,0 +1,11 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Copyright (C) 2022 Richard Weinberger <richard@nod.at>
+ */
+
+#ifndef UML_CONSOLE_H
+#define UML_CONSOLE_H
+
+extern void uml_console_exit(void);
+
+#endif /* UML_CONSOLE_H */
diff --git a/arch/um/kernel/um_arch.c b/arch/um/kernel/um_arch.c
index abceeabe29b9..0bdae61929ef 100644
--- a/arch/um/kernel/um_arch.c
+++ b/arch/um/kernel/um_arch.c
@@ -17,17 +17,18 @@
 #include <linux/kmsg_dump.h>
 #include <linux/suspend.h>
 
-#include <asm/processor.h>
+#include <arch.h>
+#include <as-layout.h>
 #include <asm/cpufeature.h>
+#include <asm/processor.h>
 #include <asm/sections.h>
 #include <asm/setup.h>
-#include <as-layout.h>
-#include <arch.h>
 #include <init.h>
 #include <kern.h>
 #include <kern_util.h>
 #include <mem_user.h>
 #include <os.h>
+#include <uml_console.h>
 
 #include "um_arch.h"
 
@@ -245,6 +246,7 @@ static int panic_exit(struct notifier_block *self, unsigned long unused1,
 	bust_spinlocks(1);
 	bust_spinlocks(0);
 	uml_exitcode = 1;
+	uml_console_exit();
 	os_dump_core();
 	return 0;
 }
-- 
2.26.2


_______________________________________________
linux-um mailing list
linux-um@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-um


  reply	other threads:[~2022-01-01 21:58 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-01 21:58 [PATCH 0/4] um: Assorted console related fixes Richard Weinberger
2022-01-01 21:58 ` Richard Weinberger [this message]
2022-01-04  8:56   ` [PATCH 1/4] um: Run console exit code also upon kernel panic Johannes Berg
2022-01-01 21:58 ` [PATCH 2/4] um: os_set_fd_block: Return old blocking mode Richard Weinberger
2022-01-04  9:00   ` Johannes Berg
2022-01-01 21:58 ` [PATCH 3/4] um: chan: Restore blocking mode upon exit Richard Weinberger
2022-01-01 21:58 ` [PATCH 4/4] um: irq: Restore O_ASYNC " Richard Weinberger
2022-01-04  9:02   ` Johannes Berg
2022-03-09  5:29 ` [PATCH 0/4] um: Assorted console related fixes Glenn Washburn
2022-03-09  8:35   ` Richard Weinberger
2022-03-09 16:13     ` Randy Dunlap
2022-03-09 16:21       ` Richard Weinberger
2022-03-09 16:48         ` Randy Dunlap
2022-03-10 18:21     ` Glenn Washburn
2022-04-04 21:41       ` Richard Weinberger
2022-06-06 23:16         ` Glenn Washburn
2022-06-07  8:22           ` Johannes Berg
2022-06-07 15:10             ` Glenn Washburn

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=20220101215810.13260-2-richard@nod.at \
    --to=richard@nod.at \
    --cc=anton.ivanov@cambridgegreys.com \
    --cc=johannes.berg@intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-um@lists.infradead.org \
    /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