x86: introduce __die helper to X86_32

Small step towards unifying traps_32|64.c.  No functional
changes.  Pull out a small helper from an if() statement
in die().

Marked as __kprobes as eventually we will want to call this
from do_page_fault similar to how X86_64 does it.

Signed-off-by: Harvey Harrison <harvey.harrison@gmail.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
This commit is contained in:
Harvey Harrison 2008-01-30 13:32:59 +01:00 committed by Ingo Molnar
parent c68461b67d
commit a604b38036
1 changed files with 42 additions and 34 deletions

View File

@ -352,44 +352,14 @@ int is_valid_bugaddr(unsigned long ip)
return ud2 == 0x0b0f;
}
/*
* This is gone through when something in the kernel has done something bad and
* is about to be terminated.
*/
void die(const char * str, struct pt_regs * regs, long err)
{
static struct {
raw_spinlock_t lock;
u32 lock_owner;
int lock_owner_depth;
} die = {
.lock = __RAW_SPIN_LOCK_UNLOCKED,
.lock_owner = -1,
.lock_owner_depth = 0
};
static int die_counter;
unsigned long flags;
oops_enter();
if (die.lock_owner != raw_smp_processor_id()) {
console_verbose();
raw_local_irq_save(flags);
__raw_spin_lock(&die.lock);
die.lock_owner = smp_processor_id();
die.lock_owner_depth = 0;
bust_spinlocks(1);
} else
raw_local_irq_save(flags);
if (++die.lock_owner_depth < 3) {
int __kprobes __die(const char * str, struct pt_regs * regs, long err)
{
unsigned long sp;
unsigned short ss;
report_bug(regs->ip, regs);
printk(KERN_EMERG "%s: %04lx [#%d] ", str, err & 0xffff,
++die_counter);
printk(KERN_EMERG "%s: %04lx [#%d] ", str, err & 0xffff, ++die_counter);
#ifdef CONFIG_PREEMPT
printk("PREEMPT ");
#endif
@ -415,11 +385,49 @@ void die(const char * str, struct pt_regs * regs, long err)
printk(KERN_EMERG "EIP: [<%08lx>] ", regs->ip);
print_symbol("%s", regs->ip);
printk(" SS:ESP %04x:%08lx\n", ss, sp);
return 0;
} else {
return 1;
}
else
regs = NULL;
}
/*
* This is gone through when something in the kernel has done something bad and
* is about to be terminated.
*/
void die(const char * str, struct pt_regs * regs, long err)
{
static struct {
raw_spinlock_t lock;
u32 lock_owner;
int lock_owner_depth;
} die = {
.lock = __RAW_SPIN_LOCK_UNLOCKED,
.lock_owner = -1,
.lock_owner_depth = 0
};
unsigned long flags;
oops_enter();
if (die.lock_owner != raw_smp_processor_id()) {
console_verbose();
raw_local_irq_save(flags);
__raw_spin_lock(&die.lock);
die.lock_owner = smp_processor_id();
die.lock_owner_depth = 0;
bust_spinlocks(1);
} else
raw_local_irq_save(flags);
if (++die.lock_owner_depth < 3) {
report_bug(regs->ip, regs);
if (__die(str, regs, err))
regs = NULL;
} else {
printk(KERN_EMERG "Recursive die() failure, output suppressed\n");
}
bust_spinlocks(0);
die.lock_owner = -1;