All of lore.kernel.org
 help / color / mirror / Atom feed
From: u.kleine-koenig@pengutronix.de (Uwe Kleine-König)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH] ARM: fix v7-M signal return
Date: Sat, 3 May 2014 20:45:12 +0200	[thread overview]
Message-ID: <20140503184512.GO28564@pengutronix.de> (raw)
In-Reply-To: <20140503173903.GA16300@debian>

Hello Rabin,

On Sat, May 03, 2014 at 07:39:03PM +0200, Rabin Vincent wrote:
> On Mon, Apr 28, 2014 at 10:27:57AM +0200, Uwe Kleine-K?nig wrote:
> > This is a valid fix, but it seems on my efm32 the unpredictable
> > behaviour is to just discard the LSB. How did you find that? Is it an
> > issue on your machine? Which cpu are you using?
> 
> 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.

> > I'd like to have the instruction clearing the thumb bit above the
> > comment about the basic exception frame and please add a comment for
> > your instruction, too.
> 
> OK, here is a v2 with those changes:
> 
> 8<------------------
> From 4aa76f95a6ecf781eec89dba8a3884e5e4339182 Mon Sep 17 00:00:00 2001
> From: Rabin Vincent <rabin@rab.in>
> Date: Sat, 3 May 2014 19:27:09 +0200
> Subject: [PATCHv2] 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 <rabin@rab.in>
> ---
>  arch/arm/kernel/entry-header.S | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/arch/arm/kernel/entry-header.S b/arch/arm/kernel/entry-header.S
> index 1420725..743dff6 100644
> --- a/arch/arm/kernel/entry-header.S
> +++ b/arch/arm/kernel/entry-header.S
> @@ -132,6 +132,9 @@
>  	orrne	r5, V7M_xPSR_FRAMEPTRALIGN
>  	biceq	r5, V7M_xPSR_FRAMEPTRALIGN
>  
> +	@ 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.

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.

Best regards
Uwe

-- 
Pengutronix e.K.                           | Uwe Kleine-K?nig            |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |

  reply	other threads:[~2014-05-03 18:45 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-04-21 18:07 [PATCH] ARM: fix v7-M signal return Rabin Vincent
2014-04-28  8:27 ` Uwe Kleine-König
2014-05-03 17:39   ` Rabin Vincent
2014-05-03 18:45     ` Uwe Kleine-König [this message]
2014-05-04 15:36       ` Rabin Vincent
2014-05-05 13:28         ` Uwe Kleine-König

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20140503184512.GO28564@pengutronix.de \
    --to=u.kleine-koenig@pengutronix.de \
    --cc=linux-arm-kernel@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.