From patchwork Fri Jul 7 17:57:36 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 9830979 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 994E260317 for ; Fri, 7 Jul 2017 18:31:46 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 94B4428397 for ; Fri, 7 Jul 2017 18:31:46 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 890C628506; Fri, 7 Jul 2017 18:31:46 +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 063B728397 for ; Fri, 7 Jul 2017 18:31:46 +0000 (UTC) Received: from localhost ([::1]:58222 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dTY2b-0002Kp-5I for patchwork-qemu-devel@patchwork.kernel.org; Fri, 07 Jul 2017 14:31:45 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34466) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dTXVb-0006Iv-FF for qemu-devel@nongnu.org; Fri, 07 Jul 2017 13:57:40 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dTXVa-0002ah-AB for qemu-devel@nongnu.org; Fri, 07 Jul 2017 13:57:39 -0400 Received: from mail-oi0-x236.google.com ([2607:f8b0:4003:c06::236]:35396) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dTXVa-0002Ze-2F for qemu-devel@nongnu.org; Fri, 07 Jul 2017 13:57:38 -0400 Received: by mail-oi0-x236.google.com with SMTP id 191so33791730oii.2 for ; Fri, 07 Jul 2017 10:57:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to; bh=AMhY+vFaws2fYFLL2JKnguPFJL0ySwz0K09AnPmEhxs=; b=q1687zMR8x5O0VZ9Em9UWQ8r8doHszgSxvgkrfvaRetin9SJG+FHEH07tsmjm7frbF ZRnmiXVOBJ7G9ybz7FwSDX0lTmBhA82XrDNk9lrSHzdc8eNEbicIymBQ3Z7a0DOdttuY RzmT/QZ1QTgBir02CuHPzCTSaxl663q8ZDj9Tiw1NM8HhlCZ8fM6AuKl1MB//+XNThRe ulPgYnnNw8Hbh3KXlITW2Pw1TEYNG/QZNaYHU4PVkZalehl8lYXNVY400fmUDJO8G5X7 iQJn6eMSDMxT0yeUDchtSXnPKh7VEPzD5ff7xHWZ2JxAp6R6nT6r3VMlgNTGk52heYcx 2XaQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:sender:in-reply-to:references:from :date:message-id:subject:to; bh=AMhY+vFaws2fYFLL2JKnguPFJL0ySwz0K09AnPmEhxs=; b=HfIvI0ZdsQx1W+HqJTaOzwJN3riG6eiTaujDPVEzNZk5CPIelbiBDMpvmjy9k0jCDU GXDXwL92L3Qrnsf304R0S1VGmckJKAVCIBYQ7nenrAMLOgR30lX6DZssdN7xaB9SWTkL xwjWBc7bg0+9cnvP4r6/RXLJhWbWMaA8RbI2auHJqOcoKHTJ8danax3EPq8d0qrC9KZh YMll3KpnObD+sAuwyURR7b1NDg3EeNmQZJwzbsGDSnNImhs9CuyVW+lk/aU9A1oeWDNr 4rV+inoRzwDMpHp9Qvhv/ZoKHFodB7xUXgMUfcjtSf8Dlamgx4e+3HOA8jIdmcTjAdsF fEXg== X-Gm-Message-State: AIVw1107uetP/aRN8kHKfOGbo8rqbfcHfQmrjkMuspzRQFYz1alAW09o JuH0H7bMs+UDNrSrdFAcLPtPJV9xIRxI X-Received: by 10.202.89.10 with SMTP id n10mr1265016oib.95.1499450256644; Fri, 07 Jul 2017 10:57:36 -0700 (PDT) MIME-Version: 1.0 Received: by 10.182.55.37 with HTTP; Fri, 7 Jul 2017 10:57:36 -0700 (PDT) In-Reply-To: <20170707163826.22631-1-rth@twiddle.net> References: <3349c01e-1f1a-2111-28c2-70fb5cc077cd@physik.fu-berlin.de> <20170707163826.22631-1-rth@twiddle.net> From: Richard Henderson Date: Fri, 7 Jul 2017 07:57:36 -1000 X-Google-Sender-Auth: 7lqMxECtVCWgK2RTpLiyjnVDFIg Message-ID: To: qemu-devel X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4003:c06::236 X-Content-Filtered-By: Mailman/MimeDel 2.1.21 Subject: [Qemu-devel] Fwd: [PATCH v2.5] fixup! 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: , Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Bah. Should have gone to the list as well. r~ ---------- Forwarded message ---------- From: Richard Henderson Date: Fri, Jul 7, 2017 at 6:38 AM Subject: [PATCH v2.5] fixup! linux-user/sh4: Notice gUSA regions during signal delivery To: glaubitz@physik.fu-berlin.de Cc: laurent@vivier.eu This fixes the signal delivery problem reported. I'll fold this into the patch properly for v3, but this will allow reasonable testing to proceed in the meantime. r~ --- linux-user/signal.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) /* Reset the SP to the saved version in R1. */ -- 2.9.4 diff --git a/linux-user/signal.c b/linux-user/signal.c index 8c0b851..d68bd26 100644 --- a/linux-user/signal.c +++ b/linux-user/signal.c @@ -3476,13 +3476,18 @@ static abi_ulong get_sigframe(struct target_sigaction *ka, 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 - /* ... and we haven't completed the sequence ... */ - && regs->pc < regs->gregs[0]) { + /* If the stack pointer is sufficiently negative, and we haven't + completed the sequence, then reset to the entry to the region. */ + /* ??? The SH4 kernel checks for and address above 0xC0000000. + However, the page mappings in qemu linux-user aren't as restricted + and we wind up with the normal stack mapped above 0xF0000000. + That said, there is no reason why the kernel should be allowing + a gUSA region that spans 1GB. Use a tighter check here, for what + can actually be enabled by the immediate move. */ + if (regs->gregs[15] >= -128u && 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 - that actually sets SP to the region size. */ + R0 = region end, SP = -(region size), plus one more for the + insn that actually initializes SP to the region size. */ regs->pc = regs->gregs[0] + regs->gregs[15] - 2;