From patchwork Wed May 25 10:32:07 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Riku Voipio X-Patchwork-Id: 9135159 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id D94946075C for ; Wed, 25 May 2016 11:03:03 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CD826252D5 for ; Wed, 25 May 2016 11:03:03 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C2950282A2; Wed, 25 May 2016 11:03:03 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, FSL_HELO_HOME, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 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.wl.linuxfoundation.org (Postfix) with ESMTPS id 9D57D252D5 for ; Wed, 25 May 2016 11:03:02 +0000 (UTC) Received: from localhost ([::1]:58951 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b5Wab-0003fv-Op for patchwork-qemu-devel@patchwork.kernel.org; Wed, 25 May 2016 07:03:01 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42089) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b5W7V-0001aV-2u for qemu-devel@nongnu.org; Wed, 25 May 2016 06:33:03 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1b5W7K-0003Tl-D9 for qemu-devel@nongnu.org; Wed, 25 May 2016 06:32:56 -0400 Received: from mail-lb0-x233.google.com ([2a00:1450:4010:c04::233]:35131) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b5W7K-0003Sp-65 for qemu-devel@nongnu.org; Wed, 25 May 2016 06:32:46 -0400 Received: by mail-lb0-x233.google.com with SMTP id ww9so14021794lbc.2 for ; Wed, 25 May 2016 03:32:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=G4tAB/8sk0v5RYVQOuVrDdMN3RF+g9Kh8KOuVetdnKo=; b=Wg+yvz8y6g7BIKef7vCI0JocNKufaww+mj6A+mfy8T1hVnzLxKqeVWW9LE6U/94pqw AvOG8IBrNm8D91dnbtv8uZXjR5lTzAx3A37u6eFW+KXsFGgzwj/pkLRJOhjosVyzWNgp dR8CAMoYATYPFcFW/h8wI/wMYQ9Dy04tlhTvQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=G4tAB/8sk0v5RYVQOuVrDdMN3RF+g9Kh8KOuVetdnKo=; b=cCEtkybf2J48oxhx4pQ7OJhyoknpaz/c9uiZ/NtbK6lJqRZHqW48DdJZWEjo66Gd4m baDPQywsI6qFNM/Y9uEmRNg6yEXoF9Fny+Hf76OGrv2OtXZXfTEFRr1Zx6o+m1I0WzYP /WCb2s2hJdFlEi591h7uJRB2tVof3mOPSD1o9qagWQfADrti2Zq9ReOTHrDVBCaNXU5D MaeL0pCidNI/bjmvsDKA/Yxq2TiTh4QA5ZEFY9zGTjLCQA03VtePJhyOa4yb0fDH+3Uk SFX58TMKxB5M1xVDHZg4tgafyamp3/PXEo3duxqYI9TbrPusWTZjQDKM7T7UChqfOgA0 V7Xg== X-Gm-Message-State: ALyK8tI8IiFui2SAGbT0RAlDDXfmkpxemaxHzVHgWH+MudTNch/f2X2lYDVZmWm1qjPIpLKw X-Received: by 10.112.169.42 with SMTP id ab10mr833082lbc.63.1464172365465; Wed, 25 May 2016 03:32:45 -0700 (PDT) Received: from beaming.home (91-157-168-132.elisa-laajakaista.fi. [91.157.168.132]) by smtp.gmail.com with ESMTPSA id o75sm1379610lfi.9.2016.05.25.03.32.44 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 25 May 2016 03:32:44 -0700 (PDT) From: riku.voipio@linaro.org To: qemu-devel@nongnu.org Date: Wed, 25 May 2016 13:32:07 +0300 Message-Id: <582e47b2419bd27db73310560427ead5bba5c03b.1464153942.git.riku.voipio@linaro.org> X-Mailer: git-send-email 2.1.4 In-Reply-To: References: X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2a00:1450:4010:c04::233 Subject: [Qemu-devel] [PULL 35/38] linux-user/signal.c: Generate opcode data for restorer in setup_rt_frame X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Chen Gang Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" 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. 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;