2 * Emulation of Linux signals
4 * Copyright (c) 2003 Fabrice Bellard
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, see <http://www.gnu.org/licenses/>.
19 #include "qemu/osdep.h"
21 #include "user-internals.h"
22 #include "signal-common.h"
23 #include "linux-user/trace.h"
25 /* A Sparc register window */
26 struct target_reg_window
{
31 /* A Sparc stack frame. */
32 struct target_stackf
{
34 * Since qemu does not reference fp or callers_pc directly,
35 * it's simpler to treat fp and callers_pc as elements of ins[],
36 * and then bundle locals[] and ins[] into reg_window.
38 struct target_reg_window win
;
40 * Similarly, bundle structptr and xxargs into xargs[].
41 * This portion of the struct is part of the function call abi,
42 * and belongs to the callee for spilling argument registers.
47 struct target_siginfo_fpu
{
49 uint64_t si_double_regs
[32];
54 /* It is more convenient for qemu to move doubles, not singles. */
55 uint64_t si_double_regs
[16];
65 #ifdef TARGET_ARCH_HAS_SETUP_FRAME
66 struct target_signal_frame
{
67 struct target_stackf ss
;
68 struct target_pt_regs regs
;
71 uint32_t insns
[2] QEMU_ALIGNED(8);
72 abi_ulong extramask
[TARGET_NSIG_WORDS
- 1];
73 abi_ulong extra_size
; /* Should be 0 */
78 struct target_rt_signal_frame
{
79 struct target_stackf ss
;
80 target_siginfo_t info
;
81 struct target_pt_regs regs
;
82 #if defined(TARGET_SPARC64) && !defined(TARGET_ABI32)
91 abi_ulong extra_size
; /* Should be 0 */
96 static abi_ulong
get_sigframe(struct target_sigaction
*sa
,
100 abi_ulong sp
= get_sp_from_cpustate(env
);
103 * If we are on the alternate signal stack and would overflow it, don't.
104 * Return an always-bogus address instead so we will die with SIGSEGV.
106 if (on_sig_stack(sp
) && !likely(on_sig_stack(sp
- framesize
))) {
110 /* This is the X/Open sanctioned signal stack switching. */
111 sp
= target_sigsp(sp
, sa
) - framesize
;
114 * Always align the stack frame. This handles two cases. First,
115 * sigaltstack need not be mindful of platform specific stack
116 * alignment. Second, if we took this signal because the stack
117 * is not aligned properly, we'd like to take the signal cleanly
125 static void save_pt_regs(struct target_pt_regs
*regs
, CPUSPARCState
*env
)
129 #if defined(TARGET_SPARC64) && !defined(TARGET_ABI32)
130 __put_user(sparc64_tstate(env
), ®s
->tstate
);
131 /* TODO: magic should contain PT_REG_MAGIC + %tt. */
132 __put_user(0, ®s
->magic
);
134 __put_user(cpu_get_psr(env
), ®s
->psr
);
137 __put_user(env
->pc
, ®s
->pc
);
138 __put_user(env
->npc
, ®s
->npc
);
139 __put_user(env
->y
, ®s
->y
);
141 for (i
= 0; i
< 8; i
++) {
142 __put_user(env
->gregs
[i
], ®s
->u_regs
[i
]);
144 for (i
= 0; i
< 8; i
++) {
145 __put_user(env
->regwptr
[WREG_O0
+ i
], ®s
->u_regs
[i
+ 8]);
149 static void restore_pt_regs(struct target_pt_regs
*regs
, CPUSPARCState
*env
)
153 #if defined(TARGET_SPARC64) && !defined(TARGET_ABI32)
154 /* User can only change condition codes and %asi in %tstate. */
156 __get_user(tstate
, ®s
->tstate
);
157 cpu_put_ccr(env
, tstate
>> 32);
158 env
->asi
= extract64(tstate
, 24, 8);
161 * User can only change condition codes and FPU enabling in %psr.
162 * But don't bother with FPU enabling, since a real kernel would
163 * just re-enable the FPU upon the next fpu trap.
166 __get_user(psr
, ®s
->psr
);
167 env
->psr
= (psr
& PSR_ICC
) | (env
->psr
& ~PSR_ICC
);
170 /* Note that pc and npc are handled in the caller. */
172 __get_user(env
->y
, ®s
->y
);
174 for (i
= 0; i
< 8; i
++) {
175 __get_user(env
->gregs
[i
], ®s
->u_regs
[i
]);
177 for (i
= 0; i
< 8; i
++) {
178 __get_user(env
->regwptr
[WREG_O0
+ i
], ®s
->u_regs
[i
+ 8]);
182 static void save_reg_win(struct target_reg_window
*win
, CPUSPARCState
*env
)
186 for (i
= 0; i
< 8; i
++) {
187 __put_user(env
->regwptr
[i
+ WREG_L0
], &win
->locals
[i
]);
189 for (i
= 0; i
< 8; i
++) {
190 __put_user(env
->regwptr
[i
+ WREG_I0
], &win
->ins
[i
]);
194 static void save_fpu(struct target_siginfo_fpu
*fpu
, CPUSPARCState
*env
)
198 #ifdef TARGET_SPARC64
199 for (i
= 0; i
< 32; ++i
) {
200 __put_user(env
->fpr
[i
].ll
, &fpu
->si_double_regs
[i
]);
202 __put_user(env
->fsr
, &fpu
->si_fsr
);
203 __put_user(env
->gsr
, &fpu
->si_gsr
);
204 __put_user(env
->fprs
, &fpu
->si_fprs
);
206 for (i
= 0; i
< 16; ++i
) {
207 __put_user(env
->fpr
[i
].ll
, &fpu
->si_double_regs
[i
]);
209 __put_user(env
->fsr
, &fpu
->si_fsr
);
210 __put_user(0, &fpu
->si_fpqdepth
);
214 static void restore_fpu(struct target_siginfo_fpu
*fpu
, CPUSPARCState
*env
)
218 #ifdef TARGET_SPARC64
220 __get_user(fprs
, &fpu
->si_fprs
);
222 /* In case the user mucks about with FPRS, restore as directed. */
223 if (fprs
& FPRS_DL
) {
224 for (i
= 0; i
< 16; ++i
) {
225 __get_user(env
->fpr
[i
].ll
, &fpu
->si_double_regs
[i
]);
228 if (fprs
& FPRS_DU
) {
229 for (i
= 16; i
< 32; ++i
) {
230 __get_user(env
->fpr
[i
].ll
, &fpu
->si_double_regs
[i
]);
233 __get_user(env
->fsr
, &fpu
->si_fsr
);
234 __get_user(env
->gsr
, &fpu
->si_gsr
);
237 for (i
= 0; i
< 16; ++i
) {
238 __get_user(env
->fpr
[i
].ll
, &fpu
->si_double_regs
[i
]);
240 __get_user(env
->fsr
, &fpu
->si_fsr
);
244 #ifdef TARGET_ARCH_HAS_SETUP_FRAME
245 static void install_sigtramp(uint32_t *tramp
, int syscall
)
247 __put_user(0x82102000u
+ syscall
, &tramp
[0]); /* mov syscall, %g1 */
248 __put_user(0x91d02010u
, &tramp
[1]); /* t 0x10 */
251 void setup_frame(int sig
, struct target_sigaction
*ka
,
252 target_sigset_t
*set
, CPUSPARCState
*env
)
255 struct target_signal_frame
*sf
;
256 size_t sf_size
= sizeof(*sf
) + sizeof(struct target_siginfo_fpu
);
259 sf_addr
= get_sigframe(ka
, env
, sf_size
);
260 trace_user_setup_frame(env
, sf_addr
);
262 sf
= lock_user(VERIFY_WRITE
, sf_addr
, sf_size
, 0);
268 /* 2. Save the current process state */
269 save_pt_regs(&sf
->regs
, env
);
270 __put_user(0, &sf
->extra_size
);
272 save_fpu((struct target_siginfo_fpu
*)(sf
+ 1), env
);
273 __put_user(sf_addr
+ sizeof(*sf
), &sf
->fpu_save
);
275 __put_user(0, &sf
->rwin_save
); /* TODO: save_rwin_state */
277 __put_user(set
->sig
[0], &sf
->si_mask
);
278 for (i
= 0; i
< TARGET_NSIG_WORDS
- 1; i
++) {
279 __put_user(set
->sig
[i
+ 1], &sf
->extramask
[i
]);
282 save_reg_win(&sf
->ss
.win
, env
);
284 /* 3. signal handler back-trampoline and parameters */
285 env
->regwptr
[WREG_SP
] = sf_addr
;
286 env
->regwptr
[WREG_O0
] = sig
;
287 env
->regwptr
[WREG_O1
] = sf_addr
+
288 offsetof(struct target_signal_frame
, regs
);
289 env
->regwptr
[WREG_O2
] = sf_addr
+
290 offsetof(struct target_signal_frame
, regs
);
292 /* 4. signal handler */
293 env
->pc
= ka
->_sa_handler
;
294 env
->npc
= env
->pc
+ 4;
296 /* 5. return to kernel instructions */
297 if (ka
->ka_restorer
) {
298 env
->regwptr
[WREG_O7
] = ka
->ka_restorer
;
300 /* Not used, but retain for ABI compatibility. */
301 install_sigtramp(sf
->insns
, TARGET_NR_sigreturn
);
302 env
->regwptr
[WREG_O7
] = default_sigreturn
;
304 unlock_user(sf
, sf_addr
, sf_size
);
306 #endif /* TARGET_ARCH_HAS_SETUP_FRAME */
308 void setup_rt_frame(int sig
, struct target_sigaction
*ka
,
309 target_siginfo_t
*info
,
310 target_sigset_t
*set
, CPUSPARCState
*env
)
313 struct target_rt_signal_frame
*sf
;
314 size_t sf_size
= sizeof(*sf
) + sizeof(struct target_siginfo_fpu
);
316 sf_addr
= get_sigframe(ka
, env
, sf_size
);
317 trace_user_setup_rt_frame(env
, sf_addr
);
319 sf
= lock_user(VERIFY_WRITE
, sf_addr
, sf_size
, 0);
325 /* 2. Save the current process state */
326 save_reg_win(&sf
->ss
.win
, env
);
327 save_pt_regs(&sf
->regs
, env
);
329 save_fpu((struct target_siginfo_fpu
*)(sf
+ 1), env
);
330 __put_user(sf_addr
+ sizeof(*sf
), &sf
->fpu_save
);
332 __put_user(0, &sf
->rwin_save
); /* TODO: save_rwin_state */
334 tswap_siginfo(&sf
->info
, info
);
335 tswap_sigset(&sf
->mask
, set
);
336 target_save_altstack(&sf
->stack
, env
);
339 __put_user(0, &sf
->extra_size
);
342 /* 3. signal handler back-trampoline and parameters */
343 env
->regwptr
[WREG_SP
] = sf_addr
- TARGET_STACK_BIAS
;
344 env
->regwptr
[WREG_O0
] = sig
;
345 env
->regwptr
[WREG_O1
] =
346 sf_addr
+ offsetof(struct target_rt_signal_frame
, info
);
348 env
->regwptr
[WREG_O2
] =
349 sf_addr
+ offsetof(struct target_rt_signal_frame
, regs
);
351 env
->regwptr
[WREG_O2
] = env
->regwptr
[WREG_O1
];
354 /* 4. signal handler */
355 env
->pc
= ka
->_sa_handler
;
356 env
->npc
= env
->pc
+ 4;
358 /* 5. return to kernel instructions */
360 if (ka
->ka_restorer
) {
361 env
->regwptr
[WREG_O7
] = ka
->ka_restorer
;
363 /* Not used, but retain for ABI compatibility. */
364 install_sigtramp(sf
->insns
, TARGET_NR_rt_sigreturn
);
365 env
->regwptr
[WREG_O7
] = default_rt_sigreturn
;
368 env
->regwptr
[WREG_O7
] = ka
->ka_restorer
;
371 unlock_user(sf
, sf_addr
, sf_size
);
374 long do_sigreturn(CPUSPARCState
*env
)
376 #ifdef TARGET_ARCH_HAS_SETUP_FRAME
378 struct target_signal_frame
*sf
= NULL
;
379 abi_ulong pc
, npc
, ptr
;
384 sf_addr
= env
->regwptr
[WREG_SP
];
385 trace_user_do_sigreturn(env
, sf_addr
);
387 /* 1. Make sure we are not getting garbage from the user */
388 if ((sf_addr
& 15) || !lock_user_struct(VERIFY_READ
, sf
, sf_addr
, 1)) {
392 /* Make sure stack pointer is aligned. */
393 __get_user(ptr
, &sf
->regs
.u_regs
[14]);
398 /* Make sure instruction pointers are aligned. */
399 __get_user(pc
, &sf
->regs
.pc
);
400 __get_user(npc
, &sf
->regs
.npc
);
401 if ((pc
| npc
) & 3) {
405 /* 2. Restore the state */
406 restore_pt_regs(&sf
->regs
, env
);
410 __get_user(ptr
, &sf
->fpu_save
);
412 struct target_siginfo_fpu
*fpu
;
413 if ((ptr
& 3) || !lock_user_struct(VERIFY_READ
, fpu
, ptr
, 1)) {
416 restore_fpu(fpu
, env
);
417 unlock_user_struct(fpu
, ptr
, 0);
420 __get_user(ptr
, &sf
->rwin_save
);
422 goto segv_and_exit
; /* TODO: restore_rwin */
425 __get_user(set
.sig
[0], &sf
->si_mask
);
426 for (i
= 1; i
< TARGET_NSIG_WORDS
; i
++) {
427 __get_user(set
.sig
[i
], &sf
->extramask
[i
- 1]);
430 target_to_host_sigset_internal(&host_set
, &set
);
431 set_sigmask(&host_set
);
433 unlock_user_struct(sf
, sf_addr
, 0);
434 return -QEMU_ESIGRETURN
;
437 unlock_user_struct(sf
, sf_addr
, 0);
438 force_sig(TARGET_SIGSEGV
);
439 return -QEMU_ESIGRETURN
;
441 return -TARGET_ENOSYS
;
445 long do_rt_sigreturn(CPUSPARCState
*env
)
447 abi_ulong sf_addr
, tpc
, tnpc
, ptr
;
448 struct target_rt_signal_frame
*sf
= NULL
;
451 sf_addr
= get_sp_from_cpustate(env
);
452 trace_user_do_rt_sigreturn(env
, sf_addr
);
454 /* 1. Make sure we are not getting garbage from the user */
455 if ((sf_addr
& 15) || !lock_user_struct(VERIFY_READ
, sf
, sf_addr
, 1)) {
459 /* Validate SP alignment. */
460 __get_user(ptr
, &sf
->regs
.u_regs
[8 + WREG_SP
]);
461 if ((ptr
+ TARGET_STACK_BIAS
) & 7) {
465 /* Validate PC and NPC alignment. */
466 __get_user(tpc
, &sf
->regs
.pc
);
467 __get_user(tnpc
, &sf
->regs
.npc
);
468 if ((tpc
| tnpc
) & 3) {
472 /* 2. Restore the state */
473 restore_pt_regs(&sf
->regs
, env
);
475 __get_user(ptr
, &sf
->fpu_save
);
477 struct target_siginfo_fpu
*fpu
;
478 if ((ptr
& 7) || !lock_user_struct(VERIFY_READ
, fpu
, ptr
, 1)) {
481 restore_fpu(fpu
, env
);
482 unlock_user_struct(fpu
, ptr
, 0);
485 __get_user(ptr
, &sf
->rwin_save
);
487 goto segv_and_exit
; /* TODO: restore_rwin_state */
490 target_restore_altstack(&sf
->stack
, env
);
491 target_to_host_sigset(&set
, &sf
->mask
);
497 unlock_user_struct(sf
, sf_addr
, 0);
498 return -QEMU_ESIGRETURN
;
501 unlock_user_struct(sf
, sf_addr
, 0);
502 force_sig(TARGET_SIGSEGV
);
503 return -QEMU_ESIGRETURN
;
506 #if defined(TARGET_SPARC64) && !defined(TARGET_ABI32)
507 #define SPARC_MC_TSTATE 0
508 #define SPARC_MC_PC 1
509 #define SPARC_MC_NPC 2
511 #define SPARC_MC_G1 4
512 #define SPARC_MC_G2 5
513 #define SPARC_MC_G3 6
514 #define SPARC_MC_G4 7
515 #define SPARC_MC_G5 8
516 #define SPARC_MC_G6 9
517 #define SPARC_MC_G7 10
518 #define SPARC_MC_O0 11
519 #define SPARC_MC_O1 12
520 #define SPARC_MC_O2 13
521 #define SPARC_MC_O3 14
522 #define SPARC_MC_O4 15
523 #define SPARC_MC_O5 16
524 #define SPARC_MC_O6 17
525 #define SPARC_MC_O7 18
526 #define SPARC_MC_NGREG 19
528 typedef abi_ulong target_mc_greg_t
;
529 typedef target_mc_greg_t target_mc_gregset_t
[SPARC_MC_NGREG
];
531 struct target_mc_fq
{
537 * Note the manual 16-alignment; the kernel gets this because it
538 * includes a "long double qregs[16]" in the mcpu_fregs union,
541 struct target_mc_fpu
{
545 //uint128_t qregs[16];
548 abi_ulong mcfpu_fprs
;
551 unsigned char mcfpu_qcnt
;
552 unsigned char mcfpu_qentsz
;
553 unsigned char mcfpu_enab
;
554 } __attribute__((aligned(16)));
555 typedef struct target_mc_fpu target_mc_fpu_t
;
558 target_mc_gregset_t mc_gregs
;
559 target_mc_greg_t mc_fp
;
560 target_mc_greg_t mc_i7
;
561 target_mc_fpu_t mc_fpregs
;
564 struct target_ucontext
{
567 target_sigset_t tuc_sigmask
;
568 target_mcontext_t tuc_mcontext
;
571 /* {set, get}context() needed for 64-bit SparcLinux userland. */
572 void sparc64_set_context(CPUSPARCState
*env
)
575 struct target_ucontext
*ucp
;
576 target_mc_gregset_t
*grp
;
577 target_mc_fpu_t
*fpup
;
578 abi_ulong pc
, npc
, tstate
;
582 ucp_addr
= env
->regwptr
[WREG_O0
];
583 if (!lock_user_struct(VERIFY_READ
, ucp
, ucp_addr
, 1)) {
586 grp
= &ucp
->tuc_mcontext
.mc_gregs
;
587 __get_user(pc
, &((*grp
)[SPARC_MC_PC
]));
588 __get_user(npc
, &((*grp
)[SPARC_MC_NPC
]));
589 if ((pc
| npc
) & 3) {
592 if (env
->regwptr
[WREG_O1
]) {
593 target_sigset_t target_set
;
596 if (TARGET_NSIG_WORDS
== 1) {
597 __get_user(target_set
.sig
[0], &ucp
->tuc_sigmask
.sig
[0]);
599 abi_ulong
*src
, *dst
;
600 src
= ucp
->tuc_sigmask
.sig
;
601 dst
= target_set
.sig
;
602 for (i
= 0; i
< TARGET_NSIG_WORDS
; i
++, dst
++, src
++) {
603 __get_user(*dst
, src
);
606 target_to_host_sigset_internal(&set
, &target_set
);
611 __get_user(env
->y
, &((*grp
)[SPARC_MC_Y
]));
612 __get_user(tstate
, &((*grp
)[SPARC_MC_TSTATE
]));
613 /* Honour TSTATE_ASI, TSTATE_ICC and TSTATE_XCC only */
614 env
->asi
= (tstate
>> 24) & 0xff;
615 cpu_put_ccr(env
, (tstate
>> 32) & 0xff);
616 __get_user(env
->gregs
[1], (&(*grp
)[SPARC_MC_G1
]));
617 __get_user(env
->gregs
[2], (&(*grp
)[SPARC_MC_G2
]));
618 __get_user(env
->gregs
[3], (&(*grp
)[SPARC_MC_G3
]));
619 __get_user(env
->gregs
[4], (&(*grp
)[SPARC_MC_G4
]));
620 __get_user(env
->gregs
[5], (&(*grp
)[SPARC_MC_G5
]));
621 __get_user(env
->gregs
[6], (&(*grp
)[SPARC_MC_G6
]));
622 /* Skip g7 as that's the thread register in userspace */
625 * Note that unlike the kernel, we didn't need to mess with the
626 * guest register window state to save it into a pt_regs to run
627 * the kernel. So for us the guest's O regs are still in WREG_O*
628 * (unlike the kernel which has put them in UREG_I* in a pt_regs)
629 * and the fp and i7 are still in WREG_I6 and WREG_I7 and don't
630 * need to be written back to userspace memory.
632 __get_user(env
->regwptr
[WREG_O0
], (&(*grp
)[SPARC_MC_O0
]));
633 __get_user(env
->regwptr
[WREG_O1
], (&(*grp
)[SPARC_MC_O1
]));
634 __get_user(env
->regwptr
[WREG_O2
], (&(*grp
)[SPARC_MC_O2
]));
635 __get_user(env
->regwptr
[WREG_O3
], (&(*grp
)[SPARC_MC_O3
]));
636 __get_user(env
->regwptr
[WREG_O4
], (&(*grp
)[SPARC_MC_O4
]));
637 __get_user(env
->regwptr
[WREG_O5
], (&(*grp
)[SPARC_MC_O5
]));
638 __get_user(env
->regwptr
[WREG_O6
], (&(*grp
)[SPARC_MC_O6
]));
639 __get_user(env
->regwptr
[WREG_O7
], (&(*grp
)[SPARC_MC_O7
]));
641 __get_user(env
->regwptr
[WREG_FP
], &(ucp
->tuc_mcontext
.mc_fp
));
642 __get_user(env
->regwptr
[WREG_I7
], &(ucp
->tuc_mcontext
.mc_i7
));
644 fpup
= &ucp
->tuc_mcontext
.mc_fpregs
;
646 __get_user(fenab
, &(fpup
->mcfpu_enab
));
651 * We use the FPRS from the guest only in deciding whether
652 * to restore the upper, lower, or both banks of the FPU regs.
653 * The kernel here writes the FPU register data into the
654 * process's current_thread_info state and unconditionally
655 * clears FPRS and TSTATE_PEF: this disables the FPU so that the
656 * next FPU-disabled trap will copy the data out of
657 * current_thread_info and into the real FPU registers.
658 * QEMU doesn't need to handle lazy-FPU-state-restoring like that,
659 * so we always load the data directly into the FPU registers
660 * and leave FPRS and TSTATE_PEF alone (so the FPU stays enabled).
661 * Note that because we (and the kernel) always write zeroes for
662 * the fenab and fprs in sparc64_get_context() none of this code
663 * will execute unless the guest manually constructed or changed
664 * the context structure.
666 __get_user(fprs
, &(fpup
->mcfpu_fprs
));
667 if (fprs
& FPRS_DL
) {
668 for (i
= 0; i
< 16; i
++) {
669 __get_user(env
->fpr
[i
].ll
, &(fpup
->mcfpu_fregs
.dregs
[i
]));
672 if (fprs
& FPRS_DU
) {
673 for (i
= 16; i
< 32; i
++) {
674 __get_user(env
->fpr
[i
].ll
, &(fpup
->mcfpu_fregs
.dregs
[i
]));
677 __get_user(env
->fsr
, &(fpup
->mcfpu_fsr
));
678 __get_user(env
->gsr
, &(fpup
->mcfpu_gsr
));
680 unlock_user_struct(ucp
, ucp_addr
, 0);
683 unlock_user_struct(ucp
, ucp_addr
, 0);
684 force_sig(TARGET_SIGSEGV
);
687 void sparc64_get_context(CPUSPARCState
*env
)
690 struct target_ucontext
*ucp
;
691 target_mc_gregset_t
*grp
;
692 target_mcontext_t
*mcp
;
695 target_sigset_t target_set
;
698 ucp_addr
= env
->regwptr
[WREG_O0
];
699 if (!lock_user_struct(VERIFY_WRITE
, ucp
, ucp_addr
, 0)) {
703 memset(ucp
, 0, sizeof(*ucp
));
705 mcp
= &ucp
->tuc_mcontext
;
706 grp
= &mcp
->mc_gregs
;
708 /* Skip over the trap instruction, first. */
712 /* If we're only reading the signal mask then do_sigprocmask()
713 * is guaranteed not to fail, which is important because we don't
714 * have any way to signal a failure or restart this operation since
715 * this is not a normal syscall.
717 err
= do_sigprocmask(0, NULL
, &set
);
719 host_to_target_sigset_internal(&target_set
, &set
);
720 if (TARGET_NSIG_WORDS
== 1) {
721 __put_user(target_set
.sig
[0],
722 (abi_ulong
*)&ucp
->tuc_sigmask
);
724 abi_ulong
*src
, *dst
;
725 src
= target_set
.sig
;
726 dst
= ucp
->tuc_sigmask
.sig
;
727 for (i
= 0; i
< TARGET_NSIG_WORDS
; i
++, dst
++, src
++) {
728 __put_user(*src
, dst
);
732 __put_user(sparc64_tstate(env
), &((*grp
)[SPARC_MC_TSTATE
]));
733 __put_user(env
->pc
, &((*grp
)[SPARC_MC_PC
]));
734 __put_user(env
->npc
, &((*grp
)[SPARC_MC_NPC
]));
735 __put_user(env
->y
, &((*grp
)[SPARC_MC_Y
]));
736 __put_user(env
->gregs
[1], &((*grp
)[SPARC_MC_G1
]));
737 __put_user(env
->gregs
[2], &((*grp
)[SPARC_MC_G2
]));
738 __put_user(env
->gregs
[3], &((*grp
)[SPARC_MC_G3
]));
739 __put_user(env
->gregs
[4], &((*grp
)[SPARC_MC_G4
]));
740 __put_user(env
->gregs
[5], &((*grp
)[SPARC_MC_G5
]));
741 __put_user(env
->gregs
[6], &((*grp
)[SPARC_MC_G6
]));
742 __put_user(env
->gregs
[7], &((*grp
)[SPARC_MC_G7
]));
745 * Note that unlike the kernel, we didn't need to mess with the
746 * guest register window state to save it into a pt_regs to run
747 * the kernel. So for us the guest's O regs are still in WREG_O*
748 * (unlike the kernel which has put them in UREG_I* in a pt_regs)
749 * and the fp and i7 are still in WREG_I6 and WREG_I7 and don't
750 * need to be fished out of userspace memory.
752 __put_user(env
->regwptr
[WREG_O0
], &((*grp
)[SPARC_MC_O0
]));
753 __put_user(env
->regwptr
[WREG_O1
], &((*grp
)[SPARC_MC_O1
]));
754 __put_user(env
->regwptr
[WREG_O2
], &((*grp
)[SPARC_MC_O2
]));
755 __put_user(env
->regwptr
[WREG_O3
], &((*grp
)[SPARC_MC_O3
]));
756 __put_user(env
->regwptr
[WREG_O4
], &((*grp
)[SPARC_MC_O4
]));
757 __put_user(env
->regwptr
[WREG_O5
], &((*grp
)[SPARC_MC_O5
]));
758 __put_user(env
->regwptr
[WREG_O6
], &((*grp
)[SPARC_MC_O6
]));
759 __put_user(env
->regwptr
[WREG_O7
], &((*grp
)[SPARC_MC_O7
]));
761 __put_user(env
->regwptr
[WREG_FP
], &(mcp
->mc_fp
));
762 __put_user(env
->regwptr
[WREG_I7
], &(mcp
->mc_i7
));
765 * We don't write out the FPU state. This matches the kernel's
766 * implementation (which has the code for doing this but
767 * hidden behind an "if (fenab)" where fenab is always 0).
770 unlock_user_struct(ucp
, ucp_addr
, 1);
773 unlock_user_struct(ucp
, ucp_addr
, 1);
774 force_sig(TARGET_SIGSEGV
);
777 void setup_sigtramp(abi_ulong sigtramp_page
)
779 uint32_t *tramp
= lock_user(VERIFY_WRITE
, sigtramp_page
, 2 * 8, 0);
780 assert(tramp
!= NULL
);
782 default_sigreturn
= sigtramp_page
;
783 install_sigtramp(tramp
, TARGET_NR_sigreturn
);
785 default_rt_sigreturn
= sigtramp_page
+ 8;
786 install_sigtramp(tramp
+ 2, TARGET_NR_rt_sigreturn
);
788 unlock_user(tramp
, sigtramp_page
, 2 * 8);