[PATCH] ARM: Add SWP/SWPB emulation for ARMv7 processors (v2)

Leif Lindholm leif.lindholm at arm.com
Tue Jan 5 13:09:39 EST 2010


> From: Jamie Lokier [mailto:jamie at shareable.org]
> Sent: 04 January 2010 19:34

> There is no need to return to userspace, as you know that userspace
> will immediately retry the instruction, or respond to a signal.
> 
> So you can loop, as long as you:
> 
>    1. Allow other tasks to run by calling cond_resched().
>    2. Break out of the loop if signal_pending().

Thanks for these suggestions - I will be posting an updated patch that does
this shortly.
 
> If someone executes SWP on uncached or device memory and it's not an
> intentional DOS (e.g. worked with older ARMs), they won't expect the
> instruction to loop at that point.

True, but difficult to solve in a clean way (see below).

> Faulting would be better. Is it feasible to detect when this has
> happened and send a SIGBUS signal instead of looping?

Only if the processor implements it (the AXI spec explicitly permits a
processor to treat an OKAY response, as opposed to EXOKAY, as an error -
but it doesn't mandate it). I am not aware of any ARM processors that do
this. Otherwise that would certainly be the best solution.

Of course this means that if we want to "detect" an impossible situation
in order to generate an abort, we need to resort to counters, and
determining an arbitrary "highest possible" number of valid sequential
failures...

/
    Leif





More information about the linux-arm-kernel mailing list