From patchwork Tue Mar 29 13:53:49 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chen Gang X-Patchwork-Id: 602936 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3qZC260PY5z9t5b for ; Wed, 30 Mar 2016 00:54:38 +1100 (AEDT) Received: from localhost ([::1]:47116 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aku6O-0000wY-Cu for incoming@patchwork.ozlabs.org; Tue, 29 Mar 2016 09:54:36 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37892) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aku67-0000fG-DN for qemu-devel@nongnu.org; Tue, 29 Mar 2016 09:54:20 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aku63-0006cA-DR for qemu-devel@nongnu.org; Tue, 29 Mar 2016 09:54:19 -0400 Received: from out11.biz.mail.alibaba.com ([205.204.114.131]:33004) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aku62-0006bP-Uf for qemu-devel@nongnu.org; Tue, 29 Mar 2016 09:54:15 -0400 X-Alimail-AntiSpam: AC=CONTINUE; BC=0.07913762|-1; FP=0|0|0|0|0|-1|-1|-1; HT=e02c03308; MF=chengang@emindsoft.com.cn; NM=1; PH=DS; RN=10; RT=9; SR=0; TI=SMTPD_----4ee8uUM_1459259631; Received: from localhost.localdomain(mailfrom:chengang@emindsoft.com.cn ip:223.72.89.125) by smtp.aliyun-inc.com(10.147.43.230); Tue, 29 Mar 2016 21:53:56 +0800 From: chengang@emindsoft.com.cn To: rth@twiddle.net, peter.maydell@linaro.org, cmetcalf@ezchip.com, laurent@vivier.eu Date: Tue, 29 Mar 2016 21:53:49 +0800 Message-Id: <1459259629-5312-1-git-send-email-chengang@emindsoft.com.cn> X-Mailer: git-send-email 1.9.3 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 205.204.114.131 Cc: walt@tilera.com, Chen Gang , riku.voipio@iki.fi, qemu-devel@nongnu.org, Chen Gang Subject: [Qemu-devel] [PATCH v2] linux-user/signal.c: Generate opcode data for restorer in setup_rt_frame X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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. Signed-off-by: Chen Gang Reviewed-by: Laurent Vivier --- 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 96e86c0..e487f9e 100644 --- a/linux-user/signal.c +++ b/linux-user/signal.c @@ -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;