From patchwork Fri May 27 13:00:26 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Riku Voipio X-Patchwork-Id: 627183 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3rGS2q5YLGz9t3Z for ; Fri, 27 May 2016 23:45:55 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b=JqPr4tvw; dkim-atps=neutral Received: from localhost ([::1]:45925 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b6I5J-00014q-NP for incoming@patchwork.ozlabs.org; Fri, 27 May 2016 09:45:53 -0400 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) 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=JqPr4tvwlG1JJm6zThqAn/mu5oVnBkgzgbT9MKebXGdkm4mpYRKW6GfNeyy2xspTKT 0ys67J0CyecZHmvYQGomtlmVzsv10NSLcHxAZwESO9u0mRe4FH2ZJQejLWBGWjBSgyk5 3Wz/vEjce3YGvKnWBemIYOXV8paJ1EBmNiBG8= 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=BeFWItZjh6CtEJU8bxXwXGII/6tTErJEw0OzQT4y59Qe4RGt+Gwu+dBsTXckX27Xdj vKg0TRUTfYlVrTf+LnbFSZuEQWikEwiGICiGmvswcPK8+NfSb8+E3MbVPAL7/mLgx8+v 1M6kausQ7bHWmXR5ZL4fu2K8K4/QpUk+nFPuj0pEIWv5ZebOyU9eOglFnZJ4M47g/Lm1 E7KtGGvjMg7frx4ZWEZOUJT4KkupEsG/cVkiUsB+I4yMf6qKiWs6B7rvwcDU2WVG1Yqk D5NmcvZkcyr2hFSHgdx2GWJp3zsNVe4uOeuKgMqp2mhyVqZd7q6v52MILH7ZYFYEc35q Ayvg== X-Gm-Message-State: ALyK8tKmA7pEx7BsMhtVLiuW16hravgd677u+k9wvqiUeGp58XUqB80DbZMk/fz/DkhrnmOh X-Received: by 10.112.9.200 with SMTP id c8mr4283801lbb.50.1464354076384; Fri, 27 May 2016 06:01:16 -0700 (PDT) Received: from beaming.home (91-157-168-132.elisa-laajakaista.fi. [91.157.168.132]) by smtp.gmail.com with ESMTPSA id n16sm2281066lfg.31.2016.05.27.06.01.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 27 May 2016 06:01:15 -0700 (PDT) From: riku.voipio@linaro.org To: qemu-devel@nongnu.org Date: Fri, 27 May 2016 16:00:26 +0300 Message-Id: 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::22d Subject: [Qemu-devel] [PULL v2 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" 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;