From 8f2c8791bf71bfc6c3d6e925ab6e09e69a70ee4a Mon Sep 17 00:00:00 2001 From: Masamichi Takagi Date: Mon, 15 Jun 2020 12:55:00 +0900 Subject: [PATCH] TO RESET: arm64: enable interrupt on panic Change-Id: I1ceb321de324f307fc82366b162c72f64184247b --- arch/arm64/kernel/cpu.c | 13 +++++++++++++ arch/arm64/kernel/irq-gic-v3.c | 21 +++++++++++++++++++++ arch/x86_64/kernel/cpu.c | 11 +++++++++++ lib/abort.c | 6 ++++++ lib/include/ihk/cpu.h | 3 +++ 5 files changed, 54 insertions(+) diff --git a/arch/arm64/kernel/cpu.c b/arch/arm64/kernel/cpu.c index fa53d20f..f9f933c6 100644 --- a/arch/arm64/kernel/cpu.c +++ b/arch/arm64/kernel/cpu.c @@ -791,6 +791,19 @@ void cpu_safe_halt(void) cpu_enable_interrupt(); } +#ifdef ENABLE_FUGAKU_HACKS +/*@ + @ assigns \nothing; + @ ensures \interrupt_disabled == 0; + @*/ +void cpu_halt_panic(void) +{ + extern void __cpu_do_idle(void); + cpu_enable_interrupt(); + __cpu_do_idle(); +} +#endif + #if defined(CONFIG_HAS_NMI) #include diff --git a/arch/arm64/kernel/irq-gic-v3.c b/arch/arm64/kernel/irq-gic-v3.c index c356efb3..113ec4bc 100644 --- a/arch/arm64/kernel/irq-gic-v3.c +++ b/arch/arm64/kernel/irq-gic-v3.c @@ -7,6 +7,9 @@ #include #include #include +#ifdef ENABLE_FUGAKU_HACKS +#include +#endif #include #include @@ -313,14 +316,27 @@ void handle_interrupt_gicv3(struct pt_regs *regs) struct cpu_local_var *v = get_this_cpu_local_var(); //unsigned long irqflags; int do_check = 0; +#ifdef ENABLE_FUGAKU_HACKS + struct ihk_os_cpu_monitor *monitor = cpu_local_var(monitor); + ++v->in_interrupt; +#endif irqnr = gic_read_iar(); cpu_enable_nmi(); set_cputime(from_user ? CPUTIME_MODE_U2K : CPUTIME_MODE_K2K_IN); while (irqnr != ICC_IAR1_EL1_SPURIOUS) { if ((irqnr < 1020) || (irqnr >= 8192)) { gic_write_eoir(irqnr); +#ifndef ENABLE_FUGAKU_HACKS handle_IPI(irqnr, regs); +#else + /* Once paniced, only allow CPU stop and NMI IRQs */ + if (monitor->status != IHK_OS_MONITOR_PANIC || + irqnr == INTRID_CPU_STOP || + irqnr == INTRID_MULTI_NMI) { + handle_IPI(irqnr, regs); + } +#endif } irqnr = gic_read_iar(); } @@ -335,7 +351,12 @@ void handle_interrupt_gicv3(struct pt_regs *regs) } //ihk_mc_spinlock_unlock(&v->runq_lock, irqflags); +#ifndef ENABLE_FUGAKU_HACKS if (do_check) { +#else + --v->in_interrupt; + if (monitor->status != IHK_OS_MONITOR_PANIC && do_check) { +#endif check_signal(0, regs, 0); schedule(); } diff --git a/arch/x86_64/kernel/cpu.c b/arch/x86_64/kernel/cpu.c index 0bb0ccf3..ebe9c6d9 100644 --- a/arch/x86_64/kernel/cpu.c +++ b/arch/x86_64/kernel/cpu.c @@ -1137,6 +1137,17 @@ void cpu_halt(void) asm volatile("hlt"); } +#ifdef ENABLE_FUGAKU_HACKS +/*@ + @ assigns \nothing; + @ ensures \interrupt_disabled == 0; + @*/ +void cpu_halt_panic(void) +{ + cpu_halt(); +} +#endif + /*@ @ assigns \nothing; @ ensures \interrupt_disabled == 0; diff --git a/lib/abort.c b/lib/abort.c index 18702589..3641829e 100644 --- a/lib/abort.c +++ b/lib/abort.c @@ -22,12 +22,18 @@ void panic(const char *msg) arch_print_stack(); +#ifndef ENABLE_FUGAKU_HACKS /* do not assume anything after this is executed */ arch_cpu_stop(); while (1) { cpu_halt(); } +#else + while (1) { + cpu_halt_panic(); + } +#endif } extern void arch_show_interrupt_context(const void*); diff --git a/lib/include/ihk/cpu.h b/lib/include/ihk/cpu.h index f572432e..7a1e499e 100644 --- a/lib/include/ihk/cpu.h +++ b/lib/include/ihk/cpu.h @@ -24,6 +24,9 @@ extern int num_processors; void cpu_enable_interrupt(void); void cpu_disable_interrupt(void); void cpu_halt(void); +#ifdef ENABLE_FUGAKU_HACKS +void cpu_halt_panic(void); +#endif void cpu_safe_halt(void); void cpu_restore_interrupt(unsigned long); void cpu_pause(void);