<https://www.gnu.org/licenses/>. */
#include <ldsodefs.h>
+#include <sys/auxv.h>
+
+/* Make glibc MTE-safe on a system that supports MTE in case user code
+ enables tag checks independently of the mte_status of glibc. There
+ is currently no ABI contract for enabling tag checks in user code,
+ but this can be useful for debugging with MTE. */
+#define MTE_ENABLED() (GLRO(dl_hwcap2) & HWCAP2_MTE)
#define INIT_ARCH() \
uint64_t __attribute__((unused)) midr = \
GLRO(dl_aarch64_cpu_features).midr_el1; \
unsigned __attribute__((unused)) zva_size = \
- GLRO(dl_aarch64_cpu_features).zva_size;
+ GLRO(dl_aarch64_cpu_features).zva_size; \
+ bool __attribute__((unused)) mte = \
+ MTE_ENABLED ();
# include <string.h>
# include <init-arch.h>
-/* This should check HWCAP2_MTE when it is available: current
- linux kernel does not expose it, but its value is reserved.
- This is needed to make glibc MTE-safe on future systems in
- case user code enables MTE. The ABI contract for enabling
- MTE is not yet specified, but it can be useful for at least
- debugging which does not need a contract. */
-#define FUTURE_HWCAP2_MTE (1 << 18)
-#define MTE_ENABLED() (GLRO(dl_hwcap2) & FUTURE_HWCAP2_MTE)
-
extern __typeof (__redirect_strlen) __strlen;
extern __typeof (__redirect_strlen) __strlen_mte attribute_hidden;
extern __typeof (__redirect_strlen) __strlen_asimd attribute_hidden;
-libc_ifunc (__strlen, (MTE_ENABLED () ? __strlen_mte : __strlen_asimd));
+libc_ifunc (__strlen, (mte ? __strlen_mte : __strlen_asimd));
# undef strlen
strong_alias (__strlen, strlen);