mirror of
https://github.com/Mathewnd/Astral.git
synced 2026-10-28 21:28:21 +00:00
signal: return from ucontext context
This commit is contained in:
@@ -3,6 +3,10 @@
|
||||
#include <arch/cpu.h>
|
||||
#include <logging.h>
|
||||
|
||||
#ifdef __x86_64__
|
||||
#include <arch/msr.h>
|
||||
#endif
|
||||
|
||||
// this expects CTX_SP to be pointing to the signal frame
|
||||
__attribute__((noreturn)) void syscall_sigreturn(context_t *context) {
|
||||
sigframe_t sigframe;
|
||||
@@ -16,7 +20,15 @@ __attribute__((noreturn)) void syscall_sigreturn(context_t *context) {
|
||||
signal_altstack(current_thread(), &sigframe.oldstack, NULL);
|
||||
signal_changemask(current_thread(), SIG_SETMASK, &sigframe.oldmask, NULL);
|
||||
|
||||
arch_sigframe_get_context_from_mcontext(&sigframe);
|
||||
|
||||
__assert(ARCH_CONTEXT_ISUSER(&sigframe.context));
|
||||
|
||||
#ifdef __x86_64__
|
||||
// XXX is this behavior correct? ucontext doesnt seem to save it on linux and so it will not be saved
|
||||
sigframe.extracontext.gsbase = rdmsr(MSR_KERNELGSBASE);
|
||||
sigframe.extracontext.fsbase = rdmsr(MSR_FSBASE);
|
||||
#endif
|
||||
memcpy(¤t_thread()->extracontext, &sigframe.extracontext, sizeof(extracontext_t));
|
||||
ARCH_CONTEXT_THREADLOAD(current_thread(), context);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user