Commit 10c198cb authored by Richard Henderson's avatar Richard Henderson
Browse files

arm: Use getauxval for feature detection

In certain minimal chroot /proc is not mounted, but the kernel
always fills in AT_PLATFORM and AT_HWCAP.  Use configure detection
of <sys/auxv.h> instead of magic glibc version testing, as we've
been doing in arm64 and ppc.
parent 5f2512aa
2021-06-03 Richard Henderson <richard.henderson@linaro.org>
* fat-arm.c (get_arm_features_auxv): New.
(get_arm_features): Use it if HAVE_SYS_AUXV_H.
* fat-arm.c (get_arm_features_env, get_arm_features_proc):
Split out of get_arm_features.
......
......@@ -192,6 +192,8 @@ AC_CHECK_HEADERS([openssl/evp.h openssl/ecdsa.h],,
[enable_openssl=no
break])
AC_CHECK_HEADERS([sys/auxv.h])
# For use by the testsuite
AC_CHECK_HEADERS([valgrind/memcheck.h])
AC_CHECK_HEADERS([dlfcn.h])
......
......@@ -39,6 +39,9 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#ifdef HAVE_SYS_AUXV_H
#include <sys/auxv.h>
#endif
#include "nettle-types.h"
......@@ -83,6 +86,25 @@ get_arm_features_env (struct arm_features *features, const char *s)
}
}
#ifdef HAVE_SYS_AUXV_H
static void
get_arm_features_auxv (struct arm_features *features)
{
const char *platform;
unsigned long hwcap;
/* AT_PLATFORM is of the form "v[4-8][lb]". */
platform = (const char *)getauxval(AT_PLATFORM);
if (platform
&& platform[0] == 'v'
&& platform[1] >= '5'
&& platform[1] <= '9')
features->arch_version = platform[1] - '0';
hwcap = getauxval(AT_HWCAP);
features->have_neon = (hwcap & HWCAP_ARM_NEON) != 0;
}
#else
static void
get_arm_features_proc (struct arm_features *features)
{
......@@ -131,6 +153,7 @@ get_arm_features_proc (struct arm_features *features)
}
fclose (f);
}
#endif
static void
get_arm_features (struct arm_features *features)
......@@ -145,7 +168,12 @@ get_arm_features (struct arm_features *features)
get_arm_features_env (features, s);
return;
}
#ifdef HAVE_SYS_AUXV_H
get_arm_features_auxv (features);
#else
get_arm_features_proc (features);
#endif
}
DECLARE_FAT_FUNC(_nettle_aes_encrypt, aes_crypt_internal_func)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment