1 // SPDX-License-Identifier: GPL-2.0
2 #include <linux/kernel.h>
3 #include <linux/stdarg.h>
4 #include <linux/string.h>
5 #include <linux/ctype.h>
6 #include <asm/stacktrace.h>
7 #include <asm/boot_data.h>
8 #include <asm/lowcore.h>
9 #include <asm/setup.h>
10 #include <asm/sclp.h>
11 #include <asm/uv.h>
12 #include "boot.h"
13
print_stacktrace(unsigned long sp)14 void print_stacktrace(unsigned long sp)
15 {
16 struct stack_info boot_stack = { STACK_TYPE_TASK, (unsigned long)_stack_start,
17 (unsigned long)_stack_end };
18 bool first = true;
19
20 boot_emerg("Call Trace:\n");
21 while (!(sp & 0x7) && on_stack(&boot_stack, sp, sizeof(struct stack_frame))) {
22 struct stack_frame *sf = (struct stack_frame *)sp;
23
24 if (first)
25 boot_emerg("(sp:%016lx [<%016lx>] %pS)\n", sp, sf->gprs[8], (void *)sf->gprs[8]);
26 else
27 boot_emerg(" sp:%016lx [<%016lx>] %pS\n", sp, sf->gprs[8], (void *)sf->gprs[8]);
28 if (sf->back_chain <= sp)
29 break;
30 sp = sf->back_chain;
31 first = false;
32 }
33 }
34
print_pgm_check_info(void)35 void print_pgm_check_info(void)
36 {
37 unsigned long *gpregs = (unsigned long *)get_lowcore()->gpregs_save_area;
38 struct psw_bits *psw = &psw_bits(get_lowcore()->psw_save_area);
39
40 if (bootdebug)
41 boot_rb_dump();
42 boot_emerg("Linux version %s\n", kernel_version);
43 if (!is_prot_virt_guest() && early_command_line[0])
44 boot_emerg("Kernel command line: %s\n", early_command_line);
45 boot_emerg("Kernel fault: interruption code %04x ilc:%d\n",
46 get_lowcore()->pgm_code, get_lowcore()->pgm_ilc >> 1);
47 if (kaslr_enabled()) {
48 boot_emerg("Kernel random base: %lx\n", __kaslr_offset);
49 boot_emerg("Kernel random base phys: %lx\n", __kaslr_offset_phys);
50 }
51 boot_emerg("PSW : %016lx %016lx (%pS)\n",
52 get_lowcore()->psw_save_area.mask,
53 get_lowcore()->psw_save_area.addr,
54 (void *)get_lowcore()->psw_save_area.addr);
55 boot_emerg(" R:%x T:%x IO:%x EX:%x Key:%x M:%x W:%x P:%x AS:%x CC:%x PM:%x RI:%x EA:%x\n",
56 psw->per, psw->dat, psw->io, psw->ext, psw->key, psw->mcheck,
57 psw->wait, psw->pstate, psw->as, psw->cc, psw->pm, psw->ri, psw->eaba);
58 boot_emerg("GPRS: %016lx %016lx %016lx %016lx\n", gpregs[0], gpregs[1], gpregs[2], gpregs[3]);
59 boot_emerg(" %016lx %016lx %016lx %016lx\n", gpregs[4], gpregs[5], gpregs[6], gpregs[7]);
60 boot_emerg(" %016lx %016lx %016lx %016lx\n", gpregs[8], gpregs[9], gpregs[10], gpregs[11]);
61 boot_emerg(" %016lx %016lx %016lx %016lx\n", gpregs[12], gpregs[13], gpregs[14], gpregs[15]);
62 print_stacktrace(get_lowcore()->gpregs_save_area[15]);
63 boot_emerg("Last Breaking-Event-Address:\n");
64 boot_emerg(" [<%016lx>] %pS\n", (unsigned long)get_lowcore()->pgm_last_break,
65 (void *)get_lowcore()->pgm_last_break);
66 }
67