aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexander van Heukelum <heukelum@fastmail.fm>2008-07-10 15:14:52 -0400
committerIngo Molnar <mingo@elte.hu>2008-07-18 10:21:17 -0400
commit78cbac65fd77242f3e5d77f4d7a71e8bc869fe4d (patch)
tree8ada810cc1f2f1f26644f6517b7f131fdb130c5d
parent5b664cb235e97afbf34db9c4d77f08ebd725335e (diff)
x86: traps_xx: refactor die() like in x86_64
Make the diff between the traps_32.c and traps_64.c a bit smaller. Change traps_32.c to look more like traps_64.c: - move lock information to file scope - split out oops_begin() and oops_end() from die() - increment nest counter in oops_begin Only whitespace change in traps_64.c No functional changes intended. Signed-off-by: Alexander van Heukelum <heukelum@fastmail.fm> Acked-by: Cyrill Gorcunov <gorcunov@gmail.com> Signed-off-by: Ingo Molnar <mingo@elte.hu>
-rw-r--r--arch/x86/kernel/traps_32.c95
-rw-r--r--arch/x86/kernel/traps_64.c2
2 files changed, 52 insertions, 45 deletions
diff --git a/arch/x86/kernel/traps_32.c b/arch/x86/kernel/traps_32.c
index 8a768973c4f0..51cccde376a5 100644
--- a/arch/x86/kernel/traps_32.c
+++ b/arch/x86/kernel/traps_32.c
@@ -383,6 +383,54 @@ int is_valid_bugaddr(unsigned long ip)
383 return ud2 == 0x0b0f; 383 return ud2 == 0x0b0f;
384} 384}
385 385
386static raw_spinlock_t die_lock = __RAW_SPIN_LOCK_UNLOCKED;
387static int die_owner = -1;
388static unsigned int die_nest_count;
389
390unsigned __kprobes long oops_begin(void)
391{
392 unsigned long flags;
393
394 oops_enter();
395
396 if (die_owner != raw_smp_processor_id()) {
397 console_verbose();
398 raw_local_irq_save(flags);
399 __raw_spin_lock(&die_lock);
400 die_owner = smp_processor_id();
401 die_nest_count = 0;
402 bust_spinlocks(1);
403 } else {
404 raw_local_irq_save(flags);
405 }
406 die_nest_count++;
407 return flags;
408}
409
410void __kprobes oops_end(unsigned long flags, struct pt_regs *regs, int signr)
411{
412 bust_spinlocks(0);
413 die_owner = -1;
414 add_taint(TAINT_DIE);
415 __raw_spin_unlock(&die_lock);
416 raw_local_irq_restore(flags);
417
418 if (!regs)
419 return;
420
421 if (kexec_should_crash(current))
422 crash_kexec(regs);
423
424 if (in_interrupt())
425 panic("Fatal exception in interrupt");
426
427 if (panic_on_oops)
428 panic("Fatal exception");
429
430 oops_exit();
431 do_exit(signr);
432}
433
386int __kprobes __die(const char *str, struct pt_regs *regs, long err) 434int __kprobes __die(const char *str, struct pt_regs *regs, long err)
387{ 435{
388 unsigned short ss; 436 unsigned short ss;
@@ -423,31 +471,9 @@ int __kprobes __die(const char *str, struct pt_regs *regs, long err)
423 */ 471 */
424void die(const char *str, struct pt_regs *regs, long err) 472void die(const char *str, struct pt_regs *regs, long err)
425{ 473{
426 static struct { 474 unsigned long flags = oops_begin();
427 raw_spinlock_t lock;
428 u32 lock_owner;
429 int lock_owner_depth;
430 } die = {
431 .lock = __RAW_SPIN_LOCK_UNLOCKED,
432 .lock_owner = -1,
433 .lock_owner_depth = 0
434 };
435 unsigned long flags;
436
437 oops_enter();
438
439 if (die.lock_owner != raw_smp_processor_id()) {
440 console_verbose();
441 raw_local_irq_save(flags);
442 __raw_spin_lock(&die.lock);
443 die.lock_owner = smp_processor_id();
444 die.lock_owner_depth = 0;
445 bust_spinlocks(1);
446 } else {
447 raw_local_irq_save(flags);
448 }
449 475
450 if (++die.lock_owner_depth < 3) { 476 if (die_nest_count < 3) {
451 report_bug(regs->ip, regs); 477 report_bug(regs->ip, regs);
452 478
453 if (__die(str, regs, err)) 479 if (__die(str, regs, err))
@@ -456,26 +482,7 @@ void die(const char *str, struct pt_regs *regs, long err)
456 printk(KERN_EMERG "Recursive die() failure, output suppressed\n"); 482 printk(KERN_EMERG "Recursive die() failure, output suppressed\n");
457 } 483 }
458 484
459 bust_spinlocks(0); 485 oops_end(flags, regs, SIGSEGV);
460 die.lock_owner = -1;
461 add_taint(TAINT_DIE);
462 __raw_spin_unlock(&die.lock);
463 raw_local_irq_restore(flags);
464
465 if (!regs)
466 return;
467
468 if (kexec_should_crash(current))
469 crash_kexec(regs);
470
471 if (in_interrupt())
472 panic("Fatal exception in interrupt");
473
474 if (panic_on_oops)
475 panic("Fatal exception");
476
477 oops_exit();
478 do_exit(SIGSEGV);
479} 486}
480 487
481static inline void 488static inline void
diff --git a/arch/x86/kernel/traps_64.c b/arch/x86/kernel/traps_64.c
index 2696a6837782..babdbe673b7f 100644
--- a/arch/x86/kernel/traps_64.c
+++ b/arch/x86/kernel/traps_64.c
@@ -518,7 +518,7 @@ unsigned __kprobes long oops_begin(void)
518} 518}
519 519
520void __kprobes oops_end(unsigned long flags, struct pt_regs *regs, int signr) 520void __kprobes oops_end(unsigned long flags, struct pt_regs *regs, int signr)
521{ 521{
522 die_owner = -1; 522 die_owner = -1;
523 bust_spinlocks(0); 523 bust_spinlocks(0);
524 die_nest_count--; 524 die_nest_count--;