mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-09-30 00:31:14 +00:00
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
|
@ -66,11 +66,11 @@ public:
|
||||||
|
|
||||||
ALWAYS_INLINE u32 lock()
|
ALWAYS_INLINE u32 lock()
|
||||||
{
|
{
|
||||||
|
u32 prev_flags = cpu_flags();
|
||||||
|
cli();
|
||||||
|
Processor::enter_critical();
|
||||||
auto& proc = Processor::current();
|
auto& proc = Processor::current();
|
||||||
FlatPtr cpu = FlatPtr(&proc);
|
FlatPtr cpu = FlatPtr(&proc);
|
||||||
u32 prev_flags = cpu_flags();
|
|
||||||
Processor::enter_critical();
|
|
||||||
cli();
|
|
||||||
FlatPtr expected = 0;
|
FlatPtr expected = 0;
|
||||||
while (!m_lock.compare_exchange_strong(expected, cpu, AK::memory_order_acq_rel)) {
|
while (!m_lock.compare_exchange_strong(expected, cpu, AK::memory_order_acq_rel)) {
|
||||||
if (expected == cpu)
|
if (expected == cpu)
|
||||||
|
|
Loading…
Reference in a new issue