From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37607) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b6HOE-0007wB-Kg for qemu-devel@nongnu.org; Fri, 27 May 2016 09:01:26 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1b6HO9-0001Mk-Ka for qemu-devel@nongnu.org; Fri, 27 May 2016 09:01:21 -0400 Received: from mail-lb0-x22d.google.com ([2a00:1450:4010:c04::22d]:36565) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b6HO9-0001MS-7i for qemu-devel@nongnu.org; Fri, 27 May 2016 09:01:17 -0400 Received: by mail-lb0-x22d.google.com with SMTP id h1so31610648lbj.3 for ; Fri, 27 May 2016 06:01:17 -0700 (PDT) From: riku.voipio@linaro.org Date: Fri, 27 May 2016 16:00:26 +0300 Message-Id: In-Reply-To: References: Subject: [Qemu-devel] [PULL v2 35/38] linux-user/signal.c: Generate opcode data for restorer in setup_rt_frame List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Chen Gang From: Chen Gang 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. Reviewed-by: Laurent Vivier Signed-off-by: Chen Gang Signed-off-by: Riku Voipio --- linux-user/signal.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/linux-user/signal.c b/linux-user/signal.c index ff4de4f..a072fa6 100644 --- a/linux-user/signal.c +++ b/linux-user/signal.c @@ -5599,8 +5599,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) { @@ -5676,9 +5681,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; -- 2.1.4