mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-29 04:09:13 +00:00
Kernel: Track previous mode when entering/exiting traps
This allows us to determine what the previous mode (user or kernel) was, e.g. in the timer interrupt. This is used e.g. to determine whether a signal handler should be set up. Fixes #5096
This commit is contained in:
parent
fa18010477
commit
0bd558081e
Notes:
sideshowbarker
2024-07-18 22:49:24 +09:00
Author: https://github.com/tomuta
Commit: 0bd558081e
Pull-request: https://github.com/SerenityOS/serenity/pull/5100
Reviewed-by: https://github.com/awesomekling
6 changed files with 70 additions and 7 deletions
|
@ -137,6 +137,7 @@ void syscall_handler(TrapFrame* trap)
|
|||
{
|
||||
auto& regs = *trap->regs;
|
||||
auto current_thread = Thread::current();
|
||||
ASSERT(current_thread->previous_mode() == Thread::PreviousMode::UserMode);
|
||||
auto& process = current_thread->process();
|
||||
|
||||
if (auto tracer = process.tracer(); tracer && tracer->is_tracing_syscalls()) {
|
||||
|
@ -206,6 +207,9 @@ void syscall_handler(TrapFrame* trap)
|
|||
|
||||
current_thread->check_dispatch_pending_signal();
|
||||
|
||||
// If the previous mode somehow changed something is seriously messed up...
|
||||
ASSERT(current_thread->previous_mode() == Thread::PreviousMode::UserMode);
|
||||
|
||||
// Check if we're supposed to return to userspace or just die.
|
||||
current_thread->die_if_needed();
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue