Skip to content

Commit

Permalink
x86: use raw locks during oopses
Browse files Browse the repository at this point in the history
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: Andi Kleen <ak@suse.de>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
  • Loading branch information
Andi Kleen authored and Thomas Gleixner committed Oct 19, 2007
1 parent b1992df commit 39743c9
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
12 changes: 7 additions & 5 deletions arch/x86/kernel/traps_32.c
Original file line number Diff line number Diff line change
Expand Up @@ -350,11 +350,11 @@ int is_valid_bugaddr(unsigned long eip)
void die(const char * str, struct pt_regs * regs, long err)
{
static struct {
spinlock_t lock;
raw_spinlock_t lock;
u32 lock_owner;
int lock_owner_depth;
} die = {
.lock = __SPIN_LOCK_UNLOCKED(die.lock),
.lock = __RAW_SPIN_LOCK_UNLOCKED,
.lock_owner = -1,
.lock_owner_depth = 0
};
Expand All @@ -365,13 +365,14 @@ void die(const char * str, struct pt_regs * regs, long err)

if (die.lock_owner != raw_smp_processor_id()) {
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_depth = 0;
bust_spinlocks(1);
}
else
local_save_flags(flags);
raw_local_save_flags(flags);

if (++die.lock_owner_depth < 3) {
unsigned long esp;
Expand Down Expand Up @@ -415,7 +416,8 @@ void die(const char * str, struct pt_regs * regs, long err)
bust_spinlocks(0);
die.lock_owner = -1;
add_taint(TAINT_DIE);
spin_unlock_irqrestore(&die.lock, flags);
__raw_spin_unlock(&die.lock);
raw_local_irq_restore(flags);

if (!regs)
return;
Expand Down
16 changes: 7 additions & 9 deletions arch/x86/kernel/traps_64.c
Original file line number Diff line number Diff line change
Expand Up @@ -462,7 +462,7 @@ void out_of_line_bug(void)
EXPORT_SYMBOL(out_of_line_bug);
#endif

static DEFINE_SPINLOCK(die_lock);
static raw_spinlock_t die_lock = __RAW_SPIN_LOCK_UNLOCKED;
static int die_owner = -1;
static unsigned int die_nest_count;

Expand All @@ -474,13 +474,13 @@ unsigned __kprobes long oops_begin(void)
oops_enter();

/* racy, but better than risking deadlock. */
local_irq_save(flags);
raw_local_irq_save(flags);
cpu = smp_processor_id();
if (!spin_trylock(&die_lock)) {
if (!__raw_spin_trylock(&die_lock)) {
if (cpu == die_owner)
/* nested oops. should stop eventually */;
else
spin_lock(&die_lock);
__raw_spin_lock(&die_lock);
}
die_nest_count++;
die_owner = cpu;
Expand All @@ -494,12 +494,10 @@ void __kprobes oops_end(unsigned long flags)
die_owner = -1;
bust_spinlocks(0);
die_nest_count--;
if (die_nest_count)
/* We still own the lock */
local_irq_restore(flags);
else
if (!die_nest_count)
/* 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)
panic("Fatal exception");
oops_exit();
Expand Down

0 comments on commit 39743c9

Please sign in to comment.