Home | History | Annotate | Line # | Download | only in sys
      1 /*	$NetBSD: __sigtramp2.S,v 1.5 2021/11/21 23:58:09 thorpej Exp $ */
      2 
      3 /*-
      4  * Copyright (c) 2003 The NetBSD Foundation, Inc.
      5  * All rights reserved.
      6  *
      7  * Redistribution and use in source and binary forms, with or without
      8  * modification, are permitted provided that the following conditions
      9  * are met:
     10  * 1. Redistributions of source code must retain the above copyright
     11  *    notice, this list of conditions and the following disclaimer.
     12  * 2. Redistributions in binary form must reproduce the above copyright
     13  *    notice, this list of conditions and the following disclaimer in the
     14  *    documentation and/or other materials provided with the distribution.
     15  *
     16  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     17  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     18  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     19  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     20  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     21  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     22  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     23  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     24  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     25  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     26  * POSSIBILITY OF SUCH DAMAGE.
     27  */
     28 
     29 #include "SYS.h"
     30 #include "assym.h"
     31 
     32 /*
     33  * The m68k signal trampoline is invoked only to return from
     34  * the signal; the kernel calls the signal handler directly.
     35  *
     36  * On entry, stack looks like:
     37  *
     38  *		ucontext structure			[12+sizeof(siginfo_t)]
     39  *		siginfo structure			[12]
     40  *		pointer to ucontext structure		[8]
     41  *		pointer to siginfo structure		[4]
     42  *	sp->	signal number				[0]
     43  *
     44  * The DWARF register numbers are 0-7 (dX), 8-15 (aX), 16-23 (fpX),
     45  * which maps nicely to _REG_D[0-7] and _REG_A[0-7].  For m68k, there
     46  * is a DWARF pseudo-register for the return address, and additionally
     47  * another DWARF pseudo-register for signal handler return addresses.
     48  * We will specify both return address pseudo-registers (without
     49  * explicitly specifying .cfi_return_column) to keep the compiler
     50  * run-time happy with whichever one it decides to use.
     51  */
     52 
     53 #define	DWARF_RETURN_REG		24
     54 #if defined(__LIBGCC_DWARF_ALT_FRAME_RETURN_COLUMN__)
     55 #define	DWARF_SIGRETURN_REG		__LIBGCC_DWARF_ALT_FRAME_RETURN_COLUMN__
     56 #else
     57 #define	DWARF_SIGRETURN_REG		25
     58 #endif
     59 
     60 #define	CFI_OFFSET_DWARF_REG(d, r)	.cfi_offset d, r * 4
     61 #define	CFI_OFFSET(r)			CFI_OFFSET_DWARF_REG(r, r)
     62 
     63 	.text
     64 	.cfi_startproc simple
     65 	.cfi_signal_frame
     66 	.cfi_def_cfa _REG_A7, 12 + SIZEOF_SIGINFO + UC_GREGS
     67 	CFI_OFFSET(_REG_D0)
     68 	CFI_OFFSET(_REG_D1)
     69 	CFI_OFFSET(_REG_D2)
     70 	CFI_OFFSET(_REG_D3)
     71 	CFI_OFFSET(_REG_D4)
     72 	CFI_OFFSET(_REG_D5)
     73 	CFI_OFFSET(_REG_D6)
     74 	CFI_OFFSET(_REG_D7)
     75 	CFI_OFFSET(_REG_A0)
     76 	CFI_OFFSET(_REG_A1)
     77 	CFI_OFFSET(_REG_A2)
     78 	CFI_OFFSET(_REG_A3)
     79 	CFI_OFFSET(_REG_A4)
     80 	CFI_OFFSET(_REG_A5)
     81 	CFI_OFFSET(_REG_A6)
     82 	CFI_OFFSET(_REG_A7)
     83 	CFI_OFFSET_DWARF_REG(DWARF_RETURN_REG, _REG_PC)
     84 	CFI_OFFSET_DWARF_REG(DWARF_SIGRETURN_REG, _REG_PC)
     85 
     86 /*
     87  * The unwind entry includes one instruction slot prior to the trampoline
     88  * because the unwinder will look up to (return PC - 1 insn) while unwinding.
     89  * Normally this would be the jump / branch, but since there isn't one in
     90  * this case, we place an explicit nop there instead.
     91  */
     92 	nop
     93 
     94 ENTRY_NOPROFILE(__sigtramp_siginfo_2)
     95 	movl	8(%sp),%a0	/* get pointer to ucontext */
     96 	movl	%a0,4(%sp)	/* put it in the argument slot */
     97 				/* fake return address already there */
     98 	SYSTRAP(setcontext)
     99 	movl	%d0,4(%sp)	/* error code */
    100 	SYSTRAP(exit)		/* exit */
    101 	.cfi_endproc
    102 END(__sigtramp_siginfo_2)
    103