From patchwork Thu Jul 6 12:09:36 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 785137 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 3x3GmL2grhz9s72 for ; Thu, 6 Jul 2017 22:10:58 +1000 (AEST) Received: from localhost ([::1]:51157 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dT5cV-0005YM-1M for incoming@patchwork.ozlabs.org; Thu, 06 Jul 2017 08:10:55 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35835) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dT5bd-0005QQ-IL for qemu-devel@nongnu.org; Thu, 06 Jul 2017 08:10:07 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dT5bZ-0004hJ-I2 for qemu-devel@nongnu.org; Thu, 06 Jul 2017 08:10:01 -0400 Received: from mout.kundenserver.de ([212.227.126.131]:58574) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dT5bZ-0004gs-6O for qemu-devel@nongnu.org; Thu, 06 Jul 2017 08:09:57 -0400 Received: from [192.168.100.1] ([78.238.229.36]) by mrelayeu.kundenserver.de (mreue003 [212.227.15.167]) with ESMTPSA (Nemesis) id 0MOELI-1dNbxX1U6m-005cuB; Thu, 06 Jul 2017 14:09:39 +0200 To: Richard Henderson , qemu-devel@nongnu.org References: <20170706002401.10507-1-rth@twiddle.net> <20170706002401.10507-6-rth@twiddle.net> From: Laurent Vivier Message-ID: <4574d0f3-8f2d-206e-475a-57404b7892dd@vivier.eu> Date: Thu, 6 Jul 2017 14:09:36 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.1.0 MIME-Version: 1.0 In-Reply-To: <20170706002401.10507-6-rth@twiddle.net> Content-Language: en-US X-Provags-ID: V03:K0:rPbgJyeCrTcpv4RFSMYHkBGH7g19ClZac456MlfX59kHDmGasxX GdG9cySR3i6bNAPhXHTrkAUMZv3qfZfvkUIpl93ljJLY0HNWkSK5WTOoAd5Bvnwk9pffqxk l/KSg0vwWQxiQMF2wcjr4GU546leanub+AonwO8LAoVTIr8TgNHhYK9/5h+HteBzJlq+XSK DZ5AtQNpNTda0uOA4dRmw== X-UI-Out-Filterresults: notjunk:1; V01:K0:ffvqmRXRRkk=:fvOI/2zf0Nt+3OJ8VI4g8S mCucZ4COM+JmQ98xuPZBtV6Kt8mvKT1Pavoq1Wv8rlMViAJxCg8UBLM4jK7Lt8CnSFqaUbC+Y GycdDiS6T9xaOpg4xJpAzsA5JQ/Tk/CF+4S6CIYcTpAZKhrxMqU70bva9jSAWJTkpxOR7nKOV kiUyHc+QxvMIiMLr+stke7c2sbFZdzxblAoLxYr36lt56NFoOAOve4u+wHQbi0BXggOxcsLjq RcUYTfzFyTBZNKG8qGDebxwWjU/X3084mhNQhhOnJVAN1MytxppDbixqUCfsScJ8bmUkmfDBA R9vf64n+0qevIzyeb13ldgUS3XJ9GoIFLoU3GrUnOg/sBTEFppy+5aNDMYoxixdk+C1wi1Ioo rCUw20UyGy+SZi3fgDww+vPuKsY0xwj/hE832C/XK4Vx9fspcD7Su463wN76kTuPGtveSV6Yh HMAP03pct2k8QxqhW5TFhFTEMTDSlFKu/Q2JmGtCorMwL8aBwbXTNp0udpTHP0jlg8ri3rxhg eDAMUl65mqZCOZ7GnxBFLleP/KLMCy3fLe86RiKoZrD7OwXfgBs36LF2+GQcasj4tDSUFTR/S 4JyrKI6dcg12jCMb0jYe0rgtRR8SEKgVe1kYGOqJRmPSs+F0pWSygIN0Go9CrMb73+PtBAs5M G0B6w+N3Lm1zVGpn9ew5sKKjafhjXEk/hhBPTgPgeZN0f6VRbJAvyVcNf6OliKjJrZiweE1Hn 4v/YEuBiKKMnktFi X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 212.227.126.131 Subject: Re: [Qemu-devel] [PATCH 05/11] linux-user/sh4: Notice gUSA regions during signal delivery 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: bruno@clisp.org, aurelien@aurel32.net Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Le 06/07/2017 à 02:23, Richard Henderson a écrit : > We translate gUSA regions atomically in a parallel context. > But in a serial context a gUSA region may be interrupted. > In that case, restart the region as the kernel would. > > Signed-off-by: Richard Henderson > --- > linux-user/signal.c | 21 +++++++++++++++++++++ > 1 file changed, 21 insertions(+) > > diff --git a/linux-user/signal.c b/linux-user/signal.c > index 3d18d1b..1e716a9 100644 > --- a/linux-user/signal.c > +++ b/linux-user/signal.c > @@ -3471,6 +3471,23 @@ static abi_ulong get_sigframe(struct target_sigaction *ka, > return (sp - frame_size) & -8ul; > } > > +/* Notice when we're in the middle of a gUSA region and reset. > + Note that this will only occur for !parallel_cpus, as we will > + translate such sequences differently in a parallel context. */ > +static void unwind_gusa(CPUSH4State *regs) > +{ > + /* If the stack pointer is sufficiently negative... */ > + if ((regs->gregs[15] & 0xc0000000u) == 0xc0000000u) { kernel also checks PC < gUSA region end point, try this: that actually sets SP to the region size. */ Laurent diff --git a/linux-user/signal.c b/linux-user/signal.c index 1e716a9..4e1e4f0 100644 --- a/linux-user/signal.c +++ b/linux-user/signal.c @@ -3477,7 +3477,8 @@ static abi_ulong get_sigframe(struct target_sigaction *ka, static void unwind_gusa(CPUSH4State *regs) { /* If the stack pointer is sufficiently negative... */ - if ((regs->gregs[15] & 0xc0000000u) == 0xc0000000u) { + if ((regs->gregs[15] & 0xc0000000u) == 0xc0000000u && + regs->pc < regs->gregs[0]) { /* Reset the PC to before the gUSA region, as computed from R0 = region end, SP = -(region size), plus one more insn