On Sun, Mar 20, 2016 at 06:47:04PM +0100, Thomas Petazzoni wrote:
Hello,
Thanks for your feedback!
On Sun, 20 Mar 2016 13:40:40 -0400, Rich Felker wrote:
On Sun, Mar 20, 2016 at 05:58:35PM +0100, Thomas Petazzoni wrote:
Currently, the Thumb support on ARM has three related Config.in options, which are not trivial for users to understand, and are in fact not needed:
- The USE_BX option is not needed: knowing whether BX is available or not is easy. If you have an ARM > v4 or ARMv4T, then BX is available, otherwise it's not. This is the logic used in glibc.
This sounds correct.
- The USE_LDREXSTREX option is not needed: whenever Thumb2 is available, ldrex/strex are available, so we can simply rely on __thumb2__ to determine whether ldrex/strex should be used, without requiring a Config.in option.
__thumb2__ is sufficient for ldrex/strex but not sufficient; v6 has them in the arm isa.
I'm not sure what you mean between:
(1) ldrex/strex are also available on plain ARMv6 (i.e not Thumb2).
(2) ldrex/strex are not available on ARMv6, while some ARMv6 support Thumb2.
(1) is what I mean.
If you mean (1), then before my patch, the ldrex/strex code was only enabled when USE_LDREXSTREX was enabled, and this option had a "depends on COMPILE_IN_THUMB". Hence my patch doesn't change the fact that the ldrex/strex logic is only used on Thumb. Whether it can/should be enabled in non-Thumb configurations is a separate matter from what my patch is doing.
OK, then the logic was wrong before, too. :-)
If you mean (2), then there is indeed a problem. Though, according to http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.faqs/14979.html, "On a v6 or later core (ARM11 onwards) you should use the LDREX/STREX instructions instead", which would suggest that such instructions are available.
Indeed, and it's further complicated by the fact that none of these instructions are proper memory barriers so they're basically useless without a separate barrier instruction, which does not exist on pre-v6, and on v6, only as a coprocessor operation that's not available in thumb1 or on uc models. Not until v7 did arm have proper working atomics. :(
Rich