From patchwork Sun May 4 15:36:18 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Rabin Vincent X-Patchwork-Id: 4107761 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 04065BFF02 for ; Sun, 4 May 2014 15:39:00 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 25217203F7 for ; Sun, 4 May 2014 15:38:59 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id B1473203EC for ; Sun, 4 May 2014 15:38:57 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1WgyTC-0003h9-CF; Sun, 04 May 2014 15:36:50 +0000 Received: from mail-lb0-x231.google.com ([2a00:1450:4010:c04::231]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1WgyTA-0003dw-8P for linux-arm-kernel@lists.infradead.org; Sun, 04 May 2014 15:36:48 +0000 Received: by mail-lb0-f177.google.com with SMTP id z11so4479329lbi.8 for ; Sun, 04 May 2014 08:36:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:date:from:to:cc:subject:message-id:references:mime-version :content-type:content-disposition:content-transfer-encoding :in-reply-to:user-agent; bh=9G8xHZajgQkmaO4BscJSy7/rC0/Tw3KxFyx3EN8AM0A=; b=xcjwGzNwWDI5rTnn6+3Z7KxIyM6I0CMsaU5DUdTTHp/U2I/nBwDaDg5PhQUolsmQse qQwVVHndV24DSiSdbwiaoSYZ02alyFPIuZ9SYXW0f7pSTggr4xo+qcB56nYlamz1XpE5 BlSJ6IsSs8oTqir8QhJyLZPdk6qYGovKWq/B7HWqYdK6gMuOwPZ0QUXdYQH7FutZSQEL i7CsyZot7a9sGGvVWku9D1s6qF3MLwPSz/SG18Y+YtB3+dgwvuOeXCEDZyZf7DzYPZ3o 3d5uPKz0rTlUPF/NepQbt6h3b06Y5snkgrW02pW7vEb559bUE4J269s0GiRk7Dd+vM4u retQ== X-Received: by 10.152.6.194 with SMTP id d2mr919008laa.54.1399217785095; Sun, 04 May 2014 08:36:25 -0700 (PDT) Received: from debian (217-211-190-200-no39.tbcn.telia.com. [217.211.190.200]) by mx.google.com with ESMTPSA id r8sm5419184laj.11.2014.05.04.08.36.23 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Sun, 04 May 2014 08:36:24 -0700 (PDT) Date: Sun, 4 May 2014 17:36:18 +0200 From: Rabin Vincent To: Uwe =?iso-8859-1?Q?Kleine-K=F6nig?= Subject: Re: [PATCH] ARM: fix v7-M signal return Message-ID: <20140504153618.GA3795@debian> References: <1398103664-23078-1-git-send-email-rabin@rab.in> <20140428082757.GD28564@pengutronix.de> <20140503173903.GA16300@debian> <20140503184512.GO28564@pengutronix.de> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20140503184512.GO28564@pengutronix.de> User-Agent: Mutt/1.5.23 (2014-03-12) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140504_083648_483144_483A1D0E X-CRM114-Status: GOOD ( 21.05 ) X-Spam-Score: 0.0 (/) Cc: Catalin Marinas , linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-2.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP On Sat, May 03, 2014 at 08:45:12PM +0200, Uwe Kleine-König wrote: > On Sat, May 03, 2014 at 07:39:03PM +0200, Rabin Vincent wrote: > > I'm running this on QEMU. Here is an old qemu-devel thread on this > > topic if you are interested: > > http://lists.gnu.org/archive/html/qemu-devel/2012-03/msg00158.html > I'm interested in your setup and (if applicable) additional kernel > patches. No kernel patches are needed other than the ones I already posted. My QEMU patches for EFM32 support are needed. I put together a small README here: https://github.com/rabinv/qemu-efm32-tools > > + @ ensure bit 0 is cleared in the PC > Maybe add: , otherwise behaviour is unpredictable > > > + bic r4, r4, #1 > I just notice that the coding style is inconsitent here, the > instructions above don't repeat the dest register. Can you please make > this "bic r4, #1", too? > > With these two changes you can have my ack. v3 below. > What happens on qemu without this fix? If it crashes I'd suggest to get > this patch into 3.15 with a stable annotation. If not I think 3.16-rc1 > is enough. User space processes crash because qemu's emulation of the CPU does not discard the zero bit. 8<-------------------- From 577b0c0e15057f58f86996da7f363c8a608c389f Mon Sep 17 00:00:00 2001 From: Rabin Vincent Date: Sat, 3 May 2014 19:27:09 +0200 Subject: [PATCHv3] ARM: fix v7-M signal return According to the ARM ARM, the behaviour is UNDPREDICTABLE if the PC read from the exception return stack is not half word aligned. See the pseudo code for ExceptionReturn() and PopStack(). The signal handler's address has the bit 0 set, and setup_return() directly writes this to regs->ARM_pc. Mask out bit 0 before the exception return to get predictable behaviour. Signed-off-by: Rabin Vincent Acked-by: Uwe Kleine-König --- arch/arm/kernel/entry-header.S | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/arch/arm/kernel/entry-header.S b/arch/arm/kernel/entry-header.S index 1420725..efb208d 100644 --- a/arch/arm/kernel/entry-header.S +++ b/arch/arm/kernel/entry-header.S @@ -132,6 +132,10 @@ orrne r5, V7M_xPSR_FRAMEPTRALIGN biceq r5, V7M_xPSR_FRAMEPTRALIGN + @ ensure bit 0 is cleared in the PC, otherwise behaviour is + @ unpredictable + bic r4, #1 + @ write basic exception frame stmdb r2!, {r1, r3-r5} ldmia sp, {r1, r3-r5}