| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: sig_machdep.c,v 1.52 2021/02/01 19:31:34 skrll Exp $ */ | | 1 | /* $NetBSD: sig_machdep.c,v 1.53 2024/04/14 07:56:13 skrll Exp $ */ |
2 | | | 2 | |
3 | /* | | 3 | /* |
4 | * Copyright (c) 1994-1998 Mark Brinicombe. | | 4 | * Copyright (c) 1994-1998 Mark Brinicombe. |
5 | * Copyright (c) 1994 Brini. | | 5 | * Copyright (c) 1994 Brini. |
6 | * All rights reserved. | | 6 | * All rights reserved. |
7 | * | | 7 | * |
8 | * This code is derived from software written for Brini by Mark Brinicombe | | 8 | * This code is derived from software written for Brini by Mark Brinicombe |
9 | * | | 9 | * |
10 | * Redistribution and use in source and binary forms, with or without | | 10 | * Redistribution and use in source and binary forms, with or without |
11 | * modification, are permitted provided that the following conditions | | 11 | * modification, are permitted provided that the following conditions |
12 | * are met: | | 12 | * are met: |
13 | * 1. Redistributions of source code must retain the above copyright | | 13 | * 1. Redistributions of source code must retain the above copyright |
14 | * notice, this list of conditions and the following disclaimer. | | 14 | * notice, this list of conditions and the following disclaimer. |
| @@ -34,27 +34,27 @@ | | | @@ -34,27 +34,27 @@ |
34 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | | 34 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
35 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | | 35 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
36 | * SUCH DAMAGE. | | 36 | * SUCH DAMAGE. |
37 | * | | 37 | * |
38 | * Machine dependent functions for kernel setup | | 38 | * Machine dependent functions for kernel setup |
39 | * | | 39 | * |
40 | * Created : 17/09/94 | | 40 | * Created : 17/09/94 |
41 | */ | | 41 | */ |
42 | | | 42 | |
43 | #include "opt_armfpe.h" | | 43 | #include "opt_armfpe.h" |
44 | | | 44 | |
45 | #include <sys/param.h> | | 45 | #include <sys/param.h> |
46 | | | 46 | |
47 | __KERNEL_RCSID(0, "$NetBSD: sig_machdep.c,v 1.52 2021/02/01 19:31:34 skrll Exp $"); | | 47 | __KERNEL_RCSID(0, "$NetBSD: sig_machdep.c,v 1.53 2024/04/14 07:56:13 skrll Exp $"); |
48 | | | 48 | |
49 | #include <sys/mount.h> /* XXX only needed by syscallargs.h */ | | 49 | #include <sys/mount.h> /* XXX only needed by syscallargs.h */ |
50 | #include <sys/cpu.h> | | 50 | #include <sys/cpu.h> |
51 | #include <sys/proc.h> | | 51 | #include <sys/proc.h> |
52 | #include <sys/signal.h> | | 52 | #include <sys/signal.h> |
53 | #include <sys/syscallargs.h> | | 53 | #include <sys/syscallargs.h> |
54 | #include <sys/systm.h> | | 54 | #include <sys/systm.h> |
55 | #include <sys/ras.h> | | 55 | #include <sys/ras.h> |
56 | #include <sys/ucontext.h> | | 56 | #include <sys/ucontext.h> |
57 | | | 57 | |
58 | #include <arm/locore.h> | | 58 | #include <arm/locore.h> |
59 | | | 59 | |
60 | #include <machine/pcb.h> | | 60 | #include <machine/pcb.h> |
| @@ -87,30 +87,30 @@ getframe(struct lwp *l, int sig, int *on | | | @@ -87,30 +87,30 @@ getframe(struct lwp *l, int sig, int *on |
87 | void | | 87 | void |
88 | sendsig_siginfo(const ksiginfo_t *ksi, const sigset_t *mask) | | 88 | sendsig_siginfo(const ksiginfo_t *ksi, const sigset_t *mask) |
89 | { | | 89 | { |
90 | struct lwp * const l = curlwp; | | 90 | struct lwp * const l = curlwp; |
91 | struct proc * const p = l->l_proc; | | 91 | struct proc * const p = l->l_proc; |
92 | struct sigacts * const ps = p->p_sigacts; | | 92 | struct sigacts * const ps = p->p_sigacts; |
93 | struct trapframe * const tf = lwp_trapframe(l); | | 93 | struct trapframe * const tf = lwp_trapframe(l); |
94 | struct sigframe_siginfo *fp, frame; | | 94 | struct sigframe_siginfo *fp, frame; |
95 | int onstack, error; | | 95 | int onstack, error; |
96 | int sig = ksi->ksi_signo; | | 96 | int sig = ksi->ksi_signo; |
97 | sig_t catcher = SIGACTION(p, sig).sa_handler; | | 97 | sig_t catcher = SIGACTION(p, sig).sa_handler; |
98 | | | 98 | |
99 | fp = getframe(l, sig, &onstack); | | 99 | fp = getframe(l, sig, &onstack); |
100 | | | 100 | |
101 | /* make room on the stack */ | | 101 | /* make room on the stack */ |
102 | fp--; | | 102 | fp--; |
103 | | | 103 | |
104 | /* make the stack aligned */ | | 104 | /* make the stack aligned */ |
105 | fp = (struct sigframe_siginfo *)STACK_ALIGN(fp, STACK_ALIGNBYTES); | | 105 | fp = (struct sigframe_siginfo *)STACK_ALIGN(fp, STACK_ALIGNBYTES); |
106 | | | 106 | |
107 | /* populate the siginfo frame */ | | 107 | /* populate the siginfo frame */ |
108 | memset(&frame, 0, sizeof(frame)); | | 108 | memset(&frame, 0, sizeof(frame)); |
109 | frame.sf_si._info = ksi->ksi_info; | | 109 | frame.sf_si._info = ksi->ksi_info; |
110 | frame.sf_uc.uc_flags = _UC_SIGMASK; | | 110 | frame.sf_uc.uc_flags = _UC_SIGMASK; |
111 | frame.sf_uc.uc_sigmask = *mask; | | 111 | frame.sf_uc.uc_sigmask = *mask; |
112 | frame.sf_uc.uc_link = l->l_ctxlink; | | 112 | frame.sf_uc.uc_link = l->l_ctxlink; |
113 | frame.sf_uc.uc_flags |= (l->l_sigstk.ss_flags & SS_ONSTACK) | | 113 | frame.sf_uc.uc_flags |= (l->l_sigstk.ss_flags & SS_ONSTACK) |
114 | ? _UC_SETSTACK : _UC_CLRSTACK; | | 114 | ? _UC_SETSTACK : _UC_CLRSTACK; |
115 | sendsig_reset(l, sig); | | 115 | sendsig_reset(l, sig); |
116 | | | 116 | |
| @@ -124,27 +124,27 @@ sendsig_siginfo(const ksiginfo_t *ksi, c | | | @@ -124,27 +124,27 @@ sendsig_siginfo(const ksiginfo_t *ksi, c |
124 | * Process has trashed its stack; give it an illegal | | 124 | * Process has trashed its stack; give it an illegal |
125 | * instruction to halt it in its tracks. | | 125 | * instruction to halt it in its tracks. |
126 | */ | | 126 | */ |
127 | sigexit(l, SIGILL); | | 127 | sigexit(l, SIGILL); |
128 | /* NOTREACHED */ | | 128 | /* NOTREACHED */ |
129 | } | | 129 | } |
130 | | | 130 | |
131 | /* | | 131 | /* |
132 | * Build context to run handler in. We invoke the handler | | 132 | * Build context to run handler in. We invoke the handler |
133 | * directly, only returning via the trampoline. Note the | | 133 | * directly, only returning via the trampoline. Note the |
134 | * trampoline version numbers are coordinated with machine- | | 134 | * trampoline version numbers are coordinated with machine- |
135 | * dependent code in libc. | | 135 | * dependent code in libc. |
136 | */ | | 136 | */ |
137 | | | 137 | |
138 | tf->tf_r0 = sig; | | 138 | tf->tf_r0 = sig; |
139 | tf->tf_r1 = (int)&fp->sf_si; | | 139 | tf->tf_r1 = (int)&fp->sf_si; |
140 | tf->tf_r2 = (int)&fp->sf_uc; | | 140 | tf->tf_r2 = (int)&fp->sf_uc; |
141 | | | 141 | |
142 | /* the trampoline uses r5 as the uc address */ | | 142 | /* the trampoline uses r5 as the uc address */ |
143 | tf->tf_r5 = (int)&fp->sf_uc; | | 143 | tf->tf_r5 = (int)&fp->sf_uc; |
144 | tf->tf_pc = (int)catcher; | | 144 | tf->tf_pc = (int)catcher; |
145 | #ifdef THUMB_CODE | | 145 | #ifdef THUMB_CODE |
146 | if (((int) catcher) & 1) | | 146 | if (((int) catcher) & 1) |
147 | tf->tf_spsr |= PSR_T_bit; | | 147 | tf->tf_spsr |= PSR_T_bit; |
148 | else | | 148 | else |
149 | tf->tf_spsr &= ~PSR_T_bit; | | 149 | tf->tf_spsr &= ~PSR_T_bit; |
150 | #endif | | 150 | #endif |