Commit 39743c9e authored by Andi Kleen's avatar Andi Kleen Committed by Thomas Gleixner

x86: use raw locks during oopses

Don't want any lockdep or other fragile machinery to run during oopses.
Use raw spinlocks directly for oops locking.
Also disables irq flag tracing there.

[ tglx: arch/x86 adaptation ]
Signed-off-by: default avatarAndi Kleen <ak@suse.de>
Signed-off-by: default avatarIngo Molnar <mingo@elte.hu>
Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
parent b1992df3
...@@ -350,11 +350,11 @@ int is_valid_bugaddr(unsigned long eip) ...@@ -350,11 +350,11 @@ int is_valid_bugaddr(unsigned long eip)
void die(const char * str, struct pt_regs * regs, long err) void die(const char * str, struct pt_regs * regs, long err)
{ {
static struct { static struct {
spinlock_t lock; raw_spinlock_t lock;
u32 lock_owner; u32 lock_owner;
int lock_owner_depth; int lock_owner_depth;
} die = { } die = {
.lock = __SPIN_LOCK_UNLOCKED(die.lock), .lock = __RAW_SPIN_LOCK_UNLOCKED,
.lock_owner = -1, .lock_owner = -1,
.lock_owner_depth = 0 .lock_owner_depth = 0
}; };
...@@ -365,13 +365,14 @@ void die(const char * str, struct pt_regs * regs, long err) ...@@ -365,13 +365,14 @@ void die(const char * str, struct pt_regs * regs, long err)
if (die.lock_owner != raw_smp_processor_id()) { if (die.lock_owner != raw_smp_processor_id()) {
console_verbose(); console_verbose();
spin_lock_irqsave(&die.lock, flags); __raw_spin_lock(&die.lock);
raw_local_save_flags(flags);
die.lock_owner = smp_processor_id(); die.lock_owner = smp_processor_id();
die.lock_owner_depth = 0; die.lock_owner_depth = 0;
bust_spinlocks(1); bust_spinlocks(1);
} }
else else
local_save_flags(flags); raw_local_save_flags(flags);
if (++die.lock_owner_depth < 3) { if (++die.lock_owner_depth < 3) {
unsigned long esp; unsigned long esp;
...@@ -415,7 +416,8 @@ void die(const char * str, struct pt_regs * regs, long err) ...@@ -415,7 +416,8 @@ void die(const char * str, struct pt_regs * regs, long err)
bust_spinlocks(0); bust_spinlocks(0);
die.lock_owner = -1; die.lock_owner = -1;
add_taint(TAINT_DIE); add_taint(TAINT_DIE);
spin_unlock_irqrestore(&die.lock, flags); __raw_spin_unlock(&die.lock);
raw_local_irq_restore(flags);
if (!regs) if (!regs)
return; return;
......
...@@ -462,7 +462,7 @@ void out_of_line_bug(void) ...@@ -462,7 +462,7 @@ void out_of_line_bug(void)
EXPORT_SYMBOL(out_of_line_bug); EXPORT_SYMBOL(out_of_line_bug);
#endif #endif
static DEFINE_SPINLOCK(die_lock); static raw_spinlock_t die_lock = __RAW_SPIN_LOCK_UNLOCKED;
static int die_owner = -1; static int die_owner = -1;
static unsigned int die_nest_count; static unsigned int die_nest_count;
...@@ -474,13 +474,13 @@ unsigned __kprobes long oops_begin(void) ...@@ -474,13 +474,13 @@ unsigned __kprobes long oops_begin(void)
oops_enter(); oops_enter();
/* racy, but better than risking deadlock. */ /* racy, but better than risking deadlock. */
local_irq_save(flags); raw_local_irq_save(flags);
cpu = smp_processor_id(); cpu = smp_processor_id();
if (!spin_trylock(&die_lock)) { if (!__raw_spin_trylock(&die_lock)) {
if (cpu == die_owner) if (cpu == die_owner)
/* nested oops. should stop eventually */; /* nested oops. should stop eventually */;
else else
spin_lock(&die_lock); __raw_spin_lock(&die_lock);
} }
die_nest_count++; die_nest_count++;
die_owner = cpu; die_owner = cpu;
...@@ -494,12 +494,10 @@ void __kprobes oops_end(unsigned long flags) ...@@ -494,12 +494,10 @@ void __kprobes oops_end(unsigned long flags)
die_owner = -1; die_owner = -1;
bust_spinlocks(0); bust_spinlocks(0);
die_nest_count--; die_nest_count--;
if (die_nest_count) if (!die_nest_count)
/* We still own the lock */
local_irq_restore(flags);
else
/* Nest count reaches zero, release the lock. */ /* Nest count reaches zero, release the lock. */
spin_unlock_irqrestore(&die_lock, flags); __raw_spin_unlock(&die_lock);
raw_local_irq_restore(flags);
if (panic_on_oops) if (panic_on_oops)
panic("Fatal exception"); panic("Fatal exception");
oops_exit(); oops_exit();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment