diff options
author | Ali Mohammad Pur <ali.mpfard@gmail.com> | 2022-02-26 18:30:51 +0330 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2022-03-04 20:07:05 +0100 |
commit | 88d7bf736279ee7245ccef4f36f71d829b2f7f2c (patch) | |
tree | d3ef99b62bf3ec4d5c6dbd0d5e7e20a16640bae7 /Kernel/Process.cpp | |
parent | e14e919b78b9043fb026a3e5d03402cd38e9fa96 (diff) | |
download | serenity-88d7bf736279ee7245ccef4f36f71d829b2f7f2c.zip |
Kernel: Save and restore FPU state on signal dispatch on i386/x86_64
Diffstat (limited to 'Kernel/Process.cpp')
-rw-r--r-- | Kernel/Process.cpp | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/Kernel/Process.cpp b/Kernel/Process.cpp index d1b4946748..5f8d2c69f7 100644 --- a/Kernel/Process.cpp +++ b/Kernel/Process.cpp @@ -293,12 +293,12 @@ void signal_trampoline_dummy() // blocking syscall, that syscall may return some special error code in eax; // This error code would likely be overwritten by the signal handler, so it's // necessary to preserve it here. - constexpr static auto offset_to_first_register_slot = sizeof(__ucontext) + sizeof(siginfo) + 5 * sizeof(FlatPtr); + constexpr static auto offset_to_first_register_slot = sizeof(__ucontext) + sizeof(siginfo) + sizeof(FPUState) + 4 * sizeof(FlatPtr); asm( ".intel_syntax noprefix\n" ".globl asm_signal_trampoline\n" "asm_signal_trampoline:\n" - // stack state: 0, ucontext, signal_info, (alignment = 16), 0, ucontext*, siginfo*, signal, (alignment = 16), handler + // stack state: 0, ucontext, signal_info, (alignment = 16), fpu_state (alignment = 16), 0, ucontext*, siginfo*, signal, (alignment = 16), handler // Pop the handler into ecx "pop ecx\n" // save handler @@ -310,7 +310,7 @@ void signal_trampoline_dummy() "call ecx\n" // drop the 4 arguments "add esp, 16\n" - // Current stack state is just saved_eax, ucontext, signal_info. + // Current stack state is just saved_eax, ucontext, signal_info, fpu_state?. // syscall SC_sigreturn "mov eax, %P0\n" "int 0x82\n" @@ -326,12 +326,12 @@ void signal_trampoline_dummy() // blocking syscall, that syscall may return some special error code in eax; // This error code would likely be overwritten by the signal handler, so it's // necessary to preserve it here. - constexpr static auto offset_to_first_register_slot = sizeof(__ucontext) + sizeof(siginfo) + 4 * sizeof(FlatPtr); + constexpr static auto offset_to_first_register_slot = sizeof(__ucontext) + sizeof(siginfo) + sizeof(FPUState) + 3 * sizeof(FlatPtr); asm( ".intel_syntax noprefix\n" ".globl asm_signal_trampoline\n" "asm_signal_trampoline:\n" - // stack state: 0, ucontext, signal_info (alignment = 16), ucontext*, siginfo*, signal, handler + // stack state: 0, ucontext, signal_info (alignment = 16), fpu_state (alignment = 16), ucontext*, siginfo*, signal, handler // Pop the handler into rcx "pop rcx\n" // save handler @@ -346,7 +346,7 @@ void signal_trampoline_dummy() // Note that the stack is currently aligned to 16 bytes as we popped the extra entries above. // call the signal handler "call rcx\n" - // Current stack state is just saved_rax, ucontext, signal_info. + // Current stack state is just saved_rax, ucontext, signal_info, fpu_state. // syscall SC_sigreturn "mov rax, %P0\n" "int 0x82\n" |