1 1.5 skrll /* $NetBSD: __sigtramp2.S,v 1.5 2021/11/27 10:00:01 skrll Exp $ */ 2 1.1 matt 3 1.1 matt /*- 4 1.1 matt * Copyright (c) 2002 The NetBSD Foundation, Inc. 5 1.1 matt * All rights reserved. 6 1.1 matt * 7 1.1 matt * This code is derived from software contributed to The NetBSD Foundation 8 1.1 matt * by Jason R. Thorpe. 9 1.1 matt * 10 1.1 matt * Redistribution and use in source and binary forms, with or without 11 1.1 matt * modification, are permitted provided that the following conditions 12 1.1 matt * are met: 13 1.1 matt * 1. Redistributions of source code must retain the above copyright 14 1.1 matt * notice, this list of conditions and the following disclaimer. 15 1.1 matt * 2. Redistributions in binary form must reproduce the above copyright 16 1.1 matt * notice, this list of conditions and the following disclaimer in the 17 1.1 matt * documentation and/or other materials provided with the distribution. 18 1.1 matt * 19 1.1 matt * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 20 1.1 matt * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 21 1.1 matt * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 22 1.1 matt * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 23 1.1 matt * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 24 1.1 matt * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 25 1.1 matt * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 26 1.1 matt * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 27 1.1 matt * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 28 1.1 matt * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 29 1.1 matt * POSSIBILITY OF SUCH DAMAGE. 30 1.1 matt */ 31 1.1 matt 32 1.1 matt #include "SYS.h" 33 1.4 thorpej #include "assym.h" 34 1.1 matt 35 1.3 matt #if defined(LIBC_SCCS) && !defined(lint) 36 1.5 skrll __RCSID("$NetBSD: __sigtramp2.S,v 1.5 2021/11/27 10:00:01 skrll Exp $") 37 1.3 matt #endif /* LIBC_SCCS && !lint */ 38 1.3 matt 39 1.1 matt /* 40 1.1 matt * On entry to user space, stack and registers look like: 41 1.1 matt * 42 1.1 matt * r3 signal number 43 1.1 matt * r4 pointer to siginfo structure 44 1.1 matt * r5 pointer to ucontext structure 45 1.1 matt * r30 pointer to ucontext structure 46 1.1 matt * srr0 address of handler 47 1.1 matt * lr address of this trampoline 48 1.1 matt * 49 1.4 thorpej * We use r30 as the CFA base register since it's been conveniently set up 50 1.4 thorpej * for us that way. The DWARF register numbers used in the .eh_frame are: 51 1.4 thorpej * 52 1.4 thorpej * 0 - 31 GPRs 53 1.4 thorpej * 32 - 63 FPRs 54 1.4 thorpej * 65 LR 55 1.4 thorpej * 66 CTR 56 1.4 thorpej * 68-75 CRs 57 1.4 thorpej * 76 XER 58 1.4 thorpej * 77 - 108 AltiVec regs 59 1.4 thorpej * 99 signal trampoline return address 60 1.4 thorpej * 109 VRSAVE 61 1.4 thorpej * 110 VCSR 62 1.4 thorpej * 63 1.4 thorpej * N.B. Only one CR slot is used (CR2) in the SVR4 ABI. 64 1.1 matt */ 65 1.4 thorpej 66 1.4 thorpej #define DWARF_LR_REG 65 67 1.4 thorpej #define DWARF_CTR_REG 66 68 1.4 thorpej #define DWARF_CR2_REG 70 69 1.4 thorpej #define DWARF_XER_REG 76 70 1.4 thorpej #define DWARF_SIGRETURN_REG 99 71 1.4 thorpej 72 1.4 thorpej #define CFI_OFFSET_DWARF_REG(d, r) .cfi_offset d, r * 4 73 1.4 thorpej #define CFI_OFFSET(r) CFI_OFFSET_DWARF_REG(r, r) 74 1.4 thorpej 75 1.4 thorpej .text 76 1.4 thorpej .cfi_startproc simple 77 1.4 thorpej .cfi_signal_frame 78 1.4 thorpej .cfi_def_cfa _REG_R30, UC_GREGS 79 1.4 thorpej CFI_OFFSET(_REG_R0) 80 1.4 thorpej CFI_OFFSET(_REG_R1) 81 1.4 thorpej CFI_OFFSET(_REG_R2) 82 1.4 thorpej CFI_OFFSET(_REG_R3) 83 1.4 thorpej CFI_OFFSET(_REG_R4) 84 1.4 thorpej CFI_OFFSET(_REG_R5) 85 1.4 thorpej CFI_OFFSET(_REG_R6) 86 1.4 thorpej CFI_OFFSET(_REG_R7) 87 1.4 thorpej CFI_OFFSET(_REG_R8) 88 1.4 thorpej CFI_OFFSET(_REG_R9) 89 1.4 thorpej CFI_OFFSET(_REG_R10) 90 1.4 thorpej CFI_OFFSET(_REG_R11) 91 1.4 thorpej CFI_OFFSET(_REG_R12) 92 1.4 thorpej CFI_OFFSET(_REG_R13) 93 1.4 thorpej CFI_OFFSET(_REG_R14) 94 1.4 thorpej CFI_OFFSET(_REG_R15) 95 1.4 thorpej CFI_OFFSET(_REG_R16) 96 1.4 thorpej CFI_OFFSET(_REG_R17) 97 1.4 thorpej CFI_OFFSET(_REG_R18) 98 1.4 thorpej CFI_OFFSET(_REG_R19) 99 1.4 thorpej CFI_OFFSET(_REG_R20) 100 1.4 thorpej CFI_OFFSET(_REG_R21) 101 1.4 thorpej CFI_OFFSET(_REG_R22) 102 1.4 thorpej CFI_OFFSET(_REG_R23) 103 1.4 thorpej CFI_OFFSET(_REG_R24) 104 1.4 thorpej CFI_OFFSET(_REG_R25) 105 1.4 thorpej CFI_OFFSET(_REG_R26) 106 1.4 thorpej CFI_OFFSET(_REG_R27) 107 1.4 thorpej CFI_OFFSET(_REG_R28) 108 1.4 thorpej CFI_OFFSET(_REG_R29) 109 1.4 thorpej CFI_OFFSET(_REG_R30) 110 1.4 thorpej CFI_OFFSET(_REG_R31) 111 1.4 thorpej CFI_OFFSET_DWARF_REG(DWARF_CR2_REG, _REG_CR) 112 1.4 thorpej CFI_OFFSET_DWARF_REG(DWARF_LR_REG, _REG_LR) 113 1.4 thorpej CFI_OFFSET_DWARF_REG(DWARF_CTR_REG, _REG_CTR) 114 1.4 thorpej CFI_OFFSET_DWARF_REG(DWARF_XER_REG, _REG_XER) 115 1.4 thorpej .cfi_return_column DWARF_SIGRETURN_REG 116 1.4 thorpej CFI_OFFSET_DWARF_REG(DWARF_SIGRETURN_REG, _REG_PC) 117 1.4 thorpej 118 1.5 skrll /* 119 1.4 thorpej * The unwind entry includes one instruction slot prior to the trampoline 120 1.4 thorpej * because the unwinder will look up to (return PC - 1 insn) while unwinding. 121 1.4 thorpej * Normally this would be the jump / branch, but since there isn't one in 122 1.4 thorpej * this case, we place an explicit nop there instead. 123 1.5 skrll */ 124 1.4 thorpej nop 125 1.4 thorpej 126 1.1 matt ENTRY_NOPROFILE(__sigtramp_siginfo_2) 127 1.1 matt mr %r3,%r30 /* restore ucontext pointer */ 128 1.1 matt _DOSYSCALL(setcontext) /* restore machine state */ 129 1.1 matt _DOSYSCALL(exit) /* or exit with errno if failed */ 130 1.4 thorpej .cfi_endproc 131 1.3 matt END(__sigtramp_siginfo_2) 132