2019-08-08 20:09:08 +02:00
|
|
|
// SPDX-License-Identifier: GPL-2.0
|
|
|
|
#include <linux/kernel.h>
|
2021-08-02 23:40:32 +03:00
|
|
|
#include <linux/stdarg.h>
|
2019-08-08 20:09:08 +02:00
|
|
|
#include <linux/string.h>
|
2020-11-10 17:05:26 +01:00
|
|
|
#include <linux/ctype.h>
|
2020-11-10 17:05:35 +01:00
|
|
|
#include <asm/stacktrace.h>
|
2020-11-10 23:30:23 +01:00
|
|
|
#include <asm/boot_data.h>
|
2019-08-08 20:09:08 +02:00
|
|
|
#include <asm/lowcore.h>
|
2019-08-11 20:23:56 +02:00
|
|
|
#include <asm/setup.h>
|
2019-08-08 20:09:08 +02:00
|
|
|
#include <asm/sclp.h>
|
2020-11-10 23:30:23 +01:00
|
|
|
#include <asm/uv.h>
|
2019-08-08 20:09:08 +02:00
|
|
|
#include "boot.h"
|
|
|
|
|
2023-02-02 13:59:36 +01:00
|
|
|
void print_stacktrace(unsigned long sp)
|
2020-11-10 17:05:35 +01:00
|
|
|
{
|
2021-06-30 17:17:53 +02:00
|
|
|
struct stack_info boot_stack = { STACK_TYPE_TASK, (unsigned long)_stack_start,
|
|
|
|
(unsigned long)_stack_end };
|
2020-11-10 17:05:35 +01:00
|
|
|
bool first = true;
|
|
|
|
|
2024-11-20 17:07:56 +01:00
|
|
|
boot_emerg("Call Trace:\n");
|
2020-11-10 17:05:35 +01:00
|
|
|
while (!(sp & 0x7) && on_stack(&boot_stack, sp, sizeof(struct stack_frame))) {
|
|
|
|
struct stack_frame *sf = (struct stack_frame *)sp;
|
|
|
|
|
2024-11-20 17:07:56 +01:00
|
|
|
if (first)
|
|
|
|
boot_emerg("(sp:%016lx [<%016lx>] %pS)\n", sp, sf->gprs[8], (void *)sf->gprs[8]);
|
|
|
|
else
|
|
|
|
boot_emerg(" sp:%016lx [<%016lx>] %pS\n", sp, sf->gprs[8], (void *)sf->gprs[8]);
|
2020-11-10 17:05:35 +01:00
|
|
|
if (sf->back_chain <= sp)
|
|
|
|
break;
|
|
|
|
sp = sf->back_chain;
|
|
|
|
first = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2025-02-24 15:59:05 +01:00
|
|
|
extern struct exception_table_entry __start___ex_table[];
|
|
|
|
extern struct exception_table_entry __stop___ex_table[];
|
|
|
|
|
|
|
|
static inline unsigned long extable_insn(const struct exception_table_entry *x)
|
|
|
|
{
|
|
|
|
return (unsigned long)&x->insn + x->insn;
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool ex_handler(struct pt_regs *regs)
|
|
|
|
{
|
|
|
|
const struct exception_table_entry *ex;
|
|
|
|
|
|
|
|
for (ex = __start___ex_table; ex < __stop___ex_table; ex++) {
|
|
|
|
if (extable_insn(ex) != regs->psw.addr)
|
|
|
|
continue;
|
|
|
|
if (ex->type != EX_TYPE_FIXUP)
|
|
|
|
return false;
|
|
|
|
regs->psw.addr = extable_fixup(ex);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
void do_pgm_check(struct pt_regs *regs)
|
2020-11-10 17:05:26 +01:00
|
|
|
{
|
2025-02-24 15:59:04 +01:00
|
|
|
struct psw_bits *psw = &psw_bits(regs->psw);
|
|
|
|
unsigned long *gpregs = regs->gprs;
|
2019-08-08 20:09:08 +02:00
|
|
|
|
2025-02-24 15:59:05 +01:00
|
|
|
if (ex_handler(regs))
|
|
|
|
return;
|
2024-11-20 20:30:10 +01:00
|
|
|
if (bootdebug)
|
|
|
|
boot_rb_dump();
|
2024-11-20 17:07:56 +01:00
|
|
|
boot_emerg("Linux version %s\n", kernel_version);
|
2020-11-10 23:30:23 +01:00
|
|
|
if (!is_prot_virt_guest() && early_command_line[0])
|
2024-11-20 17:07:56 +01:00
|
|
|
boot_emerg("Kernel command line: %s\n", early_command_line);
|
2024-11-24 14:47:58 +01:00
|
|
|
boot_emerg("Kernel fault: interruption code %04x ilc:%d\n",
|
2025-02-24 15:59:04 +01:00
|
|
|
regs->int_code & 0xffff, regs->int_code >> 17);
|
2024-02-20 14:35:43 +01:00
|
|
|
if (kaslr_enabled()) {
|
2024-11-20 17:07:56 +01:00
|
|
|
boot_emerg("Kernel random base: %lx\n", __kaslr_offset);
|
|
|
|
boot_emerg("Kernel random base phys: %lx\n", __kaslr_offset_phys);
|
2024-02-20 14:35:43 +01:00
|
|
|
}
|
2024-11-20 17:07:56 +01:00
|
|
|
boot_emerg("PSW : %016lx %016lx (%pS)\n",
|
2025-02-24 15:59:04 +01:00
|
|
|
regs->psw.mask, regs->psw.addr, (void *)regs->psw.addr);
|
2024-11-20 17:07:56 +01:00
|
|
|
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",
|
|
|
|
psw->per, psw->dat, psw->io, psw->ext, psw->key, psw->mcheck,
|
|
|
|
psw->wait, psw->pstate, psw->as, psw->cc, psw->pm, psw->ri, psw->eaba);
|
|
|
|
boot_emerg("GPRS: %016lx %016lx %016lx %016lx\n", gpregs[0], gpregs[1], gpregs[2], gpregs[3]);
|
|
|
|
boot_emerg(" %016lx %016lx %016lx %016lx\n", gpregs[4], gpregs[5], gpregs[6], gpregs[7]);
|
|
|
|
boot_emerg(" %016lx %016lx %016lx %016lx\n", gpregs[8], gpregs[9], gpregs[10], gpregs[11]);
|
|
|
|
boot_emerg(" %016lx %016lx %016lx %016lx\n", gpregs[12], gpregs[13], gpregs[14], gpregs[15]);
|
2025-02-24 15:59:04 +01:00
|
|
|
print_stacktrace(gpregs[15]);
|
2024-11-20 17:07:56 +01:00
|
|
|
boot_emerg("Last Breaking-Event-Address:\n");
|
2025-02-24 15:59:04 +01:00
|
|
|
boot_emerg(" [<%016lx>] %pS\n", regs->last_break, (void *)regs->last_break);
|
2025-02-24 15:59:05 +01:00
|
|
|
/* Convert to disabled wait PSW */
|
|
|
|
psw->io = 0;
|
|
|
|
psw->ext = 0;
|
|
|
|
psw->wait = 1;
|
2019-08-08 20:09:08 +02:00
|
|
|
}
|