Loading arch/arm64/kernel/traps.c +49 −17 Original line number Diff line number Diff line Loading @@ -218,44 +218,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) { Loading Loading
arch/arm64/kernel/traps.c +49 −17 Original line number Diff line number Diff line Loading @@ -218,44 +218,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) { Loading