1 /* 2 * Emulation of Linux signals 3 * 4 * Copyright (c) 2003 Fabrice Bellard 5 * 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. 10 * 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. 15 * 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/>. 18 */ 19 #include "qemu/osdep.h" 20 #include "qemu.h" 21 #include "signal-common.h" 22 #include "linux-user/trace.h" 23 24 #define __SUNOS_MAXWIN 31 25 26 /* This is what SunOS does, so shall I. */ 27 struct target_sigcontext { 28 abi_ulong sigc_onstack; /* state to restore */ 29 30 abi_ulong sigc_mask; /* sigmask to restore */ 31 abi_ulong sigc_sp; /* stack pointer */ 32 abi_ulong sigc_pc; /* program counter */ 33 abi_ulong sigc_npc; /* next program counter */ 34 abi_ulong sigc_psr; /* for condition codes etc */ 35 abi_ulong sigc_g1; /* User uses these two registers */ 36 abi_ulong sigc_o0; /* within the trampoline code. */ 37 38 /* Now comes information regarding the users window set 39 * at the time of the signal. 40 */ 41 abi_ulong sigc_oswins; /* outstanding windows */ 42 43 /* stack ptrs for each regwin buf */ 44 char *sigc_spbuf[__SUNOS_MAXWIN]; 45 46 /* Windows to restore after signal */ 47 struct { 48 abi_ulong locals[8]; 49 abi_ulong ins[8]; 50 } sigc_wbuf[__SUNOS_MAXWIN]; 51 }; 52 /* A Sparc stack frame */ 53 struct sparc_stackf { 54 abi_ulong locals[8]; 55 abi_ulong ins[8]; 56 /* It's simpler to treat fp and callers_pc as elements of ins[] 57 * since we never need to access them ourselves. 58 */ 59 char *structptr; 60 abi_ulong xargs[6]; 61 abi_ulong xxargs[1]; 62 }; 63 64 typedef struct { 65 struct { 66 abi_ulong psr; 67 abi_ulong pc; 68 abi_ulong npc; 69 abi_ulong y; 70 abi_ulong u_regs[16]; /* globals and ins */ 71 } si_regs; 72 int si_mask; 73 } __siginfo_t; 74 75 typedef struct { 76 abi_ulong si_float_regs[32]; 77 unsigned long si_fsr; 78 unsigned long si_fpqdepth; 79 struct { 80 unsigned long *insn_addr; 81 unsigned long insn; 82 } si_fpqueue [16]; 83 } qemu_siginfo_fpu_t; 84 85 86 struct target_signal_frame { 87 struct sparc_stackf ss; 88 __siginfo_t info; 89 abi_ulong fpu_save; 90 abi_ulong insns[2] __attribute__ ((aligned (8))); 91 abi_ulong extramask[TARGET_NSIG_WORDS - 1]; 92 abi_ulong extra_size; /* Should be 0 */ 93 qemu_siginfo_fpu_t fpu_state; 94 }; 95 struct target_rt_signal_frame { 96 struct sparc_stackf ss; 97 siginfo_t info; 98 abi_ulong regs[20]; 99 sigset_t mask; 100 abi_ulong fpu_save; 101 unsigned int insns[2]; 102 stack_t stack; 103 unsigned int extra_size; /* Should be 0 */ 104 qemu_siginfo_fpu_t fpu_state; 105 }; 106 107 #define UREG_O0 16 108 #define UREG_O6 22 109 #define UREG_I0 0 110 #define UREG_I1 1 111 #define UREG_I2 2 112 #define UREG_I3 3 113 #define UREG_I4 4 114 #define UREG_I5 5 115 #define UREG_I6 6 116 #define UREG_I7 7 117 #define UREG_L0 8 118 #define UREG_FP UREG_I6 119 #define UREG_SP UREG_O6 120 121 static inline abi_ulong get_sigframe(struct target_sigaction *sa, 122 CPUSPARCState *env, 123 unsigned long framesize) 124 { 125 abi_ulong sp = get_sp_from_cpustate(env); 126 127 /* 128 * If we are on the alternate signal stack and would overflow it, don't. 129 * Return an always-bogus address instead so we will die with SIGSEGV. 130 */ 131 if (on_sig_stack(sp) && !likely(on_sig_stack(sp - framesize))) { 132 return -1; 133 } 134 135 /* This is the X/Open sanctioned signal stack switching. */ 136 sp = target_sigsp(sp, sa) - framesize; 137 138 /* Always align the stack frame. This handles two cases. First, 139 * sigaltstack need not be mindful of platform specific stack 140 * alignment. Second, if we took this signal because the stack 141 * is not aligned properly, we'd like to take the signal cleanly 142 * and report that. 143 */ 144 sp &= ~15UL; 145 146 return sp; 147 } 148 149 static int 150 setup___siginfo(__siginfo_t *si, CPUSPARCState *env, abi_ulong mask) 151 { 152 int err = 0, i; 153 154 __put_user(env->psr, &si->si_regs.psr); 155 __put_user(env->pc, &si->si_regs.pc); 156 __put_user(env->npc, &si->si_regs.npc); 157 __put_user(env->y, &si->si_regs.y); 158 for (i=0; i < 8; i++) { 159 __put_user(env->gregs[i], &si->si_regs.u_regs[i]); 160 } 161 for (i=0; i < 8; i++) { 162 __put_user(env->regwptr[UREG_I0 + i], &si->si_regs.u_regs[i+8]); 163 } 164 __put_user(mask, &si->si_mask); 165 return err; 166 } 167 168 #if 0 169 static int 170 setup_sigcontext(struct target_sigcontext *sc, /*struct _fpstate *fpstate,*/ 171 CPUSPARCState *env, unsigned long mask) 172 { 173 int err = 0; 174 175 __put_user(mask, &sc->sigc_mask); 176 __put_user(env->regwptr[UREG_SP], &sc->sigc_sp); 177 __put_user(env->pc, &sc->sigc_pc); 178 __put_user(env->npc, &sc->sigc_npc); 179 __put_user(env->psr, &sc->sigc_psr); 180 __put_user(env->gregs[1], &sc->sigc_g1); 181 __put_user(env->regwptr[UREG_O0], &sc->sigc_o0); 182 183 return err; 184 } 185 #endif 186 #define NF_ALIGNEDSZ (((sizeof(struct target_signal_frame) + 7) & (~7))) 187 188 void setup_frame(int sig, struct target_sigaction *ka, 189 target_sigset_t *set, CPUSPARCState *env) 190 { 191 abi_ulong sf_addr; 192 struct target_signal_frame *sf; 193 int sigframe_size, err, i; 194 195 /* 1. Make sure everything is clean */ 196 //synchronize_user_stack(); 197 198 sigframe_size = NF_ALIGNEDSZ; 199 sf_addr = get_sigframe(ka, env, sigframe_size); 200 trace_user_setup_frame(env, sf_addr); 201 202 sf = lock_user(VERIFY_WRITE, sf_addr, 203 sizeof(struct target_signal_frame), 0); 204 if (!sf) { 205 goto sigsegv; 206 } 207 #if 0 208 if (invalid_frame_pointer(sf, sigframe_size)) 209 goto sigill_and_return; 210 #endif 211 /* 2. Save the current process state */ 212 err = setup___siginfo(&sf->info, env, set->sig[0]); 213 __put_user(0, &sf->extra_size); 214 215 //save_fpu_state(regs, &sf->fpu_state); 216 //__put_user(&sf->fpu_state, &sf->fpu_save); 217 218 __put_user(set->sig[0], &sf->info.si_mask); 219 for (i = 0; i < TARGET_NSIG_WORDS - 1; i++) { 220 __put_user(set->sig[i + 1], &sf->extramask[i]); 221 } 222 223 for (i = 0; i < 8; i++) { 224 __put_user(env->regwptr[i + UREG_L0], &sf->ss.locals[i]); 225 } 226 for (i = 0; i < 8; i++) { 227 __put_user(env->regwptr[i + UREG_I0], &sf->ss.ins[i]); 228 } 229 if (err) 230 goto sigsegv; 231 232 /* 3. signal handler back-trampoline and parameters */ 233 env->regwptr[UREG_FP] = sf_addr; 234 env->regwptr[UREG_I0] = sig; 235 env->regwptr[UREG_I1] = sf_addr + 236 offsetof(struct target_signal_frame, info); 237 env->regwptr[UREG_I2] = sf_addr + 238 offsetof(struct target_signal_frame, info); 239 240 /* 4. signal handler */ 241 env->pc = ka->_sa_handler; 242 env->npc = (env->pc + 4); 243 /* 5. return to kernel instructions */ 244 if (ka->ka_restorer) { 245 env->regwptr[UREG_I7] = ka->ka_restorer; 246 } else { 247 uint32_t val32; 248 249 env->regwptr[UREG_I7] = sf_addr + 250 offsetof(struct target_signal_frame, insns) - 2 * 4; 251 252 /* mov __NR_sigreturn, %g1 */ 253 val32 = 0x821020d8; 254 __put_user(val32, &sf->insns[0]); 255 256 /* t 0x10 */ 257 val32 = 0x91d02010; 258 __put_user(val32, &sf->insns[1]); 259 if (err) 260 goto sigsegv; 261 } 262 unlock_user(sf, sf_addr, sizeof(struct target_signal_frame)); 263 return; 264 #if 0 265 sigill_and_return: 266 force_sig(TARGET_SIGILL); 267 #endif 268 sigsegv: 269 unlock_user(sf, sf_addr, sizeof(struct target_signal_frame)); 270 force_sigsegv(sig); 271 } 272 273 void setup_rt_frame(int sig, struct target_sigaction *ka, 274 target_siginfo_t *info, 275 target_sigset_t *set, CPUSPARCState *env) 276 { 277 qemu_log_mask(LOG_UNIMP, "setup_rt_frame: not implemented\n"); 278 } 279 280 long do_sigreturn(CPUSPARCState *env) 281 { 282 abi_ulong sf_addr; 283 struct target_signal_frame *sf; 284 uint32_t up_psr, pc, npc; 285 target_sigset_t set; 286 sigset_t host_set; 287 int err=0, i; 288 289 sf_addr = env->regwptr[UREG_FP]; 290 trace_user_do_sigreturn(env, sf_addr); 291 if (!lock_user_struct(VERIFY_READ, sf, sf_addr, 1)) { 292 goto segv_and_exit; 293 } 294 295 /* 1. Make sure we are not getting garbage from the user */ 296 297 if (sf_addr & 3) 298 goto segv_and_exit; 299 300 __get_user(pc, &sf->info.si_regs.pc); 301 __get_user(npc, &sf->info.si_regs.npc); 302 303 if ((pc | npc) & 3) { 304 goto segv_and_exit; 305 } 306 307 /* 2. Restore the state */ 308 __get_user(up_psr, &sf->info.si_regs.psr); 309 310 /* User can only change condition codes and FPU enabling in %psr. */ 311 env->psr = (up_psr & (PSR_ICC /* | PSR_EF */)) 312 | (env->psr & ~(PSR_ICC /* | PSR_EF */)); 313 314 env->pc = pc; 315 env->npc = npc; 316 __get_user(env->y, &sf->info.si_regs.y); 317 for (i=0; i < 8; i++) { 318 __get_user(env->gregs[i], &sf->info.si_regs.u_regs[i]); 319 } 320 for (i=0; i < 8; i++) { 321 __get_user(env->regwptr[i + UREG_I0], &sf->info.si_regs.u_regs[i+8]); 322 } 323 324 /* FIXME: implement FPU save/restore: 325 * __get_user(fpu_save, &sf->fpu_save); 326 * if (fpu_save) 327 * err |= restore_fpu_state(env, fpu_save); 328 */ 329 330 /* This is pretty much atomic, no amount locking would prevent 331 * the races which exist anyways. 332 */ 333 __get_user(set.sig[0], &sf->info.si_mask); 334 for(i = 1; i < TARGET_NSIG_WORDS; i++) { 335 __get_user(set.sig[i], &sf->extramask[i - 1]); 336 } 337 338 target_to_host_sigset_internal(&host_set, &set); 339 set_sigmask(&host_set); 340 341 if (err) { 342 goto segv_and_exit; 343 } 344 unlock_user_struct(sf, sf_addr, 0); 345 return -TARGET_QEMU_ESIGRETURN; 346 347 segv_and_exit: 348 unlock_user_struct(sf, sf_addr, 0); 349 force_sig(TARGET_SIGSEGV); 350 return -TARGET_QEMU_ESIGRETURN; 351 } 352 353 long do_rt_sigreturn(CPUSPARCState *env) 354 { 355 trace_user_do_rt_sigreturn(env, 0); 356 qemu_log_mask(LOG_UNIMP, "do_rt_sigreturn: not implemented\n"); 357 return -TARGET_ENOSYS; 358 } 359 360 #if defined(TARGET_SPARC64) && !defined(TARGET_ABI32) 361 #define SPARC_MC_TSTATE 0 362 #define SPARC_MC_PC 1 363 #define SPARC_MC_NPC 2 364 #define SPARC_MC_Y 3 365 #define SPARC_MC_G1 4 366 #define SPARC_MC_G2 5 367 #define SPARC_MC_G3 6 368 #define SPARC_MC_G4 7 369 #define SPARC_MC_G5 8 370 #define SPARC_MC_G6 9 371 #define SPARC_MC_G7 10 372 #define SPARC_MC_O0 11 373 #define SPARC_MC_O1 12 374 #define SPARC_MC_O2 13 375 #define SPARC_MC_O3 14 376 #define SPARC_MC_O4 15 377 #define SPARC_MC_O5 16 378 #define SPARC_MC_O6 17 379 #define SPARC_MC_O7 18 380 #define SPARC_MC_NGREG 19 381 382 typedef abi_ulong target_mc_greg_t; 383 typedef target_mc_greg_t target_mc_gregset_t[SPARC_MC_NGREG]; 384 385 struct target_mc_fq { 386 abi_ulong *mcfq_addr; 387 uint32_t mcfq_insn; 388 }; 389 390 struct target_mc_fpu { 391 union { 392 uint32_t sregs[32]; 393 uint64_t dregs[32]; 394 //uint128_t qregs[16]; 395 } mcfpu_fregs; 396 abi_ulong mcfpu_fsr; 397 abi_ulong mcfpu_fprs; 398 abi_ulong mcfpu_gsr; 399 struct target_mc_fq *mcfpu_fq; 400 unsigned char mcfpu_qcnt; 401 unsigned char mcfpu_qentsz; 402 unsigned char mcfpu_enab; 403 }; 404 typedef struct target_mc_fpu target_mc_fpu_t; 405 406 typedef struct { 407 target_mc_gregset_t mc_gregs; 408 target_mc_greg_t mc_fp; 409 target_mc_greg_t mc_i7; 410 target_mc_fpu_t mc_fpregs; 411 } target_mcontext_t; 412 413 struct target_ucontext { 414 struct target_ucontext *tuc_link; 415 abi_ulong tuc_flags; 416 target_sigset_t tuc_sigmask; 417 target_mcontext_t tuc_mcontext; 418 }; 419 420 /* A V9 register window */ 421 struct target_reg_window { 422 abi_ulong locals[8]; 423 abi_ulong ins[8]; 424 }; 425 426 #define TARGET_STACK_BIAS 2047 427 428 /* {set, get}context() needed for 64-bit SparcLinux userland. */ 429 void sparc64_set_context(CPUSPARCState *env) 430 { 431 abi_ulong ucp_addr; 432 struct target_ucontext *ucp; 433 target_mc_gregset_t *grp; 434 abi_ulong pc, npc, tstate; 435 abi_ulong fp, i7, w_addr; 436 unsigned int i; 437 438 ucp_addr = env->regwptr[UREG_I0]; 439 if (!lock_user_struct(VERIFY_READ, ucp, ucp_addr, 1)) { 440 goto do_sigsegv; 441 } 442 grp = &ucp->tuc_mcontext.mc_gregs; 443 __get_user(pc, &((*grp)[SPARC_MC_PC])); 444 __get_user(npc, &((*grp)[SPARC_MC_NPC])); 445 if ((pc | npc) & 3) { 446 goto do_sigsegv; 447 } 448 if (env->regwptr[UREG_I1]) { 449 target_sigset_t target_set; 450 sigset_t set; 451 452 if (TARGET_NSIG_WORDS == 1) { 453 __get_user(target_set.sig[0], &ucp->tuc_sigmask.sig[0]); 454 } else { 455 abi_ulong *src, *dst; 456 src = ucp->tuc_sigmask.sig; 457 dst = target_set.sig; 458 for (i = 0; i < TARGET_NSIG_WORDS; i++, dst++, src++) { 459 __get_user(*dst, src); 460 } 461 } 462 target_to_host_sigset_internal(&set, &target_set); 463 set_sigmask(&set); 464 } 465 env->pc = pc; 466 env->npc = npc; 467 __get_user(env->y, &((*grp)[SPARC_MC_Y])); 468 __get_user(tstate, &((*grp)[SPARC_MC_TSTATE])); 469 env->asi = (tstate >> 24) & 0xff; 470 cpu_put_ccr(env, tstate >> 32); 471 cpu_put_cwp64(env, tstate & 0x1f); 472 __get_user(env->gregs[1], (&(*grp)[SPARC_MC_G1])); 473 __get_user(env->gregs[2], (&(*grp)[SPARC_MC_G2])); 474 __get_user(env->gregs[3], (&(*grp)[SPARC_MC_G3])); 475 __get_user(env->gregs[4], (&(*grp)[SPARC_MC_G4])); 476 __get_user(env->gregs[5], (&(*grp)[SPARC_MC_G5])); 477 __get_user(env->gregs[6], (&(*grp)[SPARC_MC_G6])); 478 __get_user(env->gregs[7], (&(*grp)[SPARC_MC_G7])); 479 __get_user(env->regwptr[UREG_I0], (&(*grp)[SPARC_MC_O0])); 480 __get_user(env->regwptr[UREG_I1], (&(*grp)[SPARC_MC_O1])); 481 __get_user(env->regwptr[UREG_I2], (&(*grp)[SPARC_MC_O2])); 482 __get_user(env->regwptr[UREG_I3], (&(*grp)[SPARC_MC_O3])); 483 __get_user(env->regwptr[UREG_I4], (&(*grp)[SPARC_MC_O4])); 484 __get_user(env->regwptr[UREG_I5], (&(*grp)[SPARC_MC_O5])); 485 __get_user(env->regwptr[UREG_I6], (&(*grp)[SPARC_MC_O6])); 486 __get_user(env->regwptr[UREG_I7], (&(*grp)[SPARC_MC_O7])); 487 488 __get_user(fp, &(ucp->tuc_mcontext.mc_fp)); 489 __get_user(i7, &(ucp->tuc_mcontext.mc_i7)); 490 491 w_addr = TARGET_STACK_BIAS+env->regwptr[UREG_I6]; 492 if (put_user(fp, w_addr + offsetof(struct target_reg_window, ins[6]), 493 abi_ulong) != 0) { 494 goto do_sigsegv; 495 } 496 if (put_user(i7, w_addr + offsetof(struct target_reg_window, ins[7]), 497 abi_ulong) != 0) { 498 goto do_sigsegv; 499 } 500 /* FIXME this does not match how the kernel handles the FPU in 501 * its sparc64_set_context implementation. In particular the FPU 502 * is only restored if fenab is non-zero in: 503 * __get_user(fenab, &(ucp->tuc_mcontext.mc_fpregs.mcfpu_enab)); 504 */ 505 __get_user(env->fprs, &(ucp->tuc_mcontext.mc_fpregs.mcfpu_fprs)); 506 { 507 uint32_t *src = ucp->tuc_mcontext.mc_fpregs.mcfpu_fregs.sregs; 508 for (i = 0; i < 64; i++, src++) { 509 if (i & 1) { 510 __get_user(env->fpr[i/2].l.lower, src); 511 } else { 512 __get_user(env->fpr[i/2].l.upper, src); 513 } 514 } 515 } 516 __get_user(env->fsr, 517 &(ucp->tuc_mcontext.mc_fpregs.mcfpu_fsr)); 518 __get_user(env->gsr, 519 &(ucp->tuc_mcontext.mc_fpregs.mcfpu_gsr)); 520 unlock_user_struct(ucp, ucp_addr, 0); 521 return; 522 do_sigsegv: 523 unlock_user_struct(ucp, ucp_addr, 0); 524 force_sig(TARGET_SIGSEGV); 525 } 526 527 void sparc64_get_context(CPUSPARCState *env) 528 { 529 abi_ulong ucp_addr; 530 struct target_ucontext *ucp; 531 target_mc_gregset_t *grp; 532 target_mcontext_t *mcp; 533 abi_ulong fp, i7, w_addr; 534 int err; 535 unsigned int i; 536 target_sigset_t target_set; 537 sigset_t set; 538 539 ucp_addr = env->regwptr[UREG_I0]; 540 if (!lock_user_struct(VERIFY_WRITE, ucp, ucp_addr, 0)) { 541 goto do_sigsegv; 542 } 543 544 mcp = &ucp->tuc_mcontext; 545 grp = &mcp->mc_gregs; 546 547 /* Skip over the trap instruction, first. */ 548 env->pc = env->npc; 549 env->npc += 4; 550 551 /* If we're only reading the signal mask then do_sigprocmask() 552 * is guaranteed not to fail, which is important because we don't 553 * have any way to signal a failure or restart this operation since 554 * this is not a normal syscall. 555 */ 556 err = do_sigprocmask(0, NULL, &set); 557 assert(err == 0); 558 host_to_target_sigset_internal(&target_set, &set); 559 if (TARGET_NSIG_WORDS == 1) { 560 __put_user(target_set.sig[0], 561 (abi_ulong *)&ucp->tuc_sigmask); 562 } else { 563 abi_ulong *src, *dst; 564 src = target_set.sig; 565 dst = ucp->tuc_sigmask.sig; 566 for (i = 0; i < TARGET_NSIG_WORDS; i++, dst++, src++) { 567 __put_user(*src, dst); 568 } 569 if (err) 570 goto do_sigsegv; 571 } 572 573 /* XXX: tstate must be saved properly */ 574 // __put_user(env->tstate, &((*grp)[SPARC_MC_TSTATE])); 575 __put_user(env->pc, &((*grp)[SPARC_MC_PC])); 576 __put_user(env->npc, &((*grp)[SPARC_MC_NPC])); 577 __put_user(env->y, &((*grp)[SPARC_MC_Y])); 578 __put_user(env->gregs[1], &((*grp)[SPARC_MC_G1])); 579 __put_user(env->gregs[2], &((*grp)[SPARC_MC_G2])); 580 __put_user(env->gregs[3], &((*grp)[SPARC_MC_G3])); 581 __put_user(env->gregs[4], &((*grp)[SPARC_MC_G4])); 582 __put_user(env->gregs[5], &((*grp)[SPARC_MC_G5])); 583 __put_user(env->gregs[6], &((*grp)[SPARC_MC_G6])); 584 __put_user(env->gregs[7], &((*grp)[SPARC_MC_G7])); 585 __put_user(env->regwptr[UREG_I0], &((*grp)[SPARC_MC_O0])); 586 __put_user(env->regwptr[UREG_I1], &((*grp)[SPARC_MC_O1])); 587 __put_user(env->regwptr[UREG_I2], &((*grp)[SPARC_MC_O2])); 588 __put_user(env->regwptr[UREG_I3], &((*grp)[SPARC_MC_O3])); 589 __put_user(env->regwptr[UREG_I4], &((*grp)[SPARC_MC_O4])); 590 __put_user(env->regwptr[UREG_I5], &((*grp)[SPARC_MC_O5])); 591 __put_user(env->regwptr[UREG_I6], &((*grp)[SPARC_MC_O6])); 592 __put_user(env->regwptr[UREG_I7], &((*grp)[SPARC_MC_O7])); 593 594 w_addr = TARGET_STACK_BIAS+env->regwptr[UREG_I6]; 595 fp = i7 = 0; 596 if (get_user(fp, w_addr + offsetof(struct target_reg_window, ins[6]), 597 abi_ulong) != 0) { 598 goto do_sigsegv; 599 } 600 if (get_user(i7, w_addr + offsetof(struct target_reg_window, ins[7]), 601 abi_ulong) != 0) { 602 goto do_sigsegv; 603 } 604 __put_user(fp, &(mcp->mc_fp)); 605 __put_user(i7, &(mcp->mc_i7)); 606 607 { 608 uint32_t *dst = ucp->tuc_mcontext.mc_fpregs.mcfpu_fregs.sregs; 609 for (i = 0; i < 64; i++, dst++) { 610 if (i & 1) { 611 __put_user(env->fpr[i/2].l.lower, dst); 612 } else { 613 __put_user(env->fpr[i/2].l.upper, dst); 614 } 615 } 616 } 617 __put_user(env->fsr, &(mcp->mc_fpregs.mcfpu_fsr)); 618 __put_user(env->gsr, &(mcp->mc_fpregs.mcfpu_gsr)); 619 __put_user(env->fprs, &(mcp->mc_fpregs.mcfpu_fprs)); 620 621 if (err) 622 goto do_sigsegv; 623 unlock_user_struct(ucp, ucp_addr, 1); 624 return; 625 do_sigsegv: 626 unlock_user_struct(ucp, ucp_addr, 1); 627 force_sig(TARGET_SIGSEGV); 628 } 629 #endif 630