From 00df1fc0601e9710df05e306e20402baed3b341a Mon Sep 17 00:00:00 2001 From: Timon Kruiper Date: Sun, 2 Apr 2023 16:25:52 +0200 Subject: [PATCH] Kernel: Store FPU state when dispatching signal on aarch64 And make sure to also restore it in sys$sigreturn. --- Kernel/Syscalls/sigaction.cpp | 2 -- Kernel/Thread.cpp | 2 -- 2 files changed, 4 deletions(-) diff --git a/Kernel/Syscalls/sigaction.cpp b/Kernel/Syscalls/sigaction.cpp index 7071b92978..cd17407109 100644 --- a/Kernel/Syscalls/sigaction.cpp +++ b/Kernel/Syscalls/sigaction.cpp @@ -87,14 +87,12 @@ ErrorOr Process::sys$sigreturn(RegisterState& registers) // Stack state (created by the signal trampoline): // saved_ax, ucontext, signal_info, fpu_state?. -#if ARCH(X86_64) // The FPU state is at the top here, pop it off and restore it. // FIXME: The stack alignment is off by 8 bytes here, figure this out and remove this excessively aligned object. alignas(alignof(FPUState) * 2) FPUState data {}; TRY(copy_from_user(&data, bit_cast(stack_ptr))); Thread::current()->fpu_state() = data; stack_ptr += sizeof(FPUState); -#endif stack_ptr += sizeof(siginfo); // We don't need this here. diff --git a/Kernel/Thread.cpp b/Kernel/Thread.cpp index 38fde59613..e464028f43 100644 --- a/Kernel/Thread.cpp +++ b/Kernel/Thread.cpp @@ -1150,10 +1150,8 @@ DispatchSignalResult Thread::dispatch_signal(u8 signal) VERIFY(stack % 16 == 0); -#if ARCH(X86_64) // Save the FPU/SSE state TRY(copy_value_on_user_stack(stack, fpu_state())); -#endif TRY(push_value_on_user_stack(stack, pointer_to_ucontext)); TRY(push_value_on_user_stack(stack, pointer_to_signal_info));