From patchwork Thu Jul 6 00:23:55 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 9827373 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 DC626602BD for ; Thu, 6 Jul 2017 00:32:40 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 681B92856C for ; Thu, 6 Jul 2017 00:32:22 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5C7F128541; Thu, 6 Jul 2017 00:32:22 +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.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, 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 0239028541 for ; Thu, 6 Jul 2017 00:32:21 +0000 (UTC) Received: from localhost ([::1]:48658 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dSuiT-0005EB-3h for patchwork-qemu-devel@patchwork.kernel.org; Wed, 05 Jul 2017 20:32:21 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59715) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dSub0-0007X1-UF for qemu-devel@nongnu.org; Wed, 05 Jul 2017 20:24:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dSub0-0002QD-1j for qemu-devel@nongnu.org; Wed, 05 Jul 2017 20:24:38 -0400 Received: from mail-qk0-x242.google.com ([2607:f8b0:400d:c09::242]:35763) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dSuaz-0002Q9-UJ for qemu-devel@nongnu.org; Wed, 05 Jul 2017 20:24:37 -0400 Received: by mail-qk0-x242.google.com with SMTP id 16so647437qkg.2 for ; Wed, 05 Jul 2017 17:24:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=s+oYQy25aXT5Zzsl2mzTcm8EwPd5P/rkdD6RntgzB8I=; b=ng7JNASdj//vlISQwAW/dSmJGlliKC98GfS3F0r0HnYtmMuthw+TDB9210HILU+Rm/ cPWPb6Vv5TAO5IbgW3pn5SXK1eAKcQv5JF+qHN81BwsXGbaR317jS1gTPKgpNEXadi3H XsaBrBO/K5Gh+P24lP59aZ45NxlgKOw+K9285VFeImpTP1EvOfAtAStbJXTNHtyTu8Ra +TtWXss8A4Z3bsQDQqvDbZJRskyVoJQ0Mxwcmj2S27tf/lJjAOd4ZopCtTJXZDiHzfuW pAN1Sb5x540twxYcpO+KB0T2Q5JS5CdayunSSgTVanktgvQPDxKHXsS0B6uvDCMXTzPr lBiw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=s+oYQy25aXT5Zzsl2mzTcm8EwPd5P/rkdD6RntgzB8I=; b=M1ppYpfvytTFUt1Dt0N1+cpDJ3Za3hnVGIqmqR14U4XY4WVYVtpkdURl1OYuX1UHg/ RwSKV3CYyv6djarWH2D4yMU5GjTf9Mg3ucImz4WO/TaVN5tgCd/KNZhyvyigQj+xr+zu PLz9aMyiJhuKmOVJfKwoWDy4JH4w+sIpEjPGqKC8MuiliXB4D4Ynr1gLy4m77JeO+D7D v1zDjvXm6wTC1N+qHkJBXqPdqVtcPQMORnCVRdWeeyx7XEIXs+pPQvnHetUP6d1WWN2w 8lKTCeKXAeLYHaky4Sq+4qvgW3Ctl/N0x2GantxwgKdhm8BW5DmMzKqE+uG/A4lBBTst WikA== X-Gm-Message-State: AIVw110Ipuylj89XczeqDhNQiNEQp+kSYVy4++kYWoVegv0NrRogPDUt SD4F33lVaIgmyFT2kCY= X-Received: by 10.55.21.135 with SMTP id 7mr10117888qkv.52.1499300677167; Wed, 05 Jul 2017 17:24:37 -0700 (PDT) Received: from bigtime.twiddle.net.com (rrcs-66-91-136-156.west.biz.rr.com. [66.91.136.156]) by smtp.gmail.com with ESMTPSA id u85sm371825qku.42.2017.07.05.17.24.34 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 05 Jul 2017 17:24:36 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Wed, 5 Jul 2017 14:23:55 -1000 Message-Id: <20170706002401.10507-6-rth@twiddle.net> X-Mailer: git-send-email 2.9.4 In-Reply-To: <20170706002401.10507-1-rth@twiddle.net> References: <20170706002401.10507-1-rth@twiddle.net> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400d:c09::242 Subject: [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+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP 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 Reviewed-by: Laurent Vivier --- 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) { + /* Reset the PC to before the gUSA region, as computed from + R0 = region end, SP = -(region size), plus one more insn + that actually sets SP to the region size. */ + regs->pc = regs->gregs[0] + regs->gregs[15] - 2; + + /* Reset the SP to the saved version in R1. */ + regs->gregs[15] = regs->gregs[1]; + } +} + static void setup_sigcontext(struct target_sigcontext *sc, CPUSH4State *regs, unsigned long mask) { @@ -3534,6 +3551,8 @@ static void setup_frame(int sig, struct target_sigaction *ka, abi_ulong frame_addr; int i; + unwind_gusa(regs); + frame_addr = get_sigframe(ka, regs->gregs[15], sizeof(*frame)); trace_user_setup_frame(regs, frame_addr); if (!lock_user_struct(VERIFY_WRITE, frame, frame_addr, 0)) { @@ -3583,6 +3602,8 @@ static void setup_rt_frame(int sig, struct target_sigaction *ka, abi_ulong frame_addr; int i; + unwind_gusa(regs); + frame_addr = get_sigframe(ka, regs->gregs[15], sizeof(*frame)); trace_user_setup_rt_frame(regs, frame_addr); if (!lock_user_struct(VERIFY_WRITE, frame, frame_addr, 0)) {