2 * Copyright 2012, Alex Smith, alex@alex-smith.me.uk.
3 * Distributed under the terms of the MIT License.
9 #include "asm_offsets.h"
10 #include "syscall_numbers.h"
16 // Userspace signal handler wrapper, copied to the commpage.
17 FUNCTION(x86_64_user_signal_handler):
21 // RDI points to the signal_frame_data structure, however we'll overwrite
22 // that with the function arguments, so move it somewhere else. We can use
23 // callee-save registers here without preserving them because the old value
24 // will be restored when the frame is restored.
27 // Check the handler type.
28 cmpb $0, SIGNAL_FRAME_DATA_siginfo_handler(%r12)
32 // Fetch other arguments (user data, vregs).
33 movq SIGNAL_FRAME_DATA_user_data(%r12), %rsi
34 leaq SIGNAL_FRAME_DATA_context + UCONTEXT_T_uc_mcontext(%r12), %rdx
37 // Get the handler address and the signal number first argument.
38 movq SIGNAL_FRAME_DATA_handler(%r12), %rax
39 movl SIGNAL_FRAME_DATA_info + SIGINFO_T_si_signo(%r12), %edi
44 // Perform the restore_signal_frame() syscall, should not return.
45 movq $SYSCALL_RESTORE_SIGNAL_FRAME, %rax
50 // Fetch other arguments (info pointer, context, user data).
51 leaq SIGNAL_FRAME_DATA_info(%r12), %rsi
52 leaq SIGNAL_FRAME_DATA_context(%r12), %rdx
53 movq SIGNAL_FRAME_DATA_user_data(%r12), %rcx
55 FUNCTION_END(x86_64_user_signal_handler)
56 SYMBOL(x86_64_user_signal_handler_end):