mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-26 09:30:24 +00:00
Kernel: Ensure proper locking when mutating boot console cursor
The BootFramebufferConsole highly depends on using the m_lock spinlock, therefore setting and changing the cursor state should be done under that spinlock too to avoid crashing.
This commit is contained in:
parent
0a5416a87a
commit
37ed1b28fa
Notes:
sideshowbarker
2024-07-17 06:46:37 +09:00
Author: https://github.com/supercomputer7 Commit: https://github.com/SerenityOS/serenity/commit/37ed1b28fa Pull-request: https://github.com/SerenityOS/serenity/pull/15301
2 changed files with 30 additions and 0 deletions
|
@ -71,6 +71,31 @@ void BootFramebufferConsole::write(size_t x, size_t y, char ch, Color background
|
|||
GenericFramebufferConsoleImpl::write(x, y, ch, background, foreground, critical);
|
||||
}
|
||||
|
||||
void BootFramebufferConsole::set_cursor(size_t x, size_t y)
|
||||
{
|
||||
// Note: To ensure we don't trigger a deadlock, let's assert in
|
||||
// case we already locked the spinlock, so we know there's a bug
|
||||
// in the call path.
|
||||
VERIFY(!m_lock.is_locked());
|
||||
SpinlockLocker lock(m_lock);
|
||||
hide_cursor();
|
||||
m_x = x;
|
||||
m_y = y;
|
||||
show_cursor();
|
||||
}
|
||||
|
||||
void BootFramebufferConsole::hide_cursor()
|
||||
{
|
||||
VERIFY(m_lock.is_locked());
|
||||
GenericFramebufferConsoleImpl::hide_cursor();
|
||||
}
|
||||
|
||||
void BootFramebufferConsole::show_cursor()
|
||||
{
|
||||
VERIFY(m_lock.is_locked());
|
||||
GenericFramebufferConsoleImpl::show_cursor();
|
||||
}
|
||||
|
||||
u8* BootFramebufferConsole::framebuffer_data()
|
||||
{
|
||||
VERIFY(m_lock.is_locked());
|
||||
|
|
|
@ -30,6 +30,11 @@ public:
|
|||
BootFramebufferConsole(PhysicalAddress framebuffer_addr, size_t width, size_t height, size_t pitch);
|
||||
#endif
|
||||
|
||||
private:
|
||||
virtual void set_cursor(size_t x, size_t y) override;
|
||||
virtual void hide_cursor() override;
|
||||
virtual void show_cursor() override;
|
||||
|
||||
protected:
|
||||
virtual void clear_glyph(size_t x, size_t y) override;
|
||||
|
||||
|
|
Loading…
Reference in a new issue