Kernel/x86: Don't re-enable interrupts too soon when unlocking spinlocks

To ensure that we stay on the same CPU that acquired the spinlock until
we're completely unlocked, we now leave the critical section *before*
re-enabling interrupts.
This commit is contained in:
Andreas Kling 2022-08-17 22:41:06 +02:00
commit ae3fa20252
Notes: sideshowbarker 2024-07-17 08:09:36 +09:00

View file

@ -24,12 +24,13 @@ void Spinlock::unlock(u32 prev_flags)
VERIFY(is_locked());
track_lock_release(m_rank);
m_lock.store(0, AK::memory_order_release);
Processor::leave_critical();
if ((prev_flags & 0x200) != 0)
sti();
else
cli();
Processor::leave_critical();
}
u32 RecursiveSpinlock::lock()
@ -60,12 +61,13 @@ void RecursiveSpinlock::unlock(u32 prev_flags)
track_lock_release(m_rank);
m_lock.store(0, AK::memory_order_release);
}
Processor::leave_critical();
if ((prev_flags & 0x200) != 0)
sti();
else
cli();
Processor::leave_critical();
}
}