From fe08ac4a67ed119e27a015df99e88b14d504ce3c Mon Sep 17 00:00:00 2001 From: Dominique Martinet Date: Mon, 4 Feb 2019 15:58:54 +0900 Subject: [PATCH] arm: turn off cpu on panic Since interrupts are disabled on panic, linux cannot reset a panic'd core when NMI are disabled (for e.g. mcreboot/mcstop) Just always offline it, so linux can get it back Change-Id: If8107172375f2924e02bd4c36e24645ec38a8999 --- arch/arm64/kernel/cpu.c | 7 ++++++- arch/x86_64/kernel/cpu.c | 10 +++++++++- lib/abort.c | 8 ++++++-- 3 files changed, 21 insertions(+), 4 deletions(-) diff --git a/arch/arm64/kernel/cpu.c b/arch/arm64/kernel/cpu.c index 3895ff67..addd7ea6 100644 --- a/arch/arm64/kernel/cpu.c +++ b/arch/arm64/kernel/cpu.c @@ -1274,7 +1274,7 @@ void ihk_mc_delay_us(int us) arch_delay(us); } -void arch_print_stack() +void arch_print_stack(void) { } @@ -1310,6 +1310,11 @@ void arch_show_interrupt_context(const void *reg) kprintf(" syscallno : %016lx\n", regs->syscallno); } +void arch_cpu_stop(void) +{ + psci_cpu_off(); +} + /*@ @ behavior fs_base: @ assumes type == IHK_ASR_X86_FS; diff --git a/arch/x86_64/kernel/cpu.c b/arch/x86_64/kernel/cpu.c index 3b60a763..fb7d787c 100644 --- a/arch/x86_64/kernel/cpu.c +++ b/arch/x86_64/kernel/cpu.c @@ -1551,7 +1551,8 @@ void arch_print_pre_interrupt_stack(const struct x86_basic_regs *regs) { __print_stack(rbp, regs->rip); } -void arch_print_stack() { +void arch_print_stack(void) +{ struct stack *rbp; __kprintf("Approximative stack trace:\n"); @@ -1599,6 +1600,13 @@ return; kprintf_unlock(irqflags); } +void arch_cpu_stop(void) +{ + while (1) { + cpu_halt(); + } +} + /*@ @ behavior fs_base: @ assumes type == IHK_ASR_X86_FS; diff --git a/lib/abort.c b/lib/abort.c index 1103a1af..18702589 100644 --- a/lib/abort.c +++ b/lib/abort.c @@ -4,8 +4,9 @@ #include extern struct cpu_local_var *clv; -extern void eventfd(int type); -extern void arch_print_stack(); +void eventfd(int type); +void arch_print_stack(void); +void arch_cpu_stop(void); void panic(const char *msg) { @@ -21,6 +22,9 @@ void panic(const char *msg) arch_print_stack(); + /* do not assume anything after this is executed */ + arch_cpu_stop(); + while (1) { cpu_halt(); }