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 "user-internals.h" 22 #include "signal-common.h" 23 #include "linux-user/trace.h" 24 #include "target/arm/cpu-features.h" 25 26 struct target_sigcontext { 27 abi_ulong trap_no; 28 abi_ulong error_code; 29 abi_ulong oldmask; 30 abi_ulong arm_r0; 31 abi_ulong arm_r1; 32 abi_ulong arm_r2; 33 abi_ulong arm_r3; 34 abi_ulong arm_r4; 35 abi_ulong arm_r5; 36 abi_ulong arm_r6; 37 abi_ulong arm_r7; 38 abi_ulong arm_r8; 39 abi_ulong arm_r9; 40 abi_ulong arm_r10; 41 abi_ulong arm_fp; 42 abi_ulong arm_ip; 43 abi_ulong arm_sp; 44 abi_ulong arm_lr; 45 abi_ulong arm_pc; 46 abi_ulong arm_cpsr; 47 abi_ulong fault_address; 48 }; 49 50 struct target_ucontext { 51 abi_ulong tuc_flags; 52 abi_ulong tuc_link; 53 target_stack_t tuc_stack; 54 struct target_sigcontext tuc_mcontext; 55 target_sigset_t tuc_sigmask; /* mask last for extensibility */ 56 char __unused[128 - sizeof(target_sigset_t)]; 57 abi_ulong tuc_regspace[128] __attribute__((__aligned__(8))); 58 }; 59 60 struct target_user_vfp { 61 uint64_t fpregs[32]; 62 abi_ulong fpscr; 63 }; 64 65 struct target_user_vfp_exc { 66 abi_ulong fpexc; 67 abi_ulong fpinst; 68 abi_ulong fpinst2; 69 }; 70 71 struct target_vfp_sigframe { 72 abi_ulong magic; 73 abi_ulong size; 74 struct target_user_vfp ufp; 75 struct target_user_vfp_exc ufp_exc; 76 } __attribute__((__aligned__(8))); 77 78 struct target_iwmmxt_sigframe { 79 abi_ulong magic; 80 abi_ulong size; 81 uint64_t regs[16]; 82 /* Note that not all the coprocessor control registers are stored here */ 83 uint32_t wcssf; 84 uint32_t wcasf; 85 uint32_t wcgr0; 86 uint32_t wcgr1; 87 uint32_t wcgr2; 88 uint32_t wcgr3; 89 } __attribute__((__aligned__(8))); 90 91 #define TARGET_VFP_MAGIC 0x56465001 92 #define TARGET_IWMMXT_MAGIC 0x12ef842a 93 94 struct sigframe 95 { 96 struct target_ucontext uc; 97 abi_ulong retcode[4]; 98 }; 99 100 struct rt_sigframe 101 { 102 struct target_siginfo info; 103 struct sigframe sig; 104 }; 105 106 static abi_ptr sigreturn_fdpic_tramp; 107 108 /* 109 * Up to 3 words of 'retcode' in the sigframe are code, 110 * with retcode[3] being used by fdpic for the function descriptor. 111 * This code is not actually executed, but is retained for ABI compat. 112 * 113 * We will create a table of 8 retcode variants in the sigtramp page. 114 * Let each table entry use 3 words. 115 */ 116 #define RETCODE_WORDS 3 117 #define RETCODE_BYTES (RETCODE_WORDS * 4) 118 119 static inline int valid_user_regs(CPUARMState *regs) 120 { 121 return 1; 122 } 123 124 static void 125 setup_sigcontext(struct target_sigcontext *sc, /*struct _fpstate *fpstate,*/ 126 CPUARMState *env, abi_ulong mask) 127 { 128 __put_user(env->regs[0], &sc->arm_r0); 129 __put_user(env->regs[1], &sc->arm_r1); 130 __put_user(env->regs[2], &sc->arm_r2); 131 __put_user(env->regs[3], &sc->arm_r3); 132 __put_user(env->regs[4], &sc->arm_r4); 133 __put_user(env->regs[5], &sc->arm_r5); 134 __put_user(env->regs[6], &sc->arm_r6); 135 __put_user(env->regs[7], &sc->arm_r7); 136 __put_user(env->regs[8], &sc->arm_r8); 137 __put_user(env->regs[9], &sc->arm_r9); 138 __put_user(env->regs[10], &sc->arm_r10); 139 __put_user(env->regs[11], &sc->arm_fp); 140 __put_user(env->regs[12], &sc->arm_ip); 141 __put_user(env->regs[13], &sc->arm_sp); 142 __put_user(env->regs[14], &sc->arm_lr); 143 __put_user(env->regs[15], &sc->arm_pc); 144 __put_user(cpsr_read(env), &sc->arm_cpsr); 145 146 __put_user(/* current->thread.trap_no */ 0, &sc->trap_no); 147 __put_user(/* current->thread.error_code */ 0, &sc->error_code); 148 __put_user(/* current->thread.address */ 0, &sc->fault_address); 149 __put_user(mask, &sc->oldmask); 150 } 151 152 static inline abi_ulong 153 get_sigframe(struct target_sigaction *ka, CPUARMState *regs, int framesize) 154 { 155 unsigned long sp; 156 157 sp = target_sigsp(get_sp_from_cpustate(regs), ka); 158 /* 159 * ATPCS B01 mandates 8-byte alignment 160 */ 161 return (sp - framesize) & ~7; 162 } 163 164 static int 165 setup_return(CPUARMState *env, struct target_sigaction *ka, int usig, 166 struct sigframe *frame, abi_ulong sp_addr) 167 { 168 abi_ulong handler = 0; 169 abi_ulong handler_fdpic_GOT = 0; 170 abi_ulong retcode; 171 int thumb, retcode_idx; 172 int is_fdpic = info_is_fdpic(((TaskState *)thread_cpu->opaque)->info); 173 bool copy_retcode; 174 175 if (is_fdpic) { 176 /* In FDPIC mode, ka->_sa_handler points to a function 177 * descriptor (FD). The first word contains the address of the 178 * handler. The second word contains the value of the PIC 179 * register (r9). */ 180 abi_ulong funcdesc_ptr = ka->_sa_handler; 181 if (get_user_ual(handler, funcdesc_ptr) 182 || get_user_ual(handler_fdpic_GOT, funcdesc_ptr + 4)) { 183 return 1; 184 } 185 } else { 186 handler = ka->_sa_handler; 187 } 188 189 thumb = handler & 1; 190 retcode_idx = thumb + (ka->sa_flags & TARGET_SA_SIGINFO ? 2 : 0); 191 192 uint32_t cpsr = cpsr_read(env); 193 194 cpsr &= ~CPSR_IT; 195 if (thumb) { 196 cpsr |= CPSR_T; 197 } else { 198 cpsr &= ~CPSR_T; 199 } 200 if (env->cp15.sctlr_el[1] & SCTLR_E0E) { 201 cpsr |= CPSR_E; 202 } else { 203 cpsr &= ~CPSR_E; 204 } 205 206 if (ka->sa_flags & TARGET_SA_RESTORER) { 207 if (is_fdpic) { 208 __put_user((abi_ulong)ka->sa_restorer, &frame->retcode[3]); 209 retcode = (sigreturn_fdpic_tramp + 210 retcode_idx * RETCODE_BYTES + thumb); 211 copy_retcode = true; 212 } else { 213 retcode = ka->sa_restorer; 214 copy_retcode = false; 215 } 216 } else { 217 retcode = default_sigreturn + retcode_idx * RETCODE_BYTES + thumb; 218 copy_retcode = true; 219 } 220 221 /* Copy the code to the stack slot for ABI compatibility. */ 222 if (copy_retcode) { 223 memcpy(frame->retcode, g2h_untagged(retcode & ~1), RETCODE_BYTES); 224 } 225 226 env->regs[0] = usig; 227 if (is_fdpic) { 228 env->regs[9] = handler_fdpic_GOT; 229 } 230 env->regs[13] = sp_addr; 231 env->regs[14] = retcode; 232 env->regs[15] = handler & (thumb ? ~1 : ~3); 233 cpsr_write(env, cpsr, CPSR_IT | CPSR_T | CPSR_E, CPSRWriteByInstr); 234 235 return 0; 236 } 237 238 static abi_ulong *setup_sigframe_vfp(abi_ulong *regspace, CPUARMState *env) 239 { 240 int i; 241 struct target_vfp_sigframe *vfpframe; 242 vfpframe = (struct target_vfp_sigframe *)regspace; 243 __put_user(TARGET_VFP_MAGIC, &vfpframe->magic); 244 __put_user(sizeof(*vfpframe), &vfpframe->size); 245 for (i = 0; i < 32; i++) { 246 __put_user(*aa32_vfp_dreg(env, i), &vfpframe->ufp.fpregs[i]); 247 } 248 __put_user(vfp_get_fpscr(env), &vfpframe->ufp.fpscr); 249 __put_user(env->vfp.xregs[ARM_VFP_FPEXC], &vfpframe->ufp_exc.fpexc); 250 __put_user(env->vfp.xregs[ARM_VFP_FPINST], &vfpframe->ufp_exc.fpinst); 251 __put_user(env->vfp.xregs[ARM_VFP_FPINST2], &vfpframe->ufp_exc.fpinst2); 252 return (abi_ulong*)(vfpframe+1); 253 } 254 255 static abi_ulong *setup_sigframe_iwmmxt(abi_ulong *regspace, CPUARMState *env) 256 { 257 int i; 258 struct target_iwmmxt_sigframe *iwmmxtframe; 259 iwmmxtframe = (struct target_iwmmxt_sigframe *)regspace; 260 __put_user(TARGET_IWMMXT_MAGIC, &iwmmxtframe->magic); 261 __put_user(sizeof(*iwmmxtframe), &iwmmxtframe->size); 262 for (i = 0; i < 16; i++) { 263 __put_user(env->iwmmxt.regs[i], &iwmmxtframe->regs[i]); 264 } 265 __put_user(env->vfp.xregs[ARM_IWMMXT_wCSSF], &iwmmxtframe->wcssf); 266 __put_user(env->vfp.xregs[ARM_IWMMXT_wCASF], &iwmmxtframe->wcssf); 267 __put_user(env->vfp.xregs[ARM_IWMMXT_wCGR0], &iwmmxtframe->wcgr0); 268 __put_user(env->vfp.xregs[ARM_IWMMXT_wCGR1], &iwmmxtframe->wcgr1); 269 __put_user(env->vfp.xregs[ARM_IWMMXT_wCGR2], &iwmmxtframe->wcgr2); 270 __put_user(env->vfp.xregs[ARM_IWMMXT_wCGR3], &iwmmxtframe->wcgr3); 271 return (abi_ulong*)(iwmmxtframe+1); 272 } 273 274 static void setup_sigframe(struct target_ucontext *uc, 275 target_sigset_t *set, CPUARMState *env) 276 { 277 struct target_sigaltstack stack; 278 int i; 279 abi_ulong *regspace; 280 281 /* Clear all the bits of the ucontext we don't use. */ 282 memset(uc, 0, offsetof(struct target_ucontext, tuc_mcontext)); 283 284 memset(&stack, 0, sizeof(stack)); 285 target_save_altstack(&stack, env); 286 memcpy(&uc->tuc_stack, &stack, sizeof(stack)); 287 288 setup_sigcontext(&uc->tuc_mcontext, env, set->sig[0]); 289 /* Save coprocessor signal frame. */ 290 regspace = uc->tuc_regspace; 291 if (cpu_isar_feature(aa32_vfp_simd, env_archcpu(env))) { 292 regspace = setup_sigframe_vfp(regspace, env); 293 } 294 if (arm_feature(env, ARM_FEATURE_IWMMXT)) { 295 regspace = setup_sigframe_iwmmxt(regspace, env); 296 } 297 298 /* Write terminating magic word */ 299 __put_user(0, regspace); 300 301 for(i = 0; i < TARGET_NSIG_WORDS; i++) { 302 __put_user(set->sig[i], &uc->tuc_sigmask.sig[i]); 303 } 304 } 305 306 void setup_frame(int usig, struct target_sigaction *ka, 307 target_sigset_t *set, CPUARMState *regs) 308 { 309 struct sigframe *frame; 310 abi_ulong frame_addr = get_sigframe(ka, regs, sizeof(*frame)); 311 312 trace_user_setup_frame(regs, frame_addr); 313 if (!lock_user_struct(VERIFY_WRITE, frame, frame_addr, 0)) { 314 goto sigsegv; 315 } 316 317 setup_sigframe(&frame->uc, set, regs); 318 319 if (setup_return(regs, ka, usig, frame, frame_addr)) { 320 goto sigsegv; 321 } 322 323 unlock_user_struct(frame, frame_addr, 1); 324 return; 325 sigsegv: 326 unlock_user_struct(frame, frame_addr, 1); 327 force_sigsegv(usig); 328 } 329 330 void setup_rt_frame(int usig, struct target_sigaction *ka, 331 target_siginfo_t *info, 332 target_sigset_t *set, CPUARMState *env) 333 { 334 struct rt_sigframe *frame; 335 abi_ulong frame_addr = get_sigframe(ka, env, sizeof(*frame)); 336 abi_ulong info_addr, uc_addr; 337 338 trace_user_setup_rt_frame(env, frame_addr); 339 if (!lock_user_struct(VERIFY_WRITE, frame, frame_addr, 0)) { 340 goto sigsegv; 341 } 342 343 info_addr = frame_addr + offsetof(struct rt_sigframe, info); 344 uc_addr = frame_addr + offsetof(struct rt_sigframe, sig.uc); 345 tswap_siginfo(&frame->info, info); 346 347 setup_sigframe(&frame->sig.uc, set, env); 348 349 if (setup_return(env, ka, usig, &frame->sig, frame_addr)) { 350 goto sigsegv; 351 } 352 353 env->regs[1] = info_addr; 354 env->regs[2] = uc_addr; 355 356 unlock_user_struct(frame, frame_addr, 1); 357 return; 358 sigsegv: 359 unlock_user_struct(frame, frame_addr, 1); 360 force_sigsegv(usig); 361 } 362 363 static int 364 restore_sigcontext(CPUARMState *env, struct target_sigcontext *sc) 365 { 366 int err = 0; 367 uint32_t cpsr; 368 369 __get_user(env->regs[0], &sc->arm_r0); 370 __get_user(env->regs[1], &sc->arm_r1); 371 __get_user(env->regs[2], &sc->arm_r2); 372 __get_user(env->regs[3], &sc->arm_r3); 373 __get_user(env->regs[4], &sc->arm_r4); 374 __get_user(env->regs[5], &sc->arm_r5); 375 __get_user(env->regs[6], &sc->arm_r6); 376 __get_user(env->regs[7], &sc->arm_r7); 377 __get_user(env->regs[8], &sc->arm_r8); 378 __get_user(env->regs[9], &sc->arm_r9); 379 __get_user(env->regs[10], &sc->arm_r10); 380 __get_user(env->regs[11], &sc->arm_fp); 381 __get_user(env->regs[12], &sc->arm_ip); 382 __get_user(env->regs[13], &sc->arm_sp); 383 __get_user(env->regs[14], &sc->arm_lr); 384 __get_user(env->regs[15], &sc->arm_pc); 385 __get_user(cpsr, &sc->arm_cpsr); 386 cpsr_write(env, cpsr, CPSR_USER | CPSR_EXEC, CPSRWriteByInstr); 387 388 err |= !valid_user_regs(env); 389 390 return err; 391 } 392 393 static abi_ulong *restore_sigframe_vfp(CPUARMState *env, abi_ulong *regspace) 394 { 395 int i; 396 abi_ulong magic, sz; 397 uint32_t fpscr, fpexc; 398 struct target_vfp_sigframe *vfpframe; 399 vfpframe = (struct target_vfp_sigframe *)regspace; 400 401 __get_user(magic, &vfpframe->magic); 402 __get_user(sz, &vfpframe->size); 403 if (magic != TARGET_VFP_MAGIC || sz != sizeof(*vfpframe)) { 404 return 0; 405 } 406 for (i = 0; i < 32; i++) { 407 __get_user(*aa32_vfp_dreg(env, i), &vfpframe->ufp.fpregs[i]); 408 } 409 __get_user(fpscr, &vfpframe->ufp.fpscr); 410 vfp_set_fpscr(env, fpscr); 411 __get_user(fpexc, &vfpframe->ufp_exc.fpexc); 412 /* Sanitise FPEXC: ensure VFP is enabled, FPINST2 is invalid 413 * and the exception flag is cleared 414 */ 415 fpexc |= (1 << 30); 416 fpexc &= ~((1 << 31) | (1 << 28)); 417 env->vfp.xregs[ARM_VFP_FPEXC] = fpexc; 418 __get_user(env->vfp.xregs[ARM_VFP_FPINST], &vfpframe->ufp_exc.fpinst); 419 __get_user(env->vfp.xregs[ARM_VFP_FPINST2], &vfpframe->ufp_exc.fpinst2); 420 return (abi_ulong*)(vfpframe + 1); 421 } 422 423 static abi_ulong *restore_sigframe_iwmmxt(CPUARMState *env, 424 abi_ulong *regspace) 425 { 426 int i; 427 abi_ulong magic, sz; 428 struct target_iwmmxt_sigframe *iwmmxtframe; 429 iwmmxtframe = (struct target_iwmmxt_sigframe *)regspace; 430 431 __get_user(magic, &iwmmxtframe->magic); 432 __get_user(sz, &iwmmxtframe->size); 433 if (magic != TARGET_IWMMXT_MAGIC || sz != sizeof(*iwmmxtframe)) { 434 return 0; 435 } 436 for (i = 0; i < 16; i++) { 437 __get_user(env->iwmmxt.regs[i], &iwmmxtframe->regs[i]); 438 } 439 __get_user(env->vfp.xregs[ARM_IWMMXT_wCSSF], &iwmmxtframe->wcssf); 440 __get_user(env->vfp.xregs[ARM_IWMMXT_wCASF], &iwmmxtframe->wcssf); 441 __get_user(env->vfp.xregs[ARM_IWMMXT_wCGR0], &iwmmxtframe->wcgr0); 442 __get_user(env->vfp.xregs[ARM_IWMMXT_wCGR1], &iwmmxtframe->wcgr1); 443 __get_user(env->vfp.xregs[ARM_IWMMXT_wCGR2], &iwmmxtframe->wcgr2); 444 __get_user(env->vfp.xregs[ARM_IWMMXT_wCGR3], &iwmmxtframe->wcgr3); 445 return (abi_ulong*)(iwmmxtframe + 1); 446 } 447 448 static int do_sigframe_return(CPUARMState *env, 449 target_ulong context_addr, 450 struct target_ucontext *uc) 451 { 452 sigset_t host_set; 453 abi_ulong *regspace; 454 455 target_to_host_sigset(&host_set, &uc->tuc_sigmask); 456 set_sigmask(&host_set); 457 458 if (restore_sigcontext(env, &uc->tuc_mcontext)) { 459 return 1; 460 } 461 462 /* Restore coprocessor signal frame */ 463 regspace = uc->tuc_regspace; 464 if (cpu_isar_feature(aa32_vfp_simd, env_archcpu(env))) { 465 regspace = restore_sigframe_vfp(env, regspace); 466 if (!regspace) { 467 return 1; 468 } 469 } 470 if (arm_feature(env, ARM_FEATURE_IWMMXT)) { 471 regspace = restore_sigframe_iwmmxt(env, regspace); 472 if (!regspace) { 473 return 1; 474 } 475 } 476 477 target_restore_altstack(&uc->tuc_stack, env); 478 479 #if 0 480 /* Send SIGTRAP if we're single-stepping */ 481 if (ptrace_cancel_bpt(current)) 482 send_sig(SIGTRAP, current, 1); 483 #endif 484 485 return 0; 486 } 487 488 long do_sigreturn(CPUARMState *env) 489 { 490 abi_ulong frame_addr; 491 struct sigframe *frame = NULL; 492 493 /* 494 * Since we stacked the signal on a 64-bit boundary, 495 * then 'sp' should be word aligned here. If it's 496 * not, then the user is trying to mess with us. 497 */ 498 frame_addr = env->regs[13]; 499 trace_user_do_sigreturn(env, frame_addr); 500 if (frame_addr & 7) { 501 goto badframe; 502 } 503 504 if (!lock_user_struct(VERIFY_READ, frame, frame_addr, 1)) { 505 goto badframe; 506 } 507 508 if (do_sigframe_return(env, 509 frame_addr + offsetof(struct sigframe, uc), 510 &frame->uc)) { 511 goto badframe; 512 } 513 514 unlock_user_struct(frame, frame_addr, 0); 515 return -QEMU_ESIGRETURN; 516 517 badframe: 518 unlock_user_struct(frame, frame_addr, 0); 519 force_sig(TARGET_SIGSEGV); 520 return -QEMU_ESIGRETURN; 521 } 522 523 long do_rt_sigreturn(CPUARMState *env) 524 { 525 abi_ulong frame_addr; 526 struct rt_sigframe *frame = NULL; 527 528 /* 529 * Since we stacked the signal on a 64-bit boundary, 530 * then 'sp' should be word aligned here. If it's 531 * not, then the user is trying to mess with us. 532 */ 533 frame_addr = env->regs[13]; 534 trace_user_do_rt_sigreturn(env, frame_addr); 535 if (frame_addr & 7) { 536 goto badframe; 537 } 538 539 if (!lock_user_struct(VERIFY_READ, frame, frame_addr, 1)) { 540 goto badframe; 541 } 542 543 if (do_sigframe_return(env, 544 frame_addr + offsetof(struct rt_sigframe, sig.uc), 545 &frame->sig.uc)) { 546 goto badframe; 547 } 548 549 unlock_user_struct(frame, frame_addr, 0); 550 return -QEMU_ESIGRETURN; 551 552 badframe: 553 unlock_user_struct(frame, frame_addr, 0); 554 force_sig(TARGET_SIGSEGV); 555 return -QEMU_ESIGRETURN; 556 } 557 558 /* 559 * EABI syscalls pass the number via r7. 560 * Note that the kernel still adds the OABI syscall number to the trap, 561 * presumably for backward ABI compatibility with unwinders. 562 */ 563 #define ARM_MOV_R7_IMM(X) (0xe3a07000 | (X)) 564 #define ARM_SWI_SYS(X) (0xef000000 | (X) | ARM_SYSCALL_BASE) 565 566 #define THUMB_MOVS_R7_IMM(X) (0x2700 | (X)) 567 #define THUMB_SWI_SYS 0xdf00 568 569 static void write_arm_sigreturn(uint32_t *rc, int syscall) 570 { 571 __put_user(ARM_MOV_R7_IMM(syscall), rc); 572 __put_user(ARM_SWI_SYS(syscall), rc + 1); 573 /* Wrote 8 of 12 bytes */ 574 } 575 576 static void write_thm_sigreturn(uint32_t *rc, int syscall) 577 { 578 __put_user(THUMB_SWI_SYS << 16 | THUMB_MOVS_R7_IMM(syscall), rc); 579 /* Wrote 4 of 12 bytes */ 580 } 581 582 /* 583 * Stub needed to make sure the FD register (r9) contains the right value. 584 * Use the same instruction sequence as the kernel. 585 */ 586 static void write_arm_fdpic_sigreturn(uint32_t *rc, int ofs) 587 { 588 assert(ofs <= 0xfff); 589 __put_user(0xe59d3000 | ofs, rc + 0); /* ldr r3, [sp, #ofs] */ 590 __put_user(0xe8930908, rc + 1); /* ldm r3, { r3, r9 } */ 591 __put_user(0xe12fff13, rc + 2); /* bx r3 */ 592 /* Wrote 12 of 12 bytes */ 593 } 594 595 static void write_thm_fdpic_sigreturn(void *vrc, int ofs) 596 { 597 uint16_t *rc = vrc; 598 599 assert((ofs & ~0x3fc) == 0); 600 __put_user(0x9b00 | (ofs >> 2), rc + 0); /* ldr r3, [sp, #ofs] */ 601 __put_user(0xcb0c, rc + 1); /* ldm r3, { r2, r3 } */ 602 __put_user(0x4699, rc + 2); /* mov r9, r3 */ 603 __put_user(0x4710, rc + 3); /* bx r2 */ 604 /* Wrote 8 of 12 bytes */ 605 } 606 607 void setup_sigtramp(abi_ulong sigtramp_page) 608 { 609 uint32_t total_size = 8 * RETCODE_BYTES; 610 uint32_t *tramp = lock_user(VERIFY_WRITE, sigtramp_page, total_size, 0); 611 612 assert(tramp != NULL); 613 614 default_sigreturn = sigtramp_page; 615 write_arm_sigreturn(&tramp[0 * RETCODE_WORDS], TARGET_NR_sigreturn); 616 write_thm_sigreturn(&tramp[1 * RETCODE_WORDS], TARGET_NR_sigreturn); 617 write_arm_sigreturn(&tramp[2 * RETCODE_WORDS], TARGET_NR_rt_sigreturn); 618 write_thm_sigreturn(&tramp[3 * RETCODE_WORDS], TARGET_NR_rt_sigreturn); 619 620 sigreturn_fdpic_tramp = sigtramp_page + 4 * RETCODE_BYTES; 621 write_arm_fdpic_sigreturn(tramp + 4 * RETCODE_WORDS, 622 offsetof(struct sigframe, retcode[3])); 623 write_thm_fdpic_sigreturn(tramp + 5 * RETCODE_WORDS, 624 offsetof(struct sigframe, retcode[3])); 625 write_arm_fdpic_sigreturn(tramp + 6 * RETCODE_WORDS, 626 offsetof(struct rt_sigframe, sig.retcode[3])); 627 write_thm_fdpic_sigreturn(tramp + 7 * RETCODE_WORDS, 628 offsetof(struct rt_sigframe, sig.retcode[3])); 629 630 unlock_user(tramp, sigtramp_page, total_size); 631 } 632