1724dc336SVasily Gorbik // SPDX-License-Identifier: GPL-2.0
2724dc336SVasily Gorbik #include <linux/kernel.h>
3c0891ac1SAlexey Dobriyan #include <linux/stdarg.h>
4724dc336SVasily Gorbik #include <linux/string.h>
59a78c70aSVasily Gorbik #include <linux/ctype.h>
68977ab65SVasily Gorbik #include <asm/stacktrace.h>
7ba1a6be9SVasily Gorbik #include <asm/boot_data.h>
8724dc336SVasily Gorbik #include <asm/lowcore.h>
93ca8b855SVasily Gorbik #include <asm/setup.h>
10724dc336SVasily Gorbik #include <asm/sclp.h>
11ba1a6be9SVasily Gorbik #include <asm/uv.h>
12724dc336SVasily Gorbik #include "boot.h"
13724dc336SVasily Gorbik
print_stacktrace(unsigned long sp)14f913a660SVasily Gorbik void print_stacktrace(unsigned long sp)
158977ab65SVasily Gorbik {
16256d78d0SAlexander Egorenkov struct stack_info boot_stack = { STACK_TYPE_TASK, (unsigned long)_stack_start,
17256d78d0SAlexander Egorenkov (unsigned long)_stack_end };
188977ab65SVasily Gorbik bool first = true;
198977ab65SVasily Gorbik
20*bfda6108SHeiko Carstens boot_printk("Call Trace:\n");
218977ab65SVasily Gorbik while (!(sp & 0x7) && on_stack(&boot_stack, sp, sizeof(struct stack_frame))) {
228977ab65SVasily Gorbik struct stack_frame *sf = (struct stack_frame *)sp;
238977ab65SVasily Gorbik
24*bfda6108SHeiko Carstens boot_printk(first ? "(sp:%016lx [<%016lx>] %pS)\n" :
258977ab65SVasily Gorbik " sp:%016lx [<%016lx>] %pS\n",
268977ab65SVasily Gorbik sp, sf->gprs[8], (void *)sf->gprs[8]);
278977ab65SVasily Gorbik if (sf->back_chain <= sp)
288977ab65SVasily Gorbik break;
298977ab65SVasily Gorbik sp = sf->back_chain;
308977ab65SVasily Gorbik first = false;
318977ab65SVasily Gorbik }
328977ab65SVasily Gorbik }
338977ab65SVasily Gorbik
print_pgm_check_info(void)34724dc336SVasily Gorbik void print_pgm_check_info(void)
35724dc336SVasily Gorbik {
36bbf78606SSven Schnelle unsigned long *gpregs = (unsigned long *)get_lowcore()->gpregs_save_area;
37bbf78606SSven Schnelle struct psw_bits *psw = &psw_bits(get_lowcore()->psw_save_area);
38724dc336SVasily Gorbik
39*bfda6108SHeiko Carstens boot_printk("Linux version %s\n", kernel_version);
40ba1a6be9SVasily Gorbik if (!is_prot_virt_guest() && early_command_line[0])
41*bfda6108SHeiko Carstens boot_printk("Kernel command line: %s\n", early_command_line);
42*bfda6108SHeiko Carstens boot_printk("Kernel fault: interruption code %04x ilc:%x\n",
43bbf78606SSven Schnelle get_lowcore()->pgm_code, get_lowcore()->pgm_ilc >> 1);
443bb11234SAlexander Gordeev if (kaslr_enabled()) {
45*bfda6108SHeiko Carstens boot_printk("Kernel random base: %lx\n", __kaslr_offset);
46*bfda6108SHeiko Carstens boot_printk("Kernel random base phys: %lx\n", __kaslr_offset_phys);
473bb11234SAlexander Gordeev }
48*bfda6108SHeiko Carstens boot_printk("PSW : %016lx %016lx (%pS)\n",
49bbf78606SSven Schnelle get_lowcore()->psw_save_area.mask,
50bbf78606SSven Schnelle get_lowcore()->psw_save_area.addr,
51bbf78606SSven Schnelle (void *)get_lowcore()->psw_save_area.addr);
52*bfda6108SHeiko Carstens boot_printk(
539a78c70aSVasily Gorbik " 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",
549a78c70aSVasily Gorbik psw->per, psw->dat, psw->io, psw->ext, psw->key, psw->mcheck,
559a78c70aSVasily Gorbik psw->wait, psw->pstate, psw->as, psw->cc, psw->pm, psw->ri,
569a78c70aSVasily Gorbik psw->eaba);
57*bfda6108SHeiko Carstens boot_printk("GPRS: %016lx %016lx %016lx %016lx\n", gpregs[0], gpregs[1], gpregs[2], gpregs[3]);
58*bfda6108SHeiko Carstens boot_printk(" %016lx %016lx %016lx %016lx\n", gpregs[4], gpregs[5], gpregs[6], gpregs[7]);
59*bfda6108SHeiko Carstens boot_printk(" %016lx %016lx %016lx %016lx\n", gpregs[8], gpregs[9], gpregs[10], gpregs[11]);
60*bfda6108SHeiko Carstens boot_printk(" %016lx %016lx %016lx %016lx\n", gpregs[12], gpregs[13], gpregs[14], gpregs[15]);
61bbf78606SSven Schnelle print_stacktrace(get_lowcore()->gpregs_save_area[15]);
62*bfda6108SHeiko Carstens boot_printk("Last Breaking-Event-Address:\n");
63*bfda6108SHeiko Carstens boot_printk(" [<%016lx>] %pS\n", (unsigned long)get_lowcore()->pgm_last_break,
64bbf78606SSven Schnelle (void *)get_lowcore()->pgm_last_break);
65724dc336SVasily Gorbik }
66