From patchwork Mon Mar 14 21:51:48 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chen Gang X-Patchwork-Id: 8583941 Return-Path: X-Original-To: patchwork-qemu-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 690609F3D1 for ; Mon, 14 Mar 2016 21:52:33 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 4A78520270 for ; Mon, 14 Mar 2016 21:52:32 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 9AAF920263 for ; Mon, 14 Mar 2016 21:52:29 +0000 (UTC) Received: from localhost ([::1]:44241 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1afaPb-00059Q-Sc for patchwork-qemu-devel@patchwork.kernel.org; Mon, 14 Mar 2016 17:52:27 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46891) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1afaPU-00059A-FJ for qemu-devel@nongnu.org; Mon, 14 Mar 2016 17:52:21 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1afaPP-0003cP-EX for qemu-devel@nongnu.org; Mon, 14 Mar 2016 17:52:20 -0400 Received: from mail113-248.mail.alibaba.com ([205.204.113.248]:50257 helo=us-alimail-mta2.hst.scl.en.alidc.net) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1afaPP-0003W8-02 for qemu-devel@nongnu.org; Mon, 14 Mar 2016 17:52:15 -0400 X-Alimail-AntiSpam: AC=CONTINUE; BC=0.07777933|-1; FP=0|0|0|0|0|-1|-1|-1; HT=e02c03298; MF=chengang@emindsoft.com.cn; NM=1; PH=DS; RN=8; RT=7; SR=0; TI=SMTPD_----4brqDOq_1457992311; Received: from localhost.localdomain(mailfrom:chengang@emindsoft.com.cn ip:223.72.67.118) by smtp.aliyun-inc.com(10.147.40.200); Tue, 15 Mar 2016 05:51:59 +0800 From: chengang@emindsoft.com.cn To: rth@twiddle.net, peter.maydell@linaro.org, cmetcalf@ezchip.com Date: Tue, 15 Mar 2016 05:51:48 +0800 Message-Id: <1457992308-2136-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.4.x-2.6.x [generic] X-Received-From: 205.204.113.248 Cc: walt@tilera.com, Chen Gang , qemu-devel@nongnu.org, Chen Gang Subject: [Qemu-devel] [PATCH] 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+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 --- 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 919aa83..0e3b1c6 100644 --- a/linux-user/signal.c +++ b/linux-user/signal.c @@ -5566,8 +5566,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) { @@ -5643,9 +5648,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 = (unsigned long)frame->retcode; } env->pc = (unsigned long) ka->_sa_handler; env->regs[TILEGX_R_SP] = (unsigned long) frame;