linux-user/signal.c: Generate opcode data for restorer in setup_rt_frame
PATCH v2 1/1 linux-user/signal.c: Generate opcode data for restorer in setup_rt_frame
From: Chen Gang <[email protected]>
Original implementation uses do_rt_sigreturn directly in host space, when a guest program is in unwind procedure in guest space, it will get an incorrect restore address, then causes unwind failure.
Also cleanup the original incorrect indentation.
Signed-off-by Chen Gang <[email protected]>
--- linux-user/signal.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-)
linux-user/signal.c +10 -2
@@ -5559,8 +5559,13 @@ struct target_rt_sigframe {unsigned char save_area[16 ];/* caller save area */ struct target_siginfo info;struct target_ucontext uc; +abi_ulong retcode[2 ]; }; +#define INSN_MOVELI_R10_139 0x00045fe551483000ULL/* { moveli r10, 139 } */ +#define INSN_SWINT1 0x286b180051485000ULL/* { swint1 } */ + +static void setup_sigcontext (struct target_sigcontext *sc,CPUArchState *env,int signo) {
@@ -5636,9 +5641,12 @@ static void setup_rt_frame(int sig, struct target_sigaction *ka,__put_user (target_sigaltstack_used.ss_size, &frame->uc.tuc_stack.ss_size);setup_sigcontext (&frame->uc.tuc_mcontext, env, info->si_signo); - restorer = (unsigned long ) do_rt_sigreturn;if (ka->sa_flags &TARGET_SA_RESTORER ) { - restorer = (unsigned long ) ka->sa_restorer; + restorer = (unsigned long ) ka->sa_restorer; + }else { +__put_user (INSN_MOVELI_R10_139 , &frame->retcode[0 ]); +__put_user (INSN_SWINT1 , &frame->retcode[1 ]); + restorer = frame_addr + offsetof(struct target_rt_sigframe , retcode); } env->pc = (unsigned long ) ka->_sa_handler; env->regs[TILEGX_R_SP ] = (unsigned long ) frame;
Signature · 1 line
1.9.3
Quoted 9 lines · Le 29/03/2016 15:53, [email protected] a écrit :
From: Chen Gang <[email protected]>
Original implementation uses
do_rt_sigreturndirectly in host space, when a guest program is in unwind procedure in guest space, it will get an incorrect restore address, then causes unwind failure.Also cleanup the original incorrect indentation.
Signed-off-by Chen Gang <[email protected]>
Reviewed-by Laurent Vivier <[email protected]>
Quoted 38 lines
--- linux-user/signal.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-)linux-user/signal.c +10
-2@@ -5559,8 +5559,13 @@ struct target_rt_sigframe {unsigned char save_area[16 ];/* caller save area */ struct target_siginfo info;struct target_ucontext uc; +abi_ulong retcode[2 ]; }; +#define INSN_MOVELI_R10_139 0x00045fe551483000ULL/* { moveli r10, 139 } */ +#define INSN_SWINT1 0x286b180051485000ULL/* { swint1 } */ + +static void setup_sigcontext (struct target_sigcontext *sc,CPUArchState *env,int signo) {@@ -5636,9 +5641,12 @@ static void setup_rt_frame(int sig, struct target_sigaction *ka,__put_user (target_sigaltstack_used.ss_size, &frame->uc.tuc_stack.ss_size);setup_sigcontext (&frame->uc.tuc_mcontext, env, info->si_signo); - restorer = (unsigned long ) do_rt_sigreturn;if (ka->sa_flags &TARGET_SA_RESTORER ) { - restorer = (unsigned long ) ka->sa_restorer; + restorer = (unsigned long ) ka->sa_restorer; + }else { +__put_user (INSN_MOVELI_R10_139 , &frame->retcode[0 ]); +__put_user (INSN_SWINT1 , &frame->retcode[1 ]); + restorer = frame_addr + offsetof(struct target_rt_sigframe , retcode); } env->pc = (unsigned long ) ka->_sa_handler; env->regs[TILEGX_R_SP ] = (unsigned long ) frame;