From patchwork Thu Feb 16 14:22:25 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 9577305 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 13F7C600F6 for ; Thu, 16 Feb 2017 14:38:44 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F2294285EA for ; Thu, 16 Feb 2017 14:38:43 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E44CB28586; Thu, 16 Feb 2017 14:38:43 +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=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI 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 D110C28586 for ; Thu, 16 Feb 2017 14:38:42 +0000 (UTC) Received: from localhost ([::1]:47058 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ceNCj-00006S-R8 for patchwork-qemu-devel@patchwork.kernel.org; Thu, 16 Feb 2017 09:38:41 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48555) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ceMxT-0002eW-8A for qemu-devel@nongnu.org; Thu, 16 Feb 2017 09:22:56 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ceMxR-0002NF-OX for qemu-devel@nongnu.org; Thu, 16 Feb 2017 09:22:55 -0500 Received: from mout.kundenserver.de ([217.72.192.74]:62026) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ceMxR-0002MT-Db for qemu-devel@nongnu.org; Thu, 16 Feb 2017 09:22:53 -0500 Received: from localhost.localdomain ([78.238.229.36]) by mrelayeu.kundenserver.de (mreue101 [212.227.15.183]) with ESMTPSA (Nemesis) id 0LuMNz-1cD2Ua16WN-011mlr; Thu, 16 Feb 2017 15:22:39 +0100 From: Laurent Vivier To: qemu-devel@nongnu.org Date: Thu, 16 Feb 2017 15:22:25 +0100 Message-Id: <20170216142227.27448-13-laurent@vivier.eu> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20170216142227.27448-1-laurent@vivier.eu> References: <20170216142227.27448-1-laurent@vivier.eu> X-Provags-ID: V03:K0:b3n/dMTXHT9hOAhFTPuscVQ6iwcN813X0mA4mbGD85DUS6O7rT1 TXlnFfdt3PsesMv+h2fM24mt1LPeYSDfpK0tERUhas8nvzVxRpyypultzJ6ko7YwAAZixpV FAwcNS5JKUBxh4jKB9SdEL55jqljfipmf0n7PKUKt5DQelFGn1LiaZOk5pl/rUCsJtTWvkF /9tDU6dwoYX/gciWo9Udg== X-UI-Out-Filterresults: notjunk:1; V01:K0:OX5Fp8lqj8c=:fFNLuJ+KWkesmzY5kA8ZcF juLerwF60T75T/rDmqkxGsr6YJ1KY3Xfa9PlHWPKnl/+5G96f9/NxtiVELo+yaJ7gIMUC9jDX N0HTpEC1T1+eY/W8Q3MSYaWwWavFME9GJMuXQYItU09DYD6YboXV994oo8eDShGH9/TzaOzX8 YSCklGLLhQ7HfAPaOAgiPFflmtt7h6FQ5JGj4tG/LXFio6ndIFRtbl3PEUrC7LQUOVXIxNCnE LRo5/ErHEaYG/wxIfBh7X4+3n4j3PumPIvKZOQfZLPSzrsS8U+rdzFZmhfbRo0fIvTZjBkMhO yfyNaNwuxJD2Nb64FXWyObSmQLPDyuVsMHR2S4qiiGtXA9FW20swBOcOPA+9JT0+KoaMUsckI zKmKkNbQy0aPcim5+hl0MUHwSf2j1Waj4hvVWjMwfHqMIHShA3jPy4cQBveMLdSSHTDW8OhUW XfAvSZ9QNtc2zJdWn2fijQgkLyxxQdN3sVokTJxZiQIog6Oy4SLyzf7D1GkZ26C7MyLVN1YWK 22Z4RKTEPzS1YlBev4fgpUmIWffDyQaZgMAL7bTaIWlUe1PzY4D4IMiFA8QYgCO3speGSVOtE 7c+ghxO9qOz8YgE9rdLGXCWQvr7gs2Zd//RpfeGfp4BYM9djLPIQ+BLzlK1jNADib5xL4Uo26 lxLGs4TZQdacZd4VwwrSAFKBp5xE5OjkvjL6WYqFkgSRWn088eWYdIJWkTjjgtjxLaPM= X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 217.72.192.74 Subject: [Qemu-devel] [PULL 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+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP 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;