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 "signal-common.h"
22 #include "linux-user/trace.h"
24 /* A Sparc register window */
25 struct target_reg_window
{
30 /* A Sparc stack frame. */
31 struct target_stackf
{
33 * Since qemu does not reference fp or callers_pc directly,
34 * it's simpler to treat fp and callers_pc as elements of ins[],
35 * and then bundle locals[] and ins[] into reg_window.
37 struct target_reg_window win
;
39 * Similarly, bundle structptr and xxargs into xargs[].
40 * This portion of the struct is part of the function call abi,
41 * and belongs to the callee for spilling argument registers.
46 struct target_siginfo_fpu
{
48 uint64_t si_double_regs
[32];
53 /* It is more convenient for qemu to move doubles, not singles. */
54 uint64_t si_double_regs
[16];
64 #ifdef TARGET_ARCH_HAS_SETUP_FRAME
65 struct target_signal_frame
{
66 struct target_stackf ss
;
67 struct target_pt_regs regs
;
70 uint32_t insns
[2] QEMU_ALIGNED(8);
71 abi_ulong extramask
[TARGET_NSIG_WORDS
- 1];
72 abi_ulong extra_size
; /* Should be 0 */
77 struct target_rt_signal_frame
{
78 struct target_stackf ss
;
79 target_siginfo_t info
;
80 struct target_pt_regs regs
;
81 #if defined(TARGET_SPARC64) && !defined(TARGET_ABI32)
90 abi_ulong extra_size
; /* Should be 0 */
95 static abi_ulong
get_sigframe(struct target_sigaction
*sa
,
99 abi_ulong sp
= get_sp_from_cpustate(env
);
102 * If we are on the alternate signal stack and would overflow it, don't.
103 * Return an always-bogus address instead so we will die with SIGSEGV.
105 if (on_sig_stack(sp
) && !likely(on_sig_stack(sp
- framesize
))) {
109 /* This is the X/Open sanctioned signal stack switching. */
110 sp
= target_sigsp(sp
, sa
) - framesize
;
113 * Always align the stack frame. This handles two cases. First,
114 * sigaltstack need not be mindful of platform specific stack
115 * alignment. Second, if we took this signal because the stack
116 * is not aligned properly, we'd like to take the signal cleanly
124 static void save_pt_regs(struct target_pt_regs
*regs
, CPUSPARCState
*env
)
128 #if defined(TARGET_SPARC64) && !defined(TARGET_ABI32)
129 __put_user(sparc64_tstate(env
), ®s
->tstate
);
130 /* TODO: magic should contain PT_REG_MAGIC + %tt. */
131 __put_user(0, ®s
->magic
);
133 __put_user(cpu_get_psr(env
), ®s
->psr
);
136 __put_user(env
->pc
, ®s
->pc
);
137 __put_user(env
->npc
, ®s
->npc
);
138 __put_user(env
->y
, ®s
->y
);
140 for (i
= 0; i
< 8; i
++) {
141 __put_user(env
->gregs
[i
], ®s
->u_regs
[i
]);
143 for (i
= 0; i
< 8; i
++) {
144 __put_user(env
->regwptr
[WREG_O0
+ i
], ®s
->u_regs
[i
+ 8]);
148 static void restore_pt_regs(struct target_pt_regs
*regs
, CPUSPARCState
*env
)
152 #if defined(TARGET_SPARC64) && !defined(TARGET_ABI32)
153 /* User can only change condition codes and %asi in %tstate. */
155 __get_user(tstate
, ®s
->tstate
);
156 cpu_put_ccr(env
, tstate
>> 32);
157 env
->asi
= extract64(tstate
, 24, 8);
160 * User can only change condition codes and FPU enabling in %psr.
161 * But don't bother with FPU enabling, since a real kernel would
162 * just re-enable the FPU upon the next fpu trap.
165 __get_user(psr
, ®s
->psr
);
166 env
->psr
= (psr
& PSR_ICC
) | (env
->psr
& ~PSR_ICC
);
169 /* Note that pc and npc are handled in the caller. */
171 __get_user(env
->y
, ®s
->y
);
173 for (i
= 0; i
< 8; i
++) {
174 __get_user(env
->gregs
[i
], ®s
->u_regs
[i
]);
176 for (i
= 0; i
< 8; i
++) {
177 __get_user(env
->regwptr
[WREG_O0
+ i
], ®s
->u_regs
[i
+ 8]);
181 static void save_reg_win(struct target_reg_window
*win
, CPUSPARCState
*env
)
185 for (i
= 0; i
< 8; i
++) {
186 __put_user(env
->regwptr
[i
+ WREG_L0
], &win
->locals
[i
]);
188 for (i
= 0; i
< 8; i
++) {
189 __put_user(env
->regwptr
[i
+ WREG_I0
], &win
->ins
[i
]);
193 static void save_fpu(struct target_siginfo_fpu
*fpu
, CPUSPARCState
*env
)
197 #ifdef TARGET_SPARC64
198 for (i
= 0; i
< 32; ++i
) {
199 __put_user(env
->fpr
[i
].ll
, &fpu
->si_double_regs
[i
]);
201 __put_user(env
->fsr
, &fpu
->si_fsr
);
202 __put_user(env
->gsr
, &fpu
->si_gsr
);
203 __put_user(env
->fprs
, &fpu
->si_fprs
);
205 for (i
= 0; i
< 16; ++i
) {
206 __put_user(env
->fpr
[i
].ll
, &fpu
->si_double_regs
[i
]);
208 __put_user(env
->fsr
, &fpu
->si_fsr
);
209 __put_user(0, &fpu
->si_fpqdepth
);
213 static void restore_fpu(struct target_siginfo_fpu
*fpu
, CPUSPARCState
*env
)
217 #ifdef TARGET_SPARC64
219 __get_user(fprs
, &fpu
->si_fprs
);
221 /* In case the user mucks about with FPRS, restore as directed. */
222 if (fprs
& FPRS_DL
) {
223 for (i
= 0; i
< 16; ++i
) {
224 __get_user(env
->fpr
[i
].ll
, &fpu
->si_double_regs
[i
]);
227 if (fprs
& FPRS_DU
) {
228 for (i
= 16; i
< 32; ++i
) {
229 __get_user(env
->fpr
[i
].ll
, &fpu
->si_double_regs
[i
]);
232 __get_user(env
->fsr
, &fpu
->si_fsr
);
233 __get_user(env
->gsr
, &fpu
->si_gsr
);
236 for (i
= 0; i
< 16; ++i
) {
237 __get_user(env
->fpr
[i
].ll
, &fpu
->si_double_regs
[i
]);
239 __get_user(env
->fsr
, &fpu
->si_fsr
);
243 #ifdef TARGET_ARCH_HAS_SETUP_FRAME
244 void setup_frame(int sig
, struct target_sigaction
*ka
,
245 target_sigset_t
*set
, CPUSPARCState
*env
)
248 struct target_signal_frame
*sf
;
249 size_t sf_size
= sizeof(*sf
) + sizeof(struct target_siginfo_fpu
);
252 sf_addr
= get_sigframe(ka
, env
, sf_size
);
253 trace_user_setup_frame(env
, sf_addr
);
255 sf
= lock_user(VERIFY_WRITE
, sf_addr
, sf_size
, 0);
261 /* 2. Save the current process state */
262 save_pt_regs(&sf
->regs
, env
);
263 __put_user(0, &sf
->extra_size
);
265 save_fpu((struct target_siginfo_fpu
*)(sf
+ 1), env
);
266 __put_user(sf_addr
+ sizeof(*sf
), &sf
->fpu_save
);
268 __put_user(0, &sf
->rwin_save
); /* TODO: save_rwin_state */
270 __put_user(set
->sig
[0], &sf
->si_mask
);
271 for (i
= 0; i
< TARGET_NSIG_WORDS
- 1; i
++) {
272 __put_user(set
->sig
[i
+ 1], &sf
->extramask
[i
]);
275 save_reg_win(&sf
->ss
.win
, env
);
277 /* 3. signal handler back-trampoline and parameters */
278 env
->regwptr
[WREG_SP
] = sf_addr
;
279 env
->regwptr
[WREG_O0
] = sig
;
280 env
->regwptr
[WREG_O1
] = sf_addr
+
281 offsetof(struct target_signal_frame
, regs
);
282 env
->regwptr
[WREG_O2
] = sf_addr
+
283 offsetof(struct target_signal_frame
, regs
);
285 /* 4. signal handler */
286 env
->pc
= ka
->_sa_handler
;
287 env
->npc
= env
->pc
+ 4;
289 /* 5. return to kernel instructions */
290 if (ka
->ka_restorer
) {
291 env
->regwptr
[WREG_O7
] = ka
->ka_restorer
;
293 env
->regwptr
[WREG_O7
] = sf_addr
+
294 offsetof(struct target_signal_frame
, insns
) - 2 * 4;
296 /* mov __NR_sigreturn, %g1 */
297 __put_user(0x821020d8u
, &sf
->insns
[0]);
299 __put_user(0x91d02010u
, &sf
->insns
[1]);
301 unlock_user(sf
, sf_addr
, sf_size
);
303 #endif /* TARGET_ARCH_HAS_SETUP_FRAME */
305 void setup_rt_frame(int sig
, struct target_sigaction
*ka
,
306 target_siginfo_t
*info
,
307 target_sigset_t
*set
, CPUSPARCState
*env
)
310 struct target_rt_signal_frame
*sf
;
311 size_t sf_size
= sizeof(*sf
) + sizeof(struct target_siginfo_fpu
);
313 sf_addr
= get_sigframe(ka
, env
, sf_size
);
314 trace_user_setup_rt_frame(env
, sf_addr
);
316 sf
= lock_user(VERIFY_WRITE
, sf_addr
, sf_size
, 0);
322 /* 2. Save the current process state */
323 save_reg_win(&sf
->ss
.win
, env
);
324 save_pt_regs(&sf
->regs
, env
);
326 save_fpu((struct target_siginfo_fpu
*)(sf
+ 1), env
);
327 __put_user(sf_addr
+ sizeof(*sf
), &sf
->fpu_save
);
329 __put_user(0, &sf
->rwin_save
); /* TODO: save_rwin_state */
331 tswap_siginfo(&sf
->info
, info
);
332 tswap_sigset(&sf
->mask
, set
);
333 target_save_altstack(&sf
->stack
, env
);
336 __put_user(0, &sf
->extra_size
);
339 /* 3. signal handler back-trampoline and parameters */
340 env
->regwptr
[WREG_SP
] = sf_addr
- TARGET_STACK_BIAS
;
341 env
->regwptr
[WREG_O0
] = sig
;
342 env
->regwptr
[WREG_O1
] =
343 sf_addr
+ offsetof(struct target_rt_signal_frame
, info
);
345 env
->regwptr
[WREG_O2
] =
346 sf_addr
+ offsetof(struct target_rt_signal_frame
, regs
);
348 env
->regwptr
[WREG_O2
] = env
->regwptr
[WREG_O1
];
351 /* 4. signal handler */
352 env
->pc
= ka
->_sa_handler
;
353 env
->npc
= env
->pc
+ 4;
355 /* 5. return to kernel instructions */
357 if (ka
->ka_restorer
) {
358 env
->regwptr
[WREG_O7
] = ka
->ka_restorer
;
360 env
->regwptr
[WREG_O7
] =
361 sf_addr
+ offsetof(struct target_rt_signal_frame
, insns
) - 2 * 4;
363 /* mov __NR_rt_sigreturn, %g1 */
364 __put_user(0x82102065u
, &sf
->insns
[0]);
366 __put_user(0x91d02010u
, &sf
->insns
[1]);
369 env
->regwptr
[WREG_O7
] = ka
->ka_restorer
;
372 unlock_user(sf
, sf_addr
, sf_size
);
375 long do_sigreturn(CPUSPARCState
*env
)
377 #ifdef TARGET_ARCH_HAS_SETUP_FRAME
379 struct target_signal_frame
*sf
= NULL
;
380 abi_ulong pc
, npc
, ptr
;
385 sf_addr
= env
->regwptr
[WREG_SP
];
386 trace_user_do_sigreturn(env
, sf_addr
);
388 /* 1. Make sure we are not getting garbage from the user */
389 if ((sf_addr
& 15) || !lock_user_struct(VERIFY_READ
, sf
, sf_addr
, 1)) {
393 /* Make sure stack pointer is aligned. */
394 __get_user(ptr
, &sf
->regs
.u_regs
[14]);
399 /* Make sure instruction pointers are aligned. */
400 __get_user(pc
, &sf
->regs
.pc
);
401 __get_user(npc
, &sf
->regs
.npc
);
402 if ((pc
| npc
) & 3) {
406 /* 2. Restore the state */
407 restore_pt_regs(&sf
->regs
, env
);
411 __get_user(ptr
, &sf
->fpu_save
);
413 struct target_siginfo_fpu
*fpu
;
414 if ((ptr
& 3) || !lock_user_struct(VERIFY_READ
, fpu
, ptr
, 1)) {
417 restore_fpu(fpu
, env
);
418 unlock_user_struct(fpu
, ptr
, 0);
421 __get_user(ptr
, &sf
->rwin_save
);
423 goto segv_and_exit
; /* TODO: restore_rwin */
426 __get_user(set
.sig
[0], &sf
->si_mask
);
427 for (i
= 1; i
< TARGET_NSIG_WORDS
; i
++) {
428 __get_user(set
.sig
[i
], &sf
->extramask
[i
- 1]);
431 target_to_host_sigset_internal(&host_set
, &set
);
432 set_sigmask(&host_set
);
434 unlock_user_struct(sf
, sf_addr
, 0);
435 return -TARGET_QEMU_ESIGRETURN
;
438 unlock_user_struct(sf
, sf_addr
, 0);
439 force_sig(TARGET_SIGSEGV
);
440 return -TARGET_QEMU_ESIGRETURN
;
442 return -TARGET_ENOSYS
;
446 long do_rt_sigreturn(CPUSPARCState
*env
)
448 abi_ulong sf_addr
, tpc
, tnpc
, ptr
;
449 struct target_rt_signal_frame
*sf
= NULL
;
452 sf_addr
= get_sp_from_cpustate(env
);
453 trace_user_do_rt_sigreturn(env
, sf_addr
);
455 /* 1. Make sure we are not getting garbage from the user */
456 if ((sf_addr
& 15) || !lock_user_struct(VERIFY_READ
, sf
, sf_addr
, 1)) {
460 /* Validate SP alignment. */
461 __get_user(ptr
, &sf
->regs
.u_regs
[8 + WREG_SP
]);
462 if ((ptr
+ TARGET_STACK_BIAS
) & 7) {
466 /* Validate PC and NPC alignment. */
467 __get_user(tpc
, &sf
->regs
.pc
);
468 __get_user(tnpc
, &sf
->regs
.npc
);
469 if ((tpc
| tnpc
) & 3) {
473 /* 2. Restore the state */
474 restore_pt_regs(&sf
->regs
, env
);
476 __get_user(ptr
, &sf
->fpu_save
);
478 struct target_siginfo_fpu
*fpu
;
479 if ((ptr
& 7) || !lock_user_struct(VERIFY_READ
, fpu
, ptr
, 1)) {
482 restore_fpu(fpu
, env
);
483 unlock_user_struct(fpu
, ptr
, 0);
486 __get_user(ptr
, &sf
->rwin_save
);
488 goto segv_and_exit
; /* TODO: restore_rwin_state */
491 target_restore_altstack(&sf
->stack
, env
);
492 target_to_host_sigset(&set
, &sf
->mask
);
498 unlock_user_struct(sf
, sf_addr
, 0);
499 return -TARGET_QEMU_ESIGRETURN
;
502 unlock_user_struct(sf
, sf_addr
, 0);
503 force_sig(TARGET_SIGSEGV
);
504 return -TARGET_QEMU_ESIGRETURN
;
507 #if defined(TARGET_SPARC64) && !defined(TARGET_ABI32)
508 #define SPARC_MC_TSTATE 0
509 #define SPARC_MC_PC 1
510 #define SPARC_MC_NPC 2
512 #define SPARC_MC_G1 4
513 #define SPARC_MC_G2 5
514 #define SPARC_MC_G3 6
515 #define SPARC_MC_G4 7
516 #define SPARC_MC_G5 8
517 #define SPARC_MC_G6 9
518 #define SPARC_MC_G7 10
519 #define SPARC_MC_O0 11
520 #define SPARC_MC_O1 12
521 #define SPARC_MC_O2 13
522 #define SPARC_MC_O3 14
523 #define SPARC_MC_O4 15
524 #define SPARC_MC_O5 16
525 #define SPARC_MC_O6 17
526 #define SPARC_MC_O7 18
527 #define SPARC_MC_NGREG 19
529 typedef abi_ulong target_mc_greg_t
;
530 typedef target_mc_greg_t target_mc_gregset_t
[SPARC_MC_NGREG
];
532 struct target_mc_fq
{
538 * Note the manual 16-alignment; the kernel gets this because it
539 * includes a "long double qregs[16]" in the mcpu_fregs union,
542 struct target_mc_fpu
{
546 //uint128_t qregs[16];
549 abi_ulong mcfpu_fprs
;
552 unsigned char mcfpu_qcnt
;
553 unsigned char mcfpu_qentsz
;
554 unsigned char mcfpu_enab
;
555 } __attribute__((aligned(16)));
556 typedef struct target_mc_fpu target_mc_fpu_t
;
559 target_mc_gregset_t mc_gregs
;
560 target_mc_greg_t mc_fp
;
561 target_mc_greg_t mc_i7
;
562 target_mc_fpu_t mc_fpregs
;
565 struct target_ucontext
{
568 target_sigset_t tuc_sigmask
;
569 target_mcontext_t tuc_mcontext
;
572 /* {set, get}context() needed for 64-bit SparcLinux userland. */
573 void sparc64_set_context(CPUSPARCState
*env
)
576 struct target_ucontext
*ucp
;
577 target_mc_gregset_t
*grp
;
578 target_mc_fpu_t
*fpup
;
579 abi_ulong pc
, npc
, tstate
;
583 ucp_addr
= env
->regwptr
[WREG_O0
];
584 if (!lock_user_struct(VERIFY_READ
, ucp
, ucp_addr
, 1)) {
587 grp
= &ucp
->tuc_mcontext
.mc_gregs
;
588 __get_user(pc
, &((*grp
)[SPARC_MC_PC
]));
589 __get_user(npc
, &((*grp
)[SPARC_MC_NPC
]));
590 if ((pc
| npc
) & 3) {
593 if (env
->regwptr
[WREG_O1
]) {
594 target_sigset_t target_set
;
597 if (TARGET_NSIG_WORDS
== 1) {
598 __get_user(target_set
.sig
[0], &ucp
->tuc_sigmask
.sig
[0]);
600 abi_ulong
*src
, *dst
;
601 src
= ucp
->tuc_sigmask
.sig
;
602 dst
= target_set
.sig
;
603 for (i
= 0; i
< TARGET_NSIG_WORDS
; i
++, dst
++, src
++) {
604 __get_user(*dst
, src
);
607 target_to_host_sigset_internal(&set
, &target_set
);
612 __get_user(env
->y
, &((*grp
)[SPARC_MC_Y
]));
613 __get_user(tstate
, &((*grp
)[SPARC_MC_TSTATE
]));
614 /* Honour TSTATE_ASI, TSTATE_ICC and TSTATE_XCC only */
615 env
->asi
= (tstate
>> 24) & 0xff;
616 cpu_put_ccr(env
, (tstate
>> 32) & 0xff);
617 __get_user(env
->gregs
[1], (&(*grp
)[SPARC_MC_G1
]));
618 __get_user(env
->gregs
[2], (&(*grp
)[SPARC_MC_G2
]));
619 __get_user(env
->gregs
[3], (&(*grp
)[SPARC_MC_G3
]));
620 __get_user(env
->gregs
[4], (&(*grp
)[SPARC_MC_G4
]));
621 __get_user(env
->gregs
[5], (&(*grp
)[SPARC_MC_G5
]));
622 __get_user(env
->gregs
[6], (&(*grp
)[SPARC_MC_G6
]));
623 /* Skip g7 as that's the thread register in userspace */
626 * Note that unlike the kernel, we didn't need to mess with the
627 * guest register window state to save it into a pt_regs to run
628 * the kernel. So for us the guest's O regs are still in WREG_O*
629 * (unlike the kernel which has put them in UREG_I* in a pt_regs)
630 * and the fp and i7 are still in WREG_I6 and WREG_I7 and don't
631 * need to be written back to userspace memory.
633 __get_user(env
->regwptr
[WREG_O0
], (&(*grp
)[SPARC_MC_O0
]));
634 __get_user(env
->regwptr
[WREG_O1
], (&(*grp
)[SPARC_MC_O1
]));
635 __get_user(env
->regwptr
[WREG_O2
], (&(*grp
)[SPARC_MC_O2
]));
636 __get_user(env
->regwptr
[WREG_O3
], (&(*grp
)[SPARC_MC_O3
]));
637 __get_user(env
->regwptr
[WREG_O4
], (&(*grp
)[SPARC_MC_O4
]));
638 __get_user(env
->regwptr
[WREG_O5
], (&(*grp
)[SPARC_MC_O5
]));
639 __get_user(env
->regwptr
[WREG_O6
], (&(*grp
)[SPARC_MC_O6
]));
640 __get_user(env
->regwptr
[WREG_O7
], (&(*grp
)[SPARC_MC_O7
]));
642 __get_user(env
->regwptr
[WREG_FP
], &(ucp
->tuc_mcontext
.mc_fp
));
643 __get_user(env
->regwptr
[WREG_I7
], &(ucp
->tuc_mcontext
.mc_i7
));
645 fpup
= &ucp
->tuc_mcontext
.mc_fpregs
;
647 __get_user(fenab
, &(fpup
->mcfpu_enab
));
652 * We use the FPRS from the guest only in deciding whether
653 * to restore the upper, lower, or both banks of the FPU regs.
654 * The kernel here writes the FPU register data into the
655 * process's current_thread_info state and unconditionally
656 * clears FPRS and TSTATE_PEF: this disables the FPU so that the
657 * next FPU-disabled trap will copy the data out of
658 * current_thread_info and into the real FPU registers.
659 * QEMU doesn't need to handle lazy-FPU-state-restoring like that,
660 * so we always load the data directly into the FPU registers
661 * and leave FPRS and TSTATE_PEF alone (so the FPU stays enabled).
662 * Note that because we (and the kernel) always write zeroes for
663 * the fenab and fprs in sparc64_get_context() none of this code
664 * will execute unless the guest manually constructed or changed
665 * the context structure.
667 __get_user(fprs
, &(fpup
->mcfpu_fprs
));
668 if (fprs
& FPRS_DL
) {
669 for (i
= 0; i
< 16; i
++) {
670 __get_user(env
->fpr
[i
].ll
, &(fpup
->mcfpu_fregs
.dregs
[i
]));
673 if (fprs
& FPRS_DU
) {
674 for (i
= 16; i
< 32; i
++) {
675 __get_user(env
->fpr
[i
].ll
, &(fpup
->mcfpu_fregs
.dregs
[i
]));
678 __get_user(env
->fsr
, &(fpup
->mcfpu_fsr
));
679 __get_user(env
->gsr
, &(fpup
->mcfpu_gsr
));
681 unlock_user_struct(ucp
, ucp_addr
, 0);
684 unlock_user_struct(ucp
, ucp_addr
, 0);
685 force_sig(TARGET_SIGSEGV
);
688 void sparc64_get_context(CPUSPARCState
*env
)
691 struct target_ucontext
*ucp
;
692 target_mc_gregset_t
*grp
;
693 target_mcontext_t
*mcp
;
696 target_sigset_t target_set
;
699 ucp_addr
= env
->regwptr
[WREG_O0
];
700 if (!lock_user_struct(VERIFY_WRITE
, ucp
, ucp_addr
, 0)) {
704 memset(ucp
, 0, sizeof(*ucp
));
706 mcp
= &ucp
->tuc_mcontext
;
707 grp
= &mcp
->mc_gregs
;
709 /* Skip over the trap instruction, first. */
713 /* If we're only reading the signal mask then do_sigprocmask()
714 * is guaranteed not to fail, which is important because we don't
715 * have any way to signal a failure or restart this operation since
716 * this is not a normal syscall.
718 err
= do_sigprocmask(0, NULL
, &set
);
720 host_to_target_sigset_internal(&target_set
, &set
);
721 if (TARGET_NSIG_WORDS
== 1) {
722 __put_user(target_set
.sig
[0],
723 (abi_ulong
*)&ucp
->tuc_sigmask
);
725 abi_ulong
*src
, *dst
;
726 src
= target_set
.sig
;
727 dst
= ucp
->tuc_sigmask
.sig
;
728 for (i
= 0; i
< TARGET_NSIG_WORDS
; i
++, dst
++, src
++) {
729 __put_user(*src
, dst
);
733 __put_user(sparc64_tstate(env
), &((*grp
)[SPARC_MC_TSTATE
]));
734 __put_user(env
->pc
, &((*grp
)[SPARC_MC_PC
]));
735 __put_user(env
->npc
, &((*grp
)[SPARC_MC_NPC
]));
736 __put_user(env
->y
, &((*grp
)[SPARC_MC_Y
]));
737 __put_user(env
->gregs
[1], &((*grp
)[SPARC_MC_G1
]));
738 __put_user(env
->gregs
[2], &((*grp
)[SPARC_MC_G2
]));
739 __put_user(env
->gregs
[3], &((*grp
)[SPARC_MC_G3
]));
740 __put_user(env
->gregs
[4], &((*grp
)[SPARC_MC_G4
]));
741 __put_user(env
->gregs
[5], &((*grp
)[SPARC_MC_G5
]));
742 __put_user(env
->gregs
[6], &((*grp
)[SPARC_MC_G6
]));
743 __put_user(env
->gregs
[7], &((*grp
)[SPARC_MC_G7
]));
746 * Note that unlike the kernel, we didn't need to mess with the
747 * guest register window state to save it into a pt_regs to run
748 * the kernel. So for us the guest's O regs are still in WREG_O*
749 * (unlike the kernel which has put them in UREG_I* in a pt_regs)
750 * and the fp and i7 are still in WREG_I6 and WREG_I7 and don't
751 * need to be fished out of userspace memory.
753 __put_user(env
->regwptr
[WREG_O0
], &((*grp
)[SPARC_MC_O0
]));
754 __put_user(env
->regwptr
[WREG_O1
], &((*grp
)[SPARC_MC_O1
]));
755 __put_user(env
->regwptr
[WREG_O2
], &((*grp
)[SPARC_MC_O2
]));
756 __put_user(env
->regwptr
[WREG_O3
], &((*grp
)[SPARC_MC_O3
]));
757 __put_user(env
->regwptr
[WREG_O4
], &((*grp
)[SPARC_MC_O4
]));
758 __put_user(env
->regwptr
[WREG_O5
], &((*grp
)[SPARC_MC_O5
]));
759 __put_user(env
->regwptr
[WREG_O6
], &((*grp
)[SPARC_MC_O6
]));
760 __put_user(env
->regwptr
[WREG_O7
], &((*grp
)[SPARC_MC_O7
]));
762 __put_user(env
->regwptr
[WREG_FP
], &(mcp
->mc_fp
));
763 __put_user(env
->regwptr
[WREG_I7
], &(mcp
->mc_i7
));
766 * We don't write out the FPU state. This matches the kernel's
767 * implementation (which has the code for doing this but
768 * hidden behind an "if (fenab)" where fenab is always 0).
771 unlock_user_struct(ucp
, ucp_addr
, 1);
774 unlock_user_struct(ucp
, ucp_addr
, 1);
775 force_sig(TARGET_SIGSEGV
);