mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 23:07:35 +00:00
Kernel: Thread::wait_on() must always leave interrupts enabled on exit
The short-circuit path added for waiting on a queue that already had a pending wake was able to return with interrupts disabled, which breaks the API contract of wait_on() always returning with IF=1. Fix this by adding a way to override the restored IF in ScopedCritical.
This commit is contained in:
parent
3e0020e67d
commit
163c9d5f8f
2 changed files with 13 additions and 0 deletions
|
@ -837,6 +837,14 @@ public:
|
|||
return *this;
|
||||
}
|
||||
|
||||
void set_interrupt_flag_on_destruction(bool flag)
|
||||
{
|
||||
if (flag)
|
||||
m_prev_flags |= 0x200;
|
||||
else
|
||||
m_prev_flags &= ~0x200;
|
||||
}
|
||||
|
||||
private:
|
||||
u32 m_prev_flags { 0 };
|
||||
bool m_valid { false };
|
||||
|
|
|
@ -876,6 +876,11 @@ Thread::BlockResult Thread::wait_on(WaitQueue& queue, const char* reason, timeva
|
|||
// The WaitQueue was already requested to wake someone when
|
||||
// nobody was waiting. So return right away as we shouldn't
|
||||
// be waiting
|
||||
|
||||
// The API contract guarantees we return with interrupts enabled,
|
||||
// regardless of how we got called
|
||||
critical.set_interrupt_flag_on_destruction(true);
|
||||
|
||||
return BlockResult::NotBlocked;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue