sig_machdep.c revision 1.2.2.2 1 1.2.2.2 gehenna /* $NetBSD: sig_machdep.c,v 1.2.2.2 2002/07/14 17:47:13 gehenna Exp $ */
2 1.2.2.2 gehenna
3 1.2.2.2 gehenna /*-
4 1.2.2.2 gehenna * Copyright (c) 2002 The NetBSD Foundation, Inc.
5 1.2.2.2 gehenna * All rights reserved.
6 1.2.2.2 gehenna *
7 1.2.2.2 gehenna * This code is derived from software contributed to The NetBSD Foundation
8 1.2.2.2 gehenna * by Matthew Fredette.
9 1.2.2.2 gehenna *
10 1.2.2.2 gehenna * Redistribution and use in source and binary forms, with or without
11 1.2.2.2 gehenna * modification, are permitted provided that the following conditions
12 1.2.2.2 gehenna * are met:
13 1.2.2.2 gehenna * 1. Redistributions of source code must retain the above copyright
14 1.2.2.2 gehenna * notice, this list of conditions and the following disclaimer.
15 1.2.2.2 gehenna * 2. Redistributions in binary form must reproduce the above copyright
16 1.2.2.2 gehenna * notice, this list of conditions and the following disclaimer in the
17 1.2.2.2 gehenna * documentation and/or other materials provided with the distribution.
18 1.2.2.2 gehenna * 3. All advertising materials mentioning features or use of this software
19 1.2.2.2 gehenna * must display the following acknowledgement:
20 1.2.2.2 gehenna * This product includes software developed by the NetBSD
21 1.2.2.2 gehenna * Foundation, Inc. and its contributors.
22 1.2.2.2 gehenna * 4. Neither the name of The NetBSD Foundation nor the names of its
23 1.2.2.2 gehenna * contributors may be used to endorse or promote products derived
24 1.2.2.2 gehenna * from this software without specific prior written permission.
25 1.2.2.2 gehenna *
26 1.2.2.2 gehenna * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
27 1.2.2.2 gehenna * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
28 1.2.2.2 gehenna * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29 1.2.2.2 gehenna * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
30 1.2.2.2 gehenna * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
31 1.2.2.2 gehenna * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
32 1.2.2.2 gehenna * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
33 1.2.2.2 gehenna * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
34 1.2.2.2 gehenna * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
35 1.2.2.2 gehenna * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36 1.2.2.2 gehenna * POSSIBILITY OF SUCH DAMAGE.
37 1.2.2.2 gehenna */
38 1.2.2.2 gehenna
39 1.2.2.2 gehenna /*
40 1.2.2.2 gehenna * Copyright (c) 1988 University of Utah.
41 1.2.2.2 gehenna * Copyright (c) 1982, 1986, 1990, 1993
42 1.2.2.2 gehenna * The Regents of the University of California. All rights reserved.
43 1.2.2.2 gehenna *
44 1.2.2.2 gehenna * This code is derived from software contributed to Berkeley by
45 1.2.2.2 gehenna * the Systems Programming Group of the University of Utah Computer
46 1.2.2.2 gehenna * Science Department.
47 1.2.2.2 gehenna *
48 1.2.2.2 gehenna * Redistribution and use in source and binary forms, with or without
49 1.2.2.2 gehenna * modification, are permitted provided that the following conditions
50 1.2.2.2 gehenna * are met:
51 1.2.2.2 gehenna * 1. Redistributions of source code must retain the above copyright
52 1.2.2.2 gehenna * notice, this list of conditions and the following disclaimer.
53 1.2.2.2 gehenna * 2. Redistributions in binary form must reproduce the above copyright
54 1.2.2.2 gehenna * notice, this list of conditions and the following disclaimer in the
55 1.2.2.2 gehenna * documentation and/or other materials provided with the distribution.
56 1.2.2.2 gehenna * 3. All advertising materials mentioning features or use of this software
57 1.2.2.2 gehenna * must display the following acknowledgement:
58 1.2.2.2 gehenna * This product includes software developed by the University of
59 1.2.2.2 gehenna * California, Berkeley and its contributors.
60 1.2.2.2 gehenna * 4. Neither the name of the University nor the names of its contributors
61 1.2.2.2 gehenna * may be used to endorse or promote products derived from this software
62 1.2.2.2 gehenna * without specific prior written permission.
63 1.2.2.2 gehenna *
64 1.2.2.2 gehenna * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
65 1.2.2.2 gehenna * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
66 1.2.2.2 gehenna * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
67 1.2.2.2 gehenna * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
68 1.2.2.2 gehenna * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
69 1.2.2.2 gehenna * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
70 1.2.2.2 gehenna * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
71 1.2.2.2 gehenna * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
72 1.2.2.2 gehenna * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
73 1.2.2.2 gehenna * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
74 1.2.2.2 gehenna * SUCH DAMAGE.
75 1.2.2.2 gehenna *
76 1.2.2.2 gehenna * from: Utah Hdr: machdep.c 1.74 92/12/20
77 1.2.2.2 gehenna * from: @(#)machdep.c 8.10 (Berkeley) 4/20/94
78 1.2.2.2 gehenna */
79 1.2.2.2 gehenna
80 1.2.2.2 gehenna #include "opt_compat_netbsd.h"
81 1.2.2.2 gehenna
82 1.2.2.2 gehenna #define __HPPA_SIGNAL_PRIVATE
83 1.2.2.2 gehenna
84 1.2.2.2 gehenna #include <sys/param.h>
85 1.2.2.2 gehenna #include <sys/systm.h>
86 1.2.2.2 gehenna #include <sys/kernel.h>
87 1.2.2.2 gehenna #include <sys/proc.h>
88 1.2.2.2 gehenna #include <sys/user.h>
89 1.2.2.2 gehenna #include <sys/signal.h>
90 1.2.2.2 gehenna #include <sys/signalvar.h>
91 1.2.2.2 gehenna
92 1.2.2.2 gehenna #include <sys/mount.h>
93 1.2.2.2 gehenna #include <sys/syscallargs.h>
94 1.2.2.2 gehenna
95 1.2.2.2 gehenna #include <machine/cpu.h>
96 1.2.2.2 gehenna #include <machine/reg.h>
97 1.2.2.2 gehenna
98 1.2.2.2 gehenna #ifdef DEBUG
99 1.2.2.2 gehenna int sigdebug = 0xff;
100 1.2.2.2 gehenna int sigpid = 0;
101 1.2.2.2 gehenna #define SDB_FOLLOW 0x01
102 1.2.2.2 gehenna #define SDB_KSTACK 0x02
103 1.2.2.2 gehenna #define SDB_FPSTATE 0x04
104 1.2.2.2 gehenna #endif
105 1.2.2.2 gehenna
106 1.2.2.2 gehenna /*
107 1.2.2.2 gehenna * Send an interrupt to process.
108 1.2.2.2 gehenna */
109 1.2.2.2 gehenna void
110 1.2.2.2 gehenna sendsig(catcher, sig, mask, code)
111 1.2.2.2 gehenna sig_t catcher;
112 1.2.2.2 gehenna int sig;
113 1.2.2.2 gehenna sigset_t *mask;
114 1.2.2.2 gehenna u_long code;
115 1.2.2.2 gehenna {
116 1.2.2.2 gehenna struct proc *p = curproc;
117 1.2.2.2 gehenna struct sigframe *fp, kf;
118 1.2.2.2 gehenna caddr_t sp;
119 1.2.2.2 gehenna struct trapframe *tf;
120 1.2.2.2 gehenna int onstack, fsize;
121 1.2.2.2 gehenna
122 1.2.2.2 gehenna tf = (struct trapframe *)p->p_md.md_regs;
123 1.2.2.2 gehenna
124 1.2.2.2 gehenna /* Do we need to jump onto the signal stack? */
125 1.2.2.2 gehenna onstack =
126 1.2.2.2 gehenna (p->p_sigctx.ps_sigstk.ss_flags & (SS_DISABLE | SS_ONSTACK)) == 0 &&
127 1.2.2.2 gehenna (SIGACTION(p, sig).sa_flags & SA_ONSTACK) != 0;
128 1.2.2.2 gehenna
129 1.2.2.2 gehenna /*
130 1.2.2.2 gehenna * Allocate space for the signal handler context.
131 1.2.2.2 gehenna * The PA-RISC calling convention mandates that
132 1.2.2.2 gehenna * the stack pointer must always be 64-byte aligned,
133 1.2.2.2 gehenna * and points to the first *unused* byte.
134 1.2.2.2 gehenna */
135 1.2.2.2 gehenna fsize = sizeof(struct sigframe);
136 1.2.2.2 gehenna sp = (onstack ?
137 1.2.2.2 gehenna (caddr_t)p->p_sigctx.ps_sigstk.ss_sp :
138 1.2.2.2 gehenna (caddr_t)tf->tf_sp);
139 1.2.2.2 gehenna sp = (caddr_t)(((u_int)(sp + fsize + 63)) & ~63);
140 1.2.2.2 gehenna fp = (struct sigframe *) (sp - fsize);
141 1.2.2.2 gehenna
142 1.2.2.2 gehenna #ifdef DEBUG
143 1.2.2.2 gehenna if ((sigdebug & SDB_FOLLOW) && (!sigpid || p->p_pid == sigpid))
144 1.2.2.2 gehenna printf("sendsig: %s[%d] sig %d catcher %p\n",
145 1.2.2.2 gehenna p->p_comm, p->p_pid, sig, catcher);
146 1.2.2.2 gehenna #endif
147 1.2.2.2 gehenna
148 1.2.2.2 gehenna /*
149 1.2.2.2 gehenna * Save necessary hardware state. Currently this includes:
150 1.2.2.2 gehenna * - original exception frame
151 1.2.2.2 gehenna * - FP coprocessor state
152 1.2.2.2 gehenna */
153 1.2.2.2 gehenna kf.sf_state.ss_flags = SS_USERREGS;
154 1.2.2.2 gehenna memcpy(&kf.sf_state.ss_frame, tf, sizeof(*tf));
155 1.2.2.2 gehenna /* XXX FP state */
156 1.2.2.2 gehenna
157 1.2.2.2 gehenna /* Build the signal context to be used by sigreturn. */
158 1.2.2.2 gehenna kf.sf_sc.sc_sp = tf->tf_sp;
159 1.2.2.2 gehenna kf.sf_sc.sc_fp = tf->tf_sp; /* XXX fredette - is this right? */
160 1.2.2.2 gehenna kf.sf_sc.sc_ap = (int)&fp->sf_state;
161 1.2.2.2 gehenna kf.sf_sc.sc_pcsqh = tf->tf_iisq_head;
162 1.2.2.2 gehenna kf.sf_sc.sc_pcoqh = tf->tf_iioq_head;
163 1.2.2.2 gehenna kf.sf_sc.sc_pcsqt = tf->tf_iisq_tail;
164 1.2.2.2 gehenna kf.sf_sc.sc_pcoqt = tf->tf_iioq_tail;
165 1.2.2.2 gehenna kf.sf_sc.sc_ps = tf->tf_ipsw;
166 1.2.2.2 gehenna
167 1.2.2.2 gehenna /* Save signal stack. */
168 1.2.2.2 gehenna kf.sf_sc.sc_onstack = p->p_sigctx.ps_sigstk.ss_flags & SS_ONSTACK;
169 1.2.2.2 gehenna
170 1.2.2.2 gehenna /* Save signal mask. */
171 1.2.2.2 gehenna kf.sf_sc.sc_mask = *mask;
172 1.2.2.2 gehenna
173 1.2.2.2 gehenna /* Fill the calling convention part of the signal frame. */
174 1.2.2.2 gehenna kf.sf_psp = 0;
175 1.2.2.2 gehenna kf.sf_clup = 0; /* XXX fredette - is this right? */
176 1.2.2.2 gehenna kf.sf_sl = 0; /* XXX fredette - is this right? */
177 1.2.2.2 gehenna kf.sf_edp = 0; /* XXX fredette - is this right? */
178 1.2.2.2 gehenna
179 1.2.2.2 gehenna /* Copy out the signal frame. */
180 1.2.2.2 gehenna if (copyout(&kf, fp, fsize)) {
181 1.2.2.2 gehenna #ifdef DEBUG
182 1.2.2.2 gehenna if ((sigdebug & SDB_KSTACK) && p->p_pid == sigpid)
183 1.2.2.2 gehenna printf("sendsig(%d): copyout failed on sig %d\n",
184 1.2.2.2 gehenna p->p_pid, sig);
185 1.2.2.2 gehenna #endif
186 1.2.2.2 gehenna /*
187 1.2.2.2 gehenna * Process has trashed its stack; give it an illegal
188 1.2.2.2 gehenna * instruction to halt it in its tracks.
189 1.2.2.2 gehenna */
190 1.2.2.2 gehenna sigexit(p, SIGILL);
191 1.2.2.2 gehenna /* NOTREACHED */
192 1.2.2.2 gehenna }
193 1.2.2.2 gehenna #ifdef DEBUG
194 1.2.2.2 gehenna if (sigdebug & SDB_FOLLOW)
195 1.2.2.2 gehenna printf("sendsig(%d): sig %d scp %p fp %p sc_sp %x sc_ap %x\n",
196 1.2.2.2 gehenna p->p_pid, sig, &fp->sf_sc, fp,
197 1.2.2.2 gehenna kf.sf_sc.sc_sp, kf.sf_sc.sc_ap);
198 1.2.2.2 gehenna #endif
199 1.2.2.2 gehenna
200 1.2.2.2 gehenna /* Set up the registers to return to sigcode. */
201 1.2.2.2 gehenna tf->tf_sp = (int)sp;
202 1.2.2.2 gehenna tf->tf_r3 = (int)&fp->sf_sc;
203 1.2.2.2 gehenna tf->tf_iioq_head = (int)p->p_sigctx.ps_sigcode | HPPA_PC_PRIV_USER;
204 1.2.2.2 gehenna tf->tf_iioq_tail = tf->tf_iioq_head + 4;
205 1.2.2.2 gehenna tf->tf_arg0 = sig;
206 1.2.2.2 gehenna tf->tf_arg1 = code;
207 1.2.2.2 gehenna tf->tf_arg2 = (int)&fp->sf_sc;
208 1.2.2.2 gehenna tf->tf_arg3 = (int)catcher;
209 1.2.2.2 gehenna
210 1.2.2.2 gehenna /* Remember that we're now on the signal stack. */
211 1.2.2.2 gehenna if (onstack)
212 1.2.2.2 gehenna p->p_sigctx.ps_sigstk.ss_flags |= SS_ONSTACK;
213 1.2.2.2 gehenna
214 1.2.2.2 gehenna #ifdef DEBUG
215 1.2.2.2 gehenna if ((sigdebug & SDB_KSTACK) && p->p_pid == sigpid)
216 1.2.2.2 gehenna printf("sendsig(%d): sig %d returns\n",
217 1.2.2.2 gehenna p->p_pid, sig);
218 1.2.2.2 gehenna #endif
219 1.2.2.2 gehenna }
220 1.2.2.2 gehenna
221 1.2.2.2 gehenna int
222 1.2.2.2 gehenna sys___sigreturn14(p, v, retval)
223 1.2.2.2 gehenna struct proc *p;
224 1.2.2.2 gehenna void *v;
225 1.2.2.2 gehenna register_t *retval;
226 1.2.2.2 gehenna {
227 1.2.2.2 gehenna struct sys___sigreturn14_args /* {
228 1.2.2.2 gehenna syscallarg(struct sigcontext *) sigcntxp;
229 1.2.2.2 gehenna } */ *uap = v;
230 1.2.2.2 gehenna struct sigcontext *scp;
231 1.2.2.2 gehenna struct trapframe *tf;
232 1.2.2.2 gehenna struct sigcontext tsigc;
233 1.2.2.2 gehenna struct sigstate tstate;
234 1.2.2.2 gehenna int rf, flags;
235 1.2.2.2 gehenna
236 1.2.2.2 gehenna /*
237 1.2.2.2 gehenna * The trampoline code hands us the context.
238 1.2.2.2 gehenna * It is unsafe to keep track of it ourselves, in the event that a
239 1.2.2.2 gehenna * program jumps out of a signal handler.
240 1.2.2.2 gehenna */
241 1.2.2.2 gehenna scp = SCARG(uap, sigcntxp);
242 1.2.2.2 gehenna #ifdef DEBUG
243 1.2.2.2 gehenna if (sigdebug & SDB_FOLLOW)
244 1.2.2.2 gehenna printf("sigreturn: pid %d, scp %p\n", p->p_pid, scp);
245 1.2.2.2 gehenna #endif
246 1.2.2.2 gehenna if ((int)scp & 3)
247 1.2.2.2 gehenna return (EINVAL);
248 1.2.2.2 gehenna
249 1.2.2.2 gehenna if (copyin(scp, &tsigc, sizeof(tsigc)) != 0)
250 1.2.2.2 gehenna return (EFAULT);
251 1.2.2.2 gehenna scp = &tsigc;
252 1.2.2.2 gehenna
253 1.2.2.2 gehenna /* Make sure the user isn't pulling a fast one on us! */
254 1.2.2.2 gehenna /* XXX fredette - until this is done, huge security hole here. */
255 1.2.2.2 gehenna /* XXX fredette - requiring that PSL_R be zero will hurt debuggers. */
256 1.2.2.2 gehenna #define PSW_MBS (PSW_C|PSW_Q|PSW_P|PSW_D|PSW_I)
257 1.2.2.2 gehenna #define PSW_MBZ (PSW_Y|PSW_Z|PSW_S|PSW_X|PSW_M|PSW_R)
258 1.2.2.2 gehenna if ((scp->sc_ps & (PSW_MBS|PSW_MBZ)) != PSW_MBS)
259 1.2.2.2 gehenna return (EINVAL);
260 1.2.2.2 gehenna
261 1.2.2.2 gehenna /* Restore register context. */
262 1.2.2.2 gehenna tf = (struct trapframe *) p->p_md.md_regs;
263 1.2.2.2 gehenna
264 1.2.2.2 gehenna /*
265 1.2.2.2 gehenna * Grab pointer to hardware state information.
266 1.2.2.2 gehenna * If zero, the user is probably doing a longjmp.
267 1.2.2.2 gehenna */
268 1.2.2.2 gehenna if ((rf = scp->sc_ap) == 0)
269 1.2.2.2 gehenna goto restore;
270 1.2.2.2 gehenna
271 1.2.2.2 gehenna /*
272 1.2.2.2 gehenna * See if there is anything to do before we go to the
273 1.2.2.2 gehenna * expense of copying in the trapframe
274 1.2.2.2 gehenna */
275 1.2.2.2 gehenna flags = fuword((caddr_t)rf);
276 1.2.2.2 gehenna #ifdef DEBUG
277 1.2.2.2 gehenna if (sigdebug & SDB_FOLLOW)
278 1.2.2.2 gehenna printf("sigreturn(%d): sc_ap %x flags %x\n",
279 1.2.2.2 gehenna p->p_pid, rf, flags);
280 1.2.2.2 gehenna #endif
281 1.2.2.2 gehenna /* fuword failed (bogus sc_ap value). */
282 1.2.2.2 gehenna if (flags == -1)
283 1.2.2.2 gehenna return (EINVAL);
284 1.2.2.2 gehenna
285 1.2.2.2 gehenna if (flags == 0 || copyin((caddr_t)rf, &tstate, sizeof(tstate)) != 0)
286 1.2.2.2 gehenna goto restore;
287 1.2.2.2 gehenna #ifdef DEBUG
288 1.2.2.2 gehenna if ((sigdebug & SDB_KSTACK) && p->p_pid == sigpid)
289 1.2.2.2 gehenna printf("sigreturn(%d): ssp %p usp %x scp %p\n",
290 1.2.2.2 gehenna p->p_pid, &flags, scp->sc_sp, SCARG(uap, sigcntxp));
291 1.2.2.2 gehenna #endif
292 1.2.2.2 gehenna
293 1.2.2.2 gehenna /*
294 1.2.2.2 gehenna * Restore most of the users registers except for those
295 1.2.2.2 gehenna * in the sigcontext; they will be handled below.
296 1.2.2.2 gehenna */
297 1.2.2.2 gehenna if (flags & SS_USERREGS) {
298 1.2.2.2 gehenna
299 1.2.2.2 gehenna /*
300 1.2.2.2 gehenna * There are more registers that the user can tell
301 1.2.2.2 gehenna * us to bash than registers that, for security
302 1.2.2.2 gehenna * or other reasons, we must protect. So it's
303 1.2.2.2 gehenna * easier (but not faster), to copy these sensitive
304 1.2.2.2 gehenna * register values into the user-provided frame,
305 1.2.2.2 gehenna * then bulk-copy the user-provided frame into
306 1.2.2.2 gehenna * the process' frame.
307 1.2.2.2 gehenna */
308 1.2.2.2 gehenna #define SIG_PROTECT(r) tstate.ss_frame.r = tf->r
309 1.2.2.2 gehenna /* SRs 5,6,7 must be protected. */
310 1.2.2.2 gehenna SIG_PROTECT(tf_sr5);
311 1.2.2.2 gehenna SIG_PROTECT(tf_sr6);
312 1.2.2.2 gehenna SIG_PROTECT(tf_sr7);
313 1.2.2.2 gehenna
314 1.2.2.2 gehenna /* all CRs except CR11 must be protected. */
315 1.2.2.2 gehenna SIG_PROTECT(tf_rctr); /* CR0 */
316 1.2.2.2 gehenna /* CRs 1-8 are reserved */
317 1.2.2.2 gehenna SIG_PROTECT(tf_pidr1); /* CR8 */
318 1.2.2.2 gehenna SIG_PROTECT(tf_pidr2); /* CR9 */
319 1.2.2.2 gehenna SIG_PROTECT(tf_ccr); /* CR10 */
320 1.2.2.2 gehenna SIG_PROTECT(tf_pidr3); /* CR12 */
321 1.2.2.2 gehenna SIG_PROTECT(tf_pidr4); /* CR14 */
322 1.2.2.2 gehenna SIG_PROTECT(tf_eiem); /* CR15 */
323 1.2.2.2 gehenna /* CR17 is the IISQ head */
324 1.2.2.2 gehenna /* CR18 is the IIOQ head */
325 1.2.2.2 gehenna SIG_PROTECT(tf_iir); /* CR19 */
326 1.2.2.2 gehenna SIG_PROTECT(tf_isr); /* CR20 */
327 1.2.2.2 gehenna SIG_PROTECT(tf_ior); /* CR21 */
328 1.2.2.2 gehenna /* CR22 is the IPSW */
329 1.2.2.2 gehenna SIG_PROTECT(tf_eirr); /* CR23 */
330 1.2.2.2 gehenna SIG_PROTECT(tf_hptm); /* CR24 */
331 1.2.2.2 gehenna SIG_PROTECT(tf_vtop); /* CR25 */
332 1.2.2.2 gehenna /* XXX where are CR26, CR27, CR29, CR31? */
333 1.2.2.2 gehenna SIG_PROTECT(tf_cr28); /* CR28 */
334 1.2.2.2 gehenna SIG_PROTECT(tf_cr30); /* CR30 */
335 1.2.2.2 gehenna #undef SIG_PROTECT
336 1.2.2.2 gehenna
337 1.2.2.2 gehenna /* The bulk copy. */
338 1.2.2.2 gehenna *tf = tstate.ss_frame;
339 1.2.2.2 gehenna }
340 1.2.2.2 gehenna
341 1.2.2.2 gehenna /*
342 1.2.2.2 gehenna * Restore the original FP context
343 1.2.2.2 gehenna */
344 1.2.2.2 gehenna /* XXX fredette */
345 1.2.2.2 gehenna
346 1.2.2.2 gehenna restore:
347 1.2.2.2 gehenna /*
348 1.2.2.2 gehenna * Restore the user supplied information.
349 1.2.2.2 gehenna * This should be at the last so that the error (EINVAL)
350 1.2.2.2 gehenna * is reported to the sigreturn caller, not to the
351 1.2.2.2 gehenna * jump destination.
352 1.2.2.2 gehenna */
353 1.2.2.2 gehenna
354 1.2.2.2 gehenna tf->tf_sp = scp->sc_sp;
355 1.2.2.2 gehenna /* XXX should we be doing the space registers? */
356 1.2.2.2 gehenna tf->tf_iisq_head = scp->sc_pcsqh;
357 1.2.2.2 gehenna tf->tf_iioq_head = scp->sc_pcoqh | HPPA_PC_PRIV_USER;
358 1.2.2.2 gehenna tf->tf_iisq_tail = scp->sc_pcsqt;
359 1.2.2.2 gehenna tf->tf_iioq_tail = scp->sc_pcoqt | HPPA_PC_PRIV_USER;
360 1.2.2.2 gehenna tf->tf_ipsw = scp->sc_ps;
361 1.2.2.2 gehenna
362 1.2.2.2 gehenna /* Restore signal stack. */
363 1.2.2.2 gehenna if (scp->sc_onstack & SS_ONSTACK)
364 1.2.2.2 gehenna p->p_sigctx.ps_sigstk.ss_flags |= SS_ONSTACK;
365 1.2.2.2 gehenna else
366 1.2.2.2 gehenna p->p_sigctx.ps_sigstk.ss_flags &= ~SS_ONSTACK;
367 1.2.2.2 gehenna
368 1.2.2.2 gehenna /* Restore signal mask. */
369 1.2.2.2 gehenna (void) sigprocmask1(p, SIG_SETMASK, &scp->sc_mask, 0);
370 1.2.2.2 gehenna
371 1.2.2.2 gehenna #ifdef DEBUG
372 1.2.2.2 gehenna #if 0 /* XXX FP state */
373 1.2.2.2 gehenna if ((sigdebug & SDB_FPSTATE) && *(char *)&tstate.ss_fpstate)
374 1.2.2.2 gehenna printf("sigreturn(%d): copied in FP state (%x) at %p\n",
375 1.2.2.2 gehenna p->p_pid, *(u_int *)&tstate.ss_fpstate,
376 1.2.2.2 gehenna &tstate.ss_fpstate);
377 1.2.2.2 gehenna #endif
378 1.2.2.2 gehenna if ((sigdebug & SDB_FOLLOW) ||
379 1.2.2.2 gehenna ((sigdebug & SDB_KSTACK) && p->p_pid == sigpid))
380 1.2.2.2 gehenna printf("sigreturn(%d): returns\n", p->p_pid);
381 1.2.2.2 gehenna #endif
382 1.2.2.2 gehenna return (EJUSTRETURN);
383 1.2.2.2 gehenna }
384 1.2.2.2 gehenna
385