Kernel/SMP: Fix RecursiveSpinLock remembering the wrong CPU when locking
We have to disable interrupts before capturing the current Processor*, or we risk storing the wrong one if we get preempted and resume on a different CPU. Caught by the VERIFY in RecursiveSpinLock::unlock()
This commit is contained in:
parent
5e27861c2e
commit
7f50805903
Notes:
sideshowbarker
2024-07-18 07:07:11 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/7f508059036
1 changed files with 3 additions and 3 deletions
|
@ -66,11 +66,11 @@ public:
|
|||
|
||||
ALWAYS_INLINE u32 lock()
|
||||
{
|
||||
u32 prev_flags = cpu_flags();
|
||||
cli();
|
||||
Processor::enter_critical();
|
||||
auto& proc = Processor::current();
|
||||
FlatPtr cpu = FlatPtr(&proc);
|
||||
u32 prev_flags = cpu_flags();
|
||||
Processor::enter_critical();
|
||||
cli();
|
||||
FlatPtr expected = 0;
|
||||
while (!m_lock.compare_exchange_strong(expected, cpu, AK::memory_order_acq_rel)) {
|
||||
if (expected == cpu)
|
||||
|
|
Loading…
Add table
Reference in a new issue