[PATCH 03/11] Thumb-2: Implementation of the unified start-up and exceptions code

Russell King - ARM Linux linux at arm.linux.org.uk
Fri Mar 12 16:16:14 EST 2010


On Fri, Mar 12, 2010 at 06:30:36PM +0100, Anders Grafström wrote:
> This commit seems to have broken things for ARM720T and it looks like
> the removal of the "mov r0, r0" instruction in restore_user_regs is
> what caused it.
> 
> The patch below makes it work again but why?

Because the 'add' instruction will end up touching the _userspace_
stack pointer, not the SVC stack pointer.

It's a question of timing in the core - the ldmdb instruction accesses
the user sp+lr, which is still in progress when the following instruction
is executed.  So, referencing 'sp' in the following instruction ends up
hitting the user mode stack pointer.

I'm surprised this hasn't caused more problems - there is a stipulated
requirement that banked registers are _NOT_ accessed by the instruction
following a ldm { }^ instruction - this requirement goes all the way up
to V5T as defined by DDI0100I and below:

  In ARM architecture versions earlier than ARMv6, this form of LDM must
  not be followed by an instruction that accesses banked registers. A
  following NOP is a good way to ensure this.

So yes, your patch is absolutely required - all ARMv5 and below are
facing a hazard as the kernel stands.  It might explain some of the
weird behaviours people have been reporting as well.

Please cleanup the description and submit to the patch system.



More information about the linux-arm-kernel mailing list