]> nv-tegra.nvidia Code Review - linux-2.6.git/commitdiff
x86: fix die() to not be preemptible
authorIngo Molnar <mingo@elte.hu>
Fri, 21 Dec 2007 00:27:19 +0000 (01:27 +0100)
committerIngo Molnar <mingo@elte.hu>
Fri, 21 Dec 2007 00:27:19 +0000 (01:27 +0100)
Andrew "Eagle Eye" Morton noticed that we use raw_local_save_flags()
instead of raw_local_irq_save(flags) in die(). This allows the
preemption of oopsing contexts - which is highly undesirable. It also
causes CONFIG_DEBUG_PREEMPT to complain, as reported by Miles Lane.

this bug was introduced via:

  commit 39743c9ef717fd4f2b5583f010115c5f2482b8ae
  Author: Andi Kleen <ak@suse.de>
  Date:   Fri Oct 19 20:35:03 2007 +0200

      x86: use raw locks during oopses

-               spin_lock_irqsave(&die.lock, flags);
+               __raw_spin_lock(&die.lock);
+               raw_local_save_flags(flags);

that is not a correct open-coding of spin_lock_irqsave(): both the
ordering is wrong (irqs should be disabled _first_), and the wrong
flags-saving API was used.

Signed-off-by: Ingo Molnar <mingo@elte.hu>
arch/x86/kernel/traps_32.c

index ef601026259775ae1f426b63f8808257615a37ef..c88bbffcaa03ed9485dddc721f6bf611c6982ae2 100644 (file)
@@ -373,14 +373,13 @@ void die(const char * str, struct pt_regs * regs, long err)
 
        if (die.lock_owner != raw_smp_processor_id()) {
                console_verbose();
+               raw_local_irq_save(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
-               raw_local_save_flags(flags);
+       } else
+               raw_local_irq_save(flags);
 
        if (++die.lock_owner_depth < 3) {
                unsigned long esp;