1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 11:48:10 +00:00

Kernel: Use user stack for signal handlers.

This commit drastically changes how signals are handled.

In the case that an unblocked thread is signaled it works much
in the same way as previously. However, when a blocking syscall
is interrupted, we set up the signal trampoline on the user
stack, complete the blocking syscall, return down the kernel
stack and then jump to the handler. This means that from the
kernel stack's perspective, we only ever get one system call deep.

The signal trampoline has also been changed in order to properly
store the return value from system calls. This is necessary due
to the new way we exit from signaled system calls.
This commit is contained in:
Drew Stratford 2019-09-05 01:14:54 +12:00 committed by Andreas Kling
parent 259a1d56b0
commit 81d0f96f20
5 changed files with 104 additions and 122 deletions

View file

@ -181,11 +181,7 @@ static u32 handle(RegisterDump& regs, u32 function, u32 arg1, u32 arg2, u32 arg3
case Syscall::SC_setgroups:
return current->process().sys$setgroups((ssize_t)arg1, (const gid_t*)arg2);
case Syscall::SC_sigreturn:
if (auto* tracer = current->process().tracer())
tracer->did_syscall(function, arg1, arg2, arg3, 0);
current->process().sys$sigreturn();
ASSERT_NOT_REACHED();
return 0;
return current->process().sys$sigreturn(regs);
case Syscall::SC_sigprocmask:
return current->process().sys$sigprocmask((int)arg1, (const sigset_t*)arg2, (sigset_t*)arg3);
case Syscall::SC_pipe: