Skip to content

Commit c790e4e

Browse files
rth7680vivier
authored andcommitted
linux-user/ppc: Implement setup_sigtramp
Create and record the two signal trampolines. Cc: [email protected] Reviewed-by: Peter Maydell <[email protected]> Signed-off-by: Richard Henderson <[email protected]> Message-Id: <[email protected]> Signed-off-by: Laurent Vivier <[email protected]>
1 parent 5d2fc70 commit c790e4e

File tree

2 files changed

+20
-16
lines changed

2 files changed

+20
-16
lines changed

linux-user/ppc/signal.c

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -203,9 +203,6 @@ struct target_func_ptr {
203203

204204
#endif
205205

206-
/* We use the mc_pad field for the signal return trampoline. */
207-
#define tramp mc_pad
208-
209206
/* See arch/powerpc/kernel/signal.c. */
210207
static target_ulong get_sigframe(struct target_sigaction *ka,
211208
CPUPPCState *env,
@@ -436,12 +433,7 @@ void setup_frame(int sig, struct target_sigaction *ka,
436433
/* Save user regs. */
437434
save_user_regs(env, &frame->mctx);
438435

439-
/* Construct the trampoline code on the stack. */
440-
encode_trampoline(TARGET_NR_sigreturn, (uint32_t *)&frame->mctx.tramp);
441-
442-
/* The kernel checks for the presence of a VDSO here. We don't
443-
emulate a vdso, so use a sigreturn system call. */
444-
env->lr = (target_ulong) h2g(frame->mctx.tramp);
436+
env->lr = default_sigreturn;
445437

446438
/* Turn off all fp exceptions. */
447439
env->fpscr = 0;
@@ -477,7 +469,6 @@ void setup_rt_frame(int sig, struct target_sigaction *ka,
477469
target_sigset_t *set, CPUPPCState *env)
478470
{
479471
struct target_rt_sigframe *rt_sf;
480-
uint32_t *trampptr = 0;
481472
struct target_mcontext *mctx = 0;
482473
target_ulong rt_sf_addr, newsp = 0;
483474
int i, err = 0;
@@ -507,22 +498,17 @@ void setup_rt_frame(int sig, struct target_sigaction *ka,
507498

508499
#if defined(TARGET_PPC64)
509500
mctx = &rt_sf->uc.tuc_sigcontext.mcontext;
510-
trampptr = &rt_sf->trampoline[0];
511501

512502
sc = &rt_sf->uc.tuc_sigcontext;
513503
__put_user(h2g(mctx), &sc->regs);
514504
__put_user(sig, &sc->signal);
515505
#else
516506
mctx = &rt_sf->uc.tuc_mcontext;
517-
trampptr = (uint32_t *)&rt_sf->uc.tuc_mcontext.tramp;
518507
#endif
519508

520509
save_user_regs(env, mctx);
521-
encode_trampoline(TARGET_NR_rt_sigreturn, trampptr);
522510

523-
/* The kernel checks for the presence of a VDSO here. We don't
524-
emulate a vdso, so use a sigreturn system call. */
525-
env->lr = (target_ulong) h2g(trampptr);
511+
env->lr = default_rt_sigreturn;
526512

527513
/* Turn off all fp exceptions. */
528514
env->fpscr = 0;
@@ -720,3 +706,19 @@ abi_long do_swapcontext(CPUArchState *env, abi_ulong uold_ctx,
720706

721707
return 0;
722708
}
709+
710+
void setup_sigtramp(abi_ulong sigtramp_page)
711+
{
712+
uint32_t *tramp = lock_user(VERIFY_WRITE, sigtramp_page, 2 * 8, 0);
713+
assert(tramp != NULL);
714+
715+
#ifdef TARGET_ARCH_HAS_SETUP_FRAME
716+
default_sigreturn = sigtramp_page;
717+
encode_trampoline(TARGET_NR_sigreturn, tramp + 0);
718+
#endif
719+
720+
default_rt_sigreturn = sigtramp_page + 8;
721+
encode_trampoline(TARGET_NR_rt_sigreturn, tramp + 2);
722+
723+
unlock_user(tramp, sigtramp_page, 2 * 8);
724+
}

linux-user/ppc/target_signal.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,6 @@ typedef struct target_sigaltstack {
2424
#if !defined(TARGET_PPC64)
2525
#define TARGET_ARCH_HAS_SETUP_FRAME
2626
#endif
27+
#define TARGET_ARCH_HAS_SIGTRAMP_PAGE 1
28+
2729
#endif /* PPC_TARGET_SIGNAL_H */

0 commit comments

Comments
 (0)