Home | History | Annotate | Line # | Download | only in sys
      1 /*	$NetBSD: __sigtramp2.S,v 1.9 2020/10/19 11:29:26 kamil Exp $	*/
      2 
      3 /*
      4  * Copyright (c) 2001 Wasabi Systems, Inc.
      5  * All rights reserved.
      6  *
      7  * Written by Frank van der Linden for Wasabi Systems, Inc.
      8  *
      9  * Redistribution and use in source and binary forms, with or without
     10  * modification, are permitted provided that the following conditions
     11  * are met:
     12  * 1. Redistributions of source code must retain the above copyright
     13  *    notice, this list of conditions and the following disclaimer.
     14  * 2. Redistributions in binary form must reproduce the above copyright
     15  *    notice, this list of conditions and the following disclaimer in the
     16  *    documentation and/or other materials provided with the distribution.
     17  * 3. All advertising materials mentioning features or use of this software
     18  *    must display the following acknowledgement:
     19  *      This product includes software developed for the NetBSD Project by
     20  *      Wasabi Systems, Inc.
     21  * 4. The name of Wasabi Systems, Inc. may not be used to endorse
     22  *    or promote products derived from this software without specific prior
     23  *    written permission.
     24  *
     25  * THIS SOFTWARE IS PROVIDED BY WASABI SYSTEMS, INC. ``AS IS'' AND
     26  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     27  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     28  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL WASABI SYSTEMS, INC
     29  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     30  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     31  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     32  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     33  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     34  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     35  * POSSIBILITY OF SUCH DAMAGE.
     36  */
     37 
     38 #include "SYS.h"
     39 #include "assym.h"
     40 
     41 /*
     42  * The x86-64 signal trampoline is invoked only to return from
     43  * the signal; the kernel calls the signal handler directly.
     44  *
     45  * The unwind entry includes the one byte prior to the trampoline
     46  * because the unwinder will look up (return PC - 1) while unwinding.
     47  * Normally (return PC - 1) computes an address inside the call
     48  * instruction that created the child frame, but here there is no call
     49  * instruction so we have to manually add padding.
     50  */
     51 	.cfi_startproc simple
     52 	.cfi_signal_frame
     53 	.cfi_def_cfa r15, 0
     54 	.cfi_offset rax, UC_GREGS_RAX
     55 	.cfi_offset rdx, UC_GREGS_RDX
     56 	.cfi_offset rcx, UC_GREGS_RCX
     57 	.cfi_offset rbx, UC_GREGS_RBX
     58 	.cfi_offset rsi, UC_GREGS_RSI
     59 	.cfi_offset rdi, UC_GREGS_RDI
     60 	.cfi_offset rbp, UC_GREGS_RBP
     61 	.cfi_offset rsp, UC_GREGS_RSP
     62 	.cfi_offset r8,  UC_GREGS_R8
     63 	.cfi_offset r9,  UC_GREGS_R9
     64 	.cfi_offset r10, UC_GREGS_R10
     65 	.cfi_offset r11, UC_GREGS_R11
     66 	.cfi_offset r12, UC_GREGS_R12
     67 	.cfi_offset r13, UC_GREGS_R13
     68 	.cfi_offset r14, UC_GREGS_R14
     69 	.cfi_offset r15, UC_GREGS_R15
     70 	.cfi_offset rip, UC_GREGS_RIP
     71 	nop
     72 NENTRY(__sigtramp_siginfo_2)
     73 	movq	%r15,%rdi
     74 	movq	$SYS_setcontext, %rax
     75 	syscall
     76 	movq	$-1,%rdi /* if we return here, something is wrong */
     77 	movq	$SYS_exit, %rax
     78 	syscall
     79 	.cfi_endproc
     80 END(__sigtramp_siginfo_2)
     81