aboutsummaryrefslogtreecommitdiffstats
path: root/arch/um
diff options
context:
space:
mode:
authorThomas Meyer <thomas@m3y3r.de>2015-03-28 05:07:37 -0400
committerRichard Weinberger <richard@nod.at>2015-04-13 15:17:37 -0400
commit04a418495e0852263d77c4fb82adf470feaafef3 (patch)
tree55101ddcf7076f7f90a4957b3cdaed946289ccd7 /arch/um
parentfc9bea0e28db8cbfe0a08c1bfb1796bfd7adf49b (diff)
um: add a kmsg_dumper
Add a kmsg_dumper, that dumps the kmsg buffer to stdout, when no console is available. This an enables the printing of early panic() calls triggered in uml_postsetup(). When a panic() call happens so early in the UML kernel no earlyprintk/console is available yet, but with a kmsg_dumper in place the kernel message buffer will be outputted to the user, to give a better hint, of what the failure was. Signed-off-by: Thomas Meyer <thomas@m3y3r.de> Signed-off-by: Richard Weinberger <richard@nod.at>
Diffstat (limited to 'arch/um')
-rw-r--r--arch/um/kernel/Makefile2
-rw-r--r--arch/um/kernel/kmsg_dump.c43
-rw-r--r--arch/um/kernel/um_arch.c2
3 files changed, 46 insertions, 1 deletions
diff --git a/arch/um/kernel/Makefile b/arch/um/kernel/Makefile
index b7e31e5a8c0c..a6a5e42caaef 100644
--- a/arch/um/kernel/Makefile
+++ b/arch/um/kernel/Makefile
@@ -13,7 +13,7 @@ clean-files :=
13obj-y = config.o exec.o exitcode.o irq.o ksyms.o mem.o \ 13obj-y = config.o exec.o exitcode.o irq.o ksyms.o mem.o \
14 physmem.o process.o ptrace.o reboot.o sigio.o \ 14 physmem.o process.o ptrace.o reboot.o sigio.o \
15 signal.o syscall.o sysrq.o time.o tlb.o trap.o \ 15 signal.o syscall.o sysrq.o time.o tlb.o trap.o \
16 um_arch.o umid.o maccess.o skas/ 16 um_arch.o umid.o maccess.o kmsg_dump.o skas/
17 17
18obj-$(CONFIG_BLK_DEV_INITRD) += initrd.o 18obj-$(CONFIG_BLK_DEV_INITRD) += initrd.o
19obj-$(CONFIG_GPROF) += gprof_syms.o 19obj-$(CONFIG_GPROF) += gprof_syms.o
diff --git a/arch/um/kernel/kmsg_dump.c b/arch/um/kernel/kmsg_dump.c
new file mode 100644
index 000000000000..407d49251d6f
--- /dev/null
+++ b/arch/um/kernel/kmsg_dump.c
@@ -0,0 +1,43 @@
1#include <linux/kmsg_dump.h>
2#include <linux/console.h>
3#include <shared/init.h>
4#include <shared/kern.h>
5#include <os.h>
6
7static void kmsg_dumper_stdout(struct kmsg_dumper *dumper,
8 enum kmsg_dump_reason reason)
9{
10 static char line[1024];
11
12 size_t len = 0;
13 bool con_available = false;
14
15 /* only dump kmsg when no console is available */
16 if (!console_trylock())
17 return;
18
19 if (console_drivers != NULL)
20 con_available = true;
21
22 console_unlock();
23
24 if (con_available == true)
25 return;
26
27 printf("kmsg_dump:\n");
28 while (kmsg_dump_get_line(dumper, true, line, sizeof(line), &len)) {
29 line[len] = '\0';
30 printf("%s", line);
31 }
32}
33
34static struct kmsg_dumper kmsg_dumper = {
35 .dump = kmsg_dumper_stdout
36};
37
38int __init kmsg_dumper_stdout_init(void)
39{
40 return kmsg_dump_register(&kmsg_dumper);
41}
42
43__uml_postsetup(kmsg_dumper_stdout_init);
diff --git a/arch/um/kernel/um_arch.c b/arch/um/kernel/um_arch.c
index 9b06957e98ce..926ecdceba86 100644
--- a/arch/um/kernel/um_arch.c
+++ b/arch/um/kernel/um_arch.c
@@ -11,6 +11,7 @@
11#include <linux/string.h> 11#include <linux/string.h>
12#include <linux/utsname.h> 12#include <linux/utsname.h>
13#include <linux/sched.h> 13#include <linux/sched.h>
14#include <linux/kmsg_dump.h>
14#include <asm/pgtable.h> 15#include <asm/pgtable.h>
15#include <asm/processor.h> 16#include <asm/processor.h>
16#include <asm/sections.h> 17#include <asm/sections.h>
@@ -211,6 +212,7 @@ static void __init uml_postsetup(void)
211static int panic_exit(struct notifier_block *self, unsigned long unused1, 212static int panic_exit(struct notifier_block *self, unsigned long unused1,
212 void *unused2) 213 void *unused2)
213{ 214{
215 kmsg_dump(KMSG_DUMP_PANIC);
214 bust_spinlocks(1); 216 bust_spinlocks(1);
215 bust_spinlocks(0); 217 bust_spinlocks(0);
216 uml_exitcode = 1; 218 uml_exitcode = 1;