Skip to content
Snippets Groups Projects
Commit 041526ef authored by Stepan Moskovchenko's avatar Stepan Moskovchenko Committed by Matt Wagantall
Browse files

arm64: update die handler from ARM / x86


Commit 02df19b4 ("ARM:
7424/1: update die handler from x86") refactored the ARM
die() logic to avoid a deadlock if a kernel oops happens
while holding a spinlock that may also be used in an IRQ
handler. Refactor the ARM64 die() handler in a similar way,
to avoid similar deadlocks, which would have otherwise
prevented the kernel from printing the full panic output
and properly completing the panic() path.

Change-Id: I217a8d719f64b54467fa88a583d83f72193d7580
Signed-off-by: default avatarStepan Moskovchenko <stepanm@codeaurora.org>
parent 53db565d
No related branches found
No related tags found
No related merge requests found
......@@ -214,44 +214,76 @@ static int __die(const char *str, int err, struct thread_info *thread,
return ret;
}
static DEFINE_RAW_SPINLOCK(die_lock);
static arch_spinlock_t die_lock = __ARCH_SPIN_LOCK_UNLOCKED;
static int die_owner = -1;
static unsigned int die_nest_count;
/*
* This function is protected against re-entrancy.
*/
void die(const char *str, struct pt_regs *regs, int err)
static unsigned long oops_begin(void)
{
struct thread_info *thread = current_thread_info();
int ret;
enum bug_trap_type bug_type = BUG_TRAP_TYPE_NONE;
int cpu;
unsigned long flags;
oops_enter();
raw_spin_lock_irq(&die_lock);
/* racy, but better than risking deadlock. */
raw_local_irq_save(flags);
cpu = smp_processor_id();
if (!arch_spin_trylock(&die_lock)) {
if (cpu == die_owner)
/* nested oops. should stop eventually */;
else
arch_spin_lock(&die_lock);
}
die_nest_count++;
die_owner = cpu;
console_verbose();
bust_spinlocks(1);
if (!user_mode(regs))
bug_type = report_bug(regs->pc, regs);
if (bug_type != BUG_TRAP_TYPE_NONE)
str = "Oops - BUG";
ret = __die(str, err, thread, regs);
return flags;
}
if (regs && kexec_should_crash(thread->task))
static void oops_end(unsigned long flags, struct pt_regs *regs, int notify)
{
if (regs && kexec_should_crash(current))
crash_kexec(regs);
bust_spinlocks(0);
die_owner = -1;
add_taint(TAINT_DIE, LOCKDEP_NOW_UNRELIABLE);
raw_spin_unlock_irq(&die_lock);
die_nest_count--;
if (!die_nest_count)
/* Nest count reaches zero, release the lock. */
arch_spin_unlock(&die_lock);
raw_local_irq_restore(flags);
oops_exit();
if (in_interrupt())
panic("Fatal exception in interrupt");
if (panic_on_oops)
panic("Fatal exception");
if (ret != NOTIFY_STOP)
if (notify != NOTIFY_STOP)
do_exit(SIGSEGV);
}
/*
* This function is protected against re-entrancy.
*/
void die(const char *str, struct pt_regs *regs, int err)
{
struct thread_info *thread = current_thread_info();
enum bug_trap_type bug_type = BUG_TRAP_TYPE_NONE;
unsigned long flags = oops_begin();
int ret;
if (!user_mode(regs))
bug_type = report_bug(regs->pc, regs);
if (bug_type != BUG_TRAP_TYPE_NONE)
str = "Oops - BUG";
ret = __die(str, err, thread, regs);
oops_end(flags, regs, ret);
}
void arm64_notify_die(const char *str, struct pt_regs *regs,
struct siginfo *info, int err)
{
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment