From patchwork Thu Feb 16 14:38:14 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 728763 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 3vPKmd1gWgz9s85 for ; Fri, 17 Feb 2017 02:28:17 +1100 (AEDT) Received: from localhost ([::1]:47334 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ceNyg-0006Jm-KW for incoming@patchwork.ozlabs.org; Thu, 16 Feb 2017 10:28:14 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53812) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ceNCm-0000iw-D4 for qemu-devel@nongnu.org; Thu, 16 Feb 2017 09:38:46 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ceNCh-0002M7-O9 for qemu-devel@nongnu.org; Thu, 16 Feb 2017 09:38:44 -0500 Received: from mout.kundenserver.de ([212.227.17.24]:65068) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ceNCh-0002LZ-D9 for qemu-devel@nongnu.org; Thu, 16 Feb 2017 09:38:39 -0500 Received: from localhost.localdomain ([78.238.229.36]) by mrelayeu.kundenserver.de (mreue101 [212.227.15.183]) with ESMTPSA (Nemesis) id 0M9Gfu-1cXBev2uYY-00CgZo; Thu, 16 Feb 2017 15:38:27 +0100 From: Laurent Vivier To: qemu-devel@nongnu.org Date: Thu, 16 Feb 2017 15:38:14 +0100 Message-Id: <20170216143816.2384-13-laurent@vivier.eu> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20170216143816.2384-1-laurent@vivier.eu> References: <20170216143816.2384-1-laurent@vivier.eu> X-Provags-ID: V03:K0:2pXJsbCPLc9IYuzR+6Aqf8wXoO9GmGwYXUxM4zGthXK8D5Xxu6r xruMfVWUFtUqTFsEAlr7f64nrONilEo8Nc7OTsIjUoyZi3LD6ArfYgFb6NM2R6yVQ3KednE gpzZYnWzEgJXiNqBIDXj9inJkO8Exno/mz6OVB4pmNy86qYPfc/sLlbCvZmXQabEdHa5FH4 JJvSRCdiNR8UdZiA3/Lnw== X-UI-Out-Filterresults: notjunk:1; V01:K0:S5qlGvYOk4s=:0yRBNUEea7KU52mNSOGWQ5 tFqYXz+eTzBuhtffw1wigkrqnRuK2/7YF5j0GxP/WPgHU0fiFan47xpb7bGQfkheE44kEOstd RNNzS3ZOTYc52yjzKN4+YRxPMOuieLJfGjaNM8nSqunTzlW/cSOPA/8/B2V6sEtFk+dRsmaaG EkAL++VdqeVkxy52TcyRrBvnPw2DOMQAiqXl9bpO685oLUfO/iaQk9JTPLsOTNGdk4N8P3r6S 7gENAFdQQ85PMY0sDDYpMyBCTQEikApD/kJML9jip6gfrn+Y99iESA+5jdQ2N3PboQkiCXoXY PZy0d43tX2/K3uxhYTILlidkF/lK3vW2LVnBK55SQdi2i93uq3GgdLpvllauO7/4gOuf/Imie P1m2lsXLg+wzLFMfXEDjMmkEEtL4BI7R5O+zqMwWB71bKWhVEPXP/Hn82s9X2PcaIsueMsYV2 hlCLivFOn18XAUvsplwwHYnzQggDV7Gnb2GJff7lCM3QCxPY1COcMzAGE71C2xoKHeLEmXr4o JceSe+BfPTlHlYxINIhTFxBktKPBPSMKA+5jEysF/WP1D2GunpUNHEAJYconpyjjuwjokAw1x bMWEfbhwOwqGZwj/itR3fAUzGaivEDxVJRURpBUSmw0rnn0tR99NeZfv3dUUN/o15Iu5obEwb YqyHBCG6mMYPKBbuHwovMYUSNomORBj4P3uEsGDwdWW70cD66Uo4XGCdgawS/CgfS2Wg= X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 212.227.17.24 Subject: [Qemu-devel] [PULL v2 12/14] linux-user: fill target sigcontext struct accordingly 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: Riku Voipio , Jose Ricardo Ziviani , Laurent Vivier Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Jose Ricardo Ziviani A segfault is noticed when an emulated program uses any of ucontext regs fields. Risu detected this issue in the following operation when handling a signal: ucontext_t *uc = (ucontext_t*)uc; uc->uc_mcontext.regs->nip += 4; but this works fine: uc->uc_mcontext.gp_regs[PT_NIP] += 4; This patch set regs to a valid location as well as other sigcontext fields. Signed-off-by: Jose Ricardo Ziviani Reviewed-by: Laurent Vivier Message-Id: <1485900317-3256-1-git-send-email-joserz@linux.vnet.ibm.com> Signed-off-by: Laurent Vivier --- linux-user/signal.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/linux-user/signal.c b/linux-user/signal.c index 5064de0..8209539 100644 --- a/linux-user/signal.c +++ b/linux-user/signal.c @@ -5155,6 +5155,7 @@ static void setup_rt_frame(int sig, struct target_sigaction *ka, target_ulong rt_sf_addr, newsp = 0; int i, err = 0; #if defined(TARGET_PPC64) + struct target_sigcontext *sc = 0; struct image_info *image = ((TaskState *)thread_cpu->opaque)->info; #endif @@ -5183,6 +5184,10 @@ static void setup_rt_frame(int sig, struct target_sigaction *ka, #if defined(TARGET_PPC64) mctx = &rt_sf->uc.tuc_sigcontext.mcontext; trampptr = &rt_sf->trampoline[0]; + + sc = &rt_sf->uc.tuc_sigcontext; + __put_user(h2g(mctx), &sc->regs); + __put_user(sig, &sc->signal); #else mctx = &rt_sf->uc.tuc_mcontext; trampptr = (uint32_t *)&rt_sf->uc.tuc_mcontext.tramp;