dynamic CPU detection for libgcrypt assembly code?

Jussi Kivilinna jussi.kivilinna at iki.fi
Fri Dec 20 20:06:28 CET 2013


On 20.12.2013 18:09, Hans-Christoph Steiner wrote:
> 
> 
> On 12/20/2013 10:04 AM, Jussi Kivilinna wrote:
>> On 20.12.2013 16:44, Hans-Christoph Steiner wrote:
>>>
>>> Hey,
>>>
>>> Its great to see all that work being done adding assembly optimizations to
>>> libgcrypt, it should make a really big difference on mobile devices.  My
>>> question is whether there is any kind of dynamic CPU detection that would
>>> enable certain modules, like ARM NEON code?  We'd like to include the NEON
>>> code, but if the same binary won't work on armv7 chips that don't have NEON,
>>> then its a showstopper for us.
>>
>> Libgcrypt has HW detection modules for x86 and ARM. On x86, cpuid instruction
>> is used to detect CPU features. On ARM, detection is platform dependent since
>> there is no cpuid instruction; with linux/arm platform NEON detection is done through '/proc/self/auxv':AT_HWCAP. On non-linux/arm platform, NEON implementations can be enabled by compiling binary for ARMv7/NEON (libgcrypt notices that compiler has __ARM_NEON__ macro predefined).
> 
> So Android is Linux but not GNU or UNIX.  Sounds like /proc/self/auxv should
> work for Android then, in my quick survey of one Android device, it does have
> /proc/self/auxv.

Well, after little bit of research, I found out that Android blocks read access
to /proc/self/auxv. Instead there is another API for cpu features:
  http://www.kandroid.org/ndk/docs/CPU-ARM-NEON.html

For proper NEON support on Android, libgcrypt should use this API for arm hw
detection.

-Jussi

> 
> .hc
> 




More information about the Gnupg-devel mailing list