| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: linux_machdep.c,v 1.44 2011/01/18 01:13:03 matt Exp $ */ | | 1 | /* $NetBSD: linux_machdep.c,v 1.45 2011/01/20 11:59:24 he Exp $ */ |
2 | | | 2 | |
3 | /*- | | 3 | /*- |
4 | * Copyright (c) 1995, 2000, 2001 The NetBSD Foundation, Inc. | | 4 | * Copyright (c) 1995, 2000, 2001 The NetBSD Foundation, Inc. |
5 | * All rights reserved. | | 5 | * All rights reserved. |
6 | * | | 6 | * |
7 | * This code is derived from software contributed to The NetBSD Foundation | | 7 | * This code is derived from software contributed to The NetBSD Foundation |
8 | * by Frank van der Linden and Emmanuel Dreyfus. | | 8 | * by Frank van der Linden and Emmanuel Dreyfus. |
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. |
| @@ -20,27 +20,27 @@ | | | @@ -20,27 +20,27 @@ |
20 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED | | 20 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED |
21 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | | 21 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
22 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS | | 22 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS |
23 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | | 23 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
24 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | | 24 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
25 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | | 25 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
26 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | | 26 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
27 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | | 27 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
28 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | | 28 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
29 | * POSSIBILITY OF SUCH DAMAGE. | | 29 | * POSSIBILITY OF SUCH DAMAGE. |
30 | */ | | 30 | */ |
31 | | | 31 | |
32 | #include <sys/cdefs.h> | | 32 | #include <sys/cdefs.h> |
33 | __KERNEL_RCSID(0, "$NetBSD: linux_machdep.c,v 1.44 2011/01/18 01:13:03 matt Exp $"); | | 33 | __KERNEL_RCSID(0, "$NetBSD: linux_machdep.c,v 1.45 2011/01/20 11:59:24 he Exp $"); |
34 | | | 34 | |
35 | #include <sys/param.h> | | 35 | #include <sys/param.h> |
36 | #include <sys/systm.h> | | 36 | #include <sys/systm.h> |
37 | #include <sys/signalvar.h> | | 37 | #include <sys/signalvar.h> |
38 | #include <sys/kernel.h> | | 38 | #include <sys/kernel.h> |
39 | #include <sys/proc.h> | | 39 | #include <sys/proc.h> |
40 | #include <sys/buf.h> | | 40 | #include <sys/buf.h> |
41 | #include <sys/reboot.h> | | 41 | #include <sys/reboot.h> |
42 | #include <sys/conf.h> | | 42 | #include <sys/conf.h> |
43 | #include <sys/exec.h> | | 43 | #include <sys/exec.h> |
44 | #include <sys/file.h> | | 44 | #include <sys/file.h> |
45 | #include <sys/callout.h> | | 45 | #include <sys/callout.h> |
46 | #include <sys/malloc.h> | | 46 | #include <sys/malloc.h> |
| @@ -171,27 +171,27 @@ linux_sendsig(const ksiginfo_t *ksi, con | | | @@ -171,27 +171,27 @@ linux_sendsig(const ksiginfo_t *ksi, con |
171 | linux_regs.lctr = tf->tf_ctr; | | 171 | linux_regs.lctr = tf->tf_ctr; |
172 | linux_regs.llink = tf->tf_lr; | | 172 | linux_regs.llink = tf->tf_lr; |
173 | linux_regs.lxer = tf->tf_xer; | | 173 | linux_regs.lxer = tf->tf_xer; |
174 | linux_regs.lccr = tf->tf_cr; | | 174 | linux_regs.lccr = tf->tf_cr; |
175 | linux_regs.lmq = 0; /* Unused, 601 only */ | | 175 | linux_regs.lmq = 0; /* Unused, 601 only */ |
176 | linux_regs.ltrap = tf->tf_exc; | | 176 | linux_regs.ltrap = tf->tf_exc; |
177 | linux_regs.ldar = tf->tf_dar; | | 177 | linux_regs.ldar = tf->tf_dar; |
178 | linux_regs.ldsisr = tf->tf_dsisr; | | 178 | linux_regs.ldsisr = tf->tf_dsisr; |
179 | linux_regs.lresult = 0; | | 179 | linux_regs.lresult = 0; |
180 | | | 180 | |
181 | memset(&frame, 0, sizeof(frame)); | | 181 | memset(&frame, 0, sizeof(frame)); |
182 | memcpy(&frame.lgp_regs, &linux_regs, sizeof(linux_regs)); | | 182 | memcpy(&frame.lgp_regs, &linux_regs, sizeof(linux_regs)); |
183 | | | 183 | |
184 | save_fpu_lwp(curlwp, FPU_SAVE); | | 184 | fpu_save_lwp(curlwp, FPU_SAVE); |
185 | memcpy(&frame.lfp_regs, curpcb->pcb_fpu.fpreg, sizeof(frame.lfp_regs)); | | 185 | memcpy(&frame.lfp_regs, curpcb->pcb_fpu.fpreg, sizeof(frame.lfp_regs)); |
186 | | | 186 | |
187 | /* | | 187 | /* |
188 | * Copy Linux's signal trampoline on the user stack It should not | | 188 | * Copy Linux's signal trampoline on the user stack It should not |
189 | * be used, but Linux binaries might expect it to be there. | | 189 | * be used, but Linux binaries might expect it to be there. |
190 | */ | | 190 | */ |
191 | frame.ltramp[0] = 0x38997777; /* li r0, 0x7777 */ | | 191 | frame.ltramp[0] = 0x38997777; /* li r0, 0x7777 */ |
192 | frame.ltramp[1] = 0x44000002; /* sc */ | | 192 | frame.ltramp[1] = 0x44000002; /* sc */ |
193 | | | 193 | |
194 | /* | | 194 | /* |
195 | * Move it to the user stack | | 195 | * Move it to the user stack |
196 | * There is a little trick here, about the LINUX_ABIGAP: the | | 196 | * There is a little trick here, about the LINUX_ABIGAP: the |
197 | * linux_sigreg structure has a 56 int gap to support rs6000/xcoff | | 197 | * linux_sigreg structure has a 56 int gap to support rs6000/xcoff |
| @@ -309,27 +309,27 @@ linux_sys_rt_sigreturn(struct lwp *l, co | | | @@ -309,27 +309,27 @@ linux_sys_rt_sigreturn(struct lwp *l, co |
309 | | | 309 | |
310 | for (i = 0; i < 32; i++) | | 310 | for (i = 0; i < 32; i++) |
311 | tf->tf_fixreg[i] = lregs->lgpr[i]; | | 311 | tf->tf_fixreg[i] = lregs->lgpr[i]; |
312 | tf->tf_lr = lregs->llink; | | 312 | tf->tf_lr = lregs->llink; |
313 | tf->tf_cr = lregs->lccr; | | 313 | tf->tf_cr = lregs->lccr; |
314 | tf->tf_xer = lregs->lxer; | | 314 | tf->tf_xer = lregs->lxer; |
315 | tf->tf_ctr = lregs->lctr; | | 315 | tf->tf_ctr = lregs->lctr; |
316 | tf->tf_srr0 = lregs->lnip; | | 316 | tf->tf_srr0 = lregs->lnip; |
317 | tf->tf_srr1 = lregs->lmsr; | | 317 | tf->tf_srr1 = lregs->lmsr; |
318 | | | 318 | |
319 | /* | | 319 | /* |
320 | * Make sure the fpu state is discarded | | 320 | * Make sure the fpu state is discarded |
321 | */ | | 321 | */ |
322 | save_fpu_lwp(curlwp, FPU_DISCARD); | | 322 | fpu_save_lwp(curlwp, FPU_DISCARD); |
323 | | | 323 | |
324 | memcpy(curpcb->pcb_fpu.fpreg, (void *)&sregs.lfp_regs, | | 324 | memcpy(curpcb->pcb_fpu.fpreg, (void *)&sregs.lfp_regs, |
325 | sizeof(curpcb->pcb_fpu.fpreg)); | | 325 | sizeof(curpcb->pcb_fpu.fpreg)); |
326 | | | 326 | |
327 | mutex_enter(p->p_lock); | | 327 | mutex_enter(p->p_lock); |
328 | | | 328 | |
329 | /* | | 329 | /* |
330 | * Restore signal stack. | | 330 | * Restore signal stack. |
331 | * | | 331 | * |
332 | * XXX cannot find the onstack information in Linux sig context. | | 332 | * XXX cannot find the onstack information in Linux sig context. |
333 | * Is signal stack really supported on Linux? | | 333 | * Is signal stack really supported on Linux? |
334 | * | | 334 | * |
335 | * It seems to be supported in libc6... | | 335 | * It seems to be supported in libc6... |
| @@ -399,27 +399,27 @@ linux_sys_sigreturn(struct lwp *l, const | | | @@ -399,27 +399,27 @@ linux_sys_sigreturn(struct lwp *l, const |
399 | | | 399 | |
400 | for (i = 0; i < 32; i++) | | 400 | for (i = 0; i < 32; i++) |
401 | tf->tf_fixreg[i] = lregs->lgpr[i]; | | 401 | tf->tf_fixreg[i] = lregs->lgpr[i]; |
402 | tf->tf_lr = lregs->llink; | | 402 | tf->tf_lr = lregs->llink; |
403 | tf->tf_cr = lregs->lccr; | | 403 | tf->tf_cr = lregs->lccr; |
404 | tf->tf_xer = lregs->lxer; | | 404 | tf->tf_xer = lregs->lxer; |
405 | tf->tf_ctr = lregs->lctr; | | 405 | tf->tf_ctr = lregs->lctr; |
406 | tf->tf_srr0 = lregs->lnip; | | 406 | tf->tf_srr0 = lregs->lnip; |
407 | tf->tf_srr1 = lregs->lmsr; | | 407 | tf->tf_srr1 = lregs->lmsr; |
408 | | | 408 | |
409 | /* | | 409 | /* |
410 | * Make sure the fpu state is discarded | | 410 | * Make sure the fpu state is discarded |
411 | */ | | 411 | */ |
412 | save_fpu_lwp(curlwp, FPU_DISCARD); | | 412 | fpu_save_lwp(curlwp, FPU_DISCARD); |
413 | | | 413 | |
414 | memcpy(curpcb->pcb_fpu.fpreg, (void *)&sregs.lfp_regs, | | 414 | memcpy(curpcb->pcb_fpu.fpreg, (void *)&sregs.lfp_regs, |
415 | sizeof(curpcb->pcb_fpu.fpreg)); | | 415 | sizeof(curpcb->pcb_fpu.fpreg)); |
416 | | | 416 | |
417 | mutex_enter(p->p_lock); | | 417 | mutex_enter(p->p_lock); |
418 | | | 418 | |
419 | /* | | 419 | /* |
420 | * Restore signal stack. | | 420 | * Restore signal stack. |
421 | * | | 421 | * |
422 | * XXX cannot find the onstack information in Linux sig context. | | 422 | * XXX cannot find the onstack information in Linux sig context. |
423 | * Is signal stack really supported on Linux? | | 423 | * Is signal stack really supported on Linux? |
424 | */ | | 424 | */ |
425 | #if 0 | | 425 | #if 0 |