2017-03-15 23:46:26 +00:00
|
|
|
/* Initialize CPU feature data. AArch64 version.
|
|
|
|
This file is part of the GNU C Library.
|
2024-01-01 18:12:26 +00:00
|
|
|
Copyright (C) 2017-2024 Free Software Foundation, Inc.
|
2017-03-15 23:46:26 +00:00
|
|
|
|
|
|
|
The GNU C Library is free software; you can redistribute it and/or
|
|
|
|
modify it under the terms of the GNU Lesser General Public
|
|
|
|
License as published by the Free Software Foundation; either
|
|
|
|
version 2.1 of the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
The GNU C Library is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
Lesser General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU Lesser General Public
|
|
|
|
License along with the GNU C Library; if not, see
|
Prefer https to http for gnu.org and fsf.org URLs
Also, change sources.redhat.com to sourceware.org.
This patch was automatically generated by running the following shell
script, which uses GNU sed, and which avoids modifying files imported
from upstream:
sed -ri '
s,(http|ftp)(://(.*\.)?(gnu|fsf|sourceware)\.org($|[^.]|\.[^a-z])),https\2,g
s,(http|ftp)(://(.*\.)?)sources\.redhat\.com($|[^.]|\.[^a-z]),https\2sourceware.org\4,g
' \
$(find $(git ls-files) -prune -type f \
! -name '*.po' \
! -name 'ChangeLog*' \
! -path COPYING ! -path COPYING.LIB \
! -path manual/fdl-1.3.texi ! -path manual/lgpl-2.1.texi \
! -path manual/texinfo.tex ! -path scripts/config.guess \
! -path scripts/config.sub ! -path scripts/install-sh \
! -path scripts/mkinstalldirs ! -path scripts/move-if-change \
! -path INSTALL ! -path locale/programs/charmap-kw.h \
! -path po/libc.pot ! -path sysdeps/gnu/errlist.c \
! '(' -name configure \
-execdir test -f configure.ac -o -f configure.in ';' ')' \
! '(' -name preconfigure \
-execdir test -f preconfigure.ac ';' ')' \
-print)
and then by running 'make dist-prepare' to regenerate files built
from the altered files, and then executing the following to cleanup:
chmod a+x sysdeps/unix/sysv/linux/riscv/configure
# Omit irrelevant whitespace and comment-only changes,
# perhaps from a slightly-different Autoconf version.
git checkout -f \
sysdeps/csky/configure \
sysdeps/hppa/configure \
sysdeps/riscv/configure \
sysdeps/unix/sysv/linux/csky/configure
# Omit changes that caused a pre-commit check to fail like this:
# remote: *** error: sysdeps/powerpc/powerpc64/ppc-mcount.S: trailing lines
git checkout -f \
sysdeps/powerpc/powerpc64/ppc-mcount.S \
sysdeps/unix/sysv/linux/s390/s390-64/syscall.S
# Omit change that caused a pre-commit check to fail like this:
# remote: *** error: sysdeps/sparc/sparc64/multiarch/memcpy-ultra3.S: last line does not end in newline
git checkout -f sysdeps/sparc/sparc64/multiarch/memcpy-ultra3.S
2019-09-07 05:40:42 +00:00
|
|
|
<https://www.gnu.org/licenses/>. */
|
2017-03-15 23:46:26 +00:00
|
|
|
|
2023-12-06 13:24:01 +00:00
|
|
|
#include <array_length.h>
|
2017-03-15 23:46:26 +00:00
|
|
|
#include <cpu-features.h>
|
|
|
|
#include <sys/auxv.h>
|
2017-04-25 17:09:17 +00:00
|
|
|
#include <elf/dl-hwcaps.h>
|
2020-12-21 15:03:03 +00:00
|
|
|
#include <sys/prctl.h>
|
2024-03-21 16:48:33 +00:00
|
|
|
#include <sys/utsname.h>
|
2023-12-06 13:24:01 +00:00
|
|
|
#include <dl-tunables-parse.h>
|
2017-03-15 23:46:26 +00:00
|
|
|
|
aarch64: Optimized memset for falkor
The generic memset reads dczid_el0 on every memset. This has a
significant impact on falkor for a range of sizes because reading
dczid_el0 is slow.
The DZP bit in the dczid_el0 register does not change dynamically, so
it is safe to read once during program startup. With this patch
dczid_el0 is read once during startup and zva_size is cached. This is
used to invoke the falkor-specific memset; the generic memset routine
remains unchanged.
The gains due to this are significant for falkor, with run time
reductions as high as 48%. Here's a sample from the falkor tests:
Function: memset
Variant: walk
simple_memset __memset_falkor __memset_generic
=====================================================================
length=256, char=0: 139.96 (-698.28%) 9.07 ( 48.26%) 17.53
length=257, char=0: 140.50 (-699.03%) 9.53 ( 45.80%) 17.58
length=258, char=0: 140.96 (-703.95%) 9.58 ( 45.36%) 17.53
length=259, char=0: 141.56 (-705.16%) 9.53 ( 45.79%) 17.58
length=260, char=0: 142.15 (-710.76%) 9.57 ( 45.39%) 17.53
length=261, char=0: 142.50 (-710.39%) 9.53 ( 45.78%) 17.58
length=262, char=0: 142.97 (-715.09%) 9.57 ( 45.42%) 17.54
length=263, char=0: 143.51 (-716.18%) 9.53 ( 45.80%) 17.58
length=264, char=0: 143.93 (-720.55%) 9.58 ( 45.39%) 17.54
length=265, char=0: 144.56 (-722.07%) 9.53 ( 45.80%) 17.59
length=266, char=0: 144.98 (-726.42%) 9.58 ( 45.42%) 17.54
length=267, char=0: 145.53 (-727.53%) 9.53 ( 45.80%) 17.59
length=268, char=0: 146.25 (-731.81%) 9.53 ( 45.79%) 17.58
length=269, char=0: 146.52 (-735.39%) 9.53 ( 45.66%) 17.54
length=270, char=0: 146.97 (-735.81%) 9.53 ( 45.80%) 17.58
length=271, char=0: 147.54 (-741.08%) 9.58 ( 45.38%) 17.54
length=512, char=0: 268.26 (-1307.85%) 12.06 ( 36.71%) 19.05
length=513, char=0: 268.73 (-1273.89%) 13.56 ( 30.68%) 19.56
length=514, char=0: 269.31 (-1276.89%) 13.56 ( 30.68%) 19.56
length=515, char=0: 269.73 (-1279.05%) 13.56 ( 30.68%) 19.56
length=516, char=0: 270.34 (-1282.24%) 13.56 ( 30.67%) 19.56
length=517, char=0: 270.83 (-1284.71%) 13.56 ( 30.66%) 19.56
length=518, char=0: 271.20 (-1286.54%) 13.56 ( 30.67%) 19.56
length=519, char=0: 271.67 (-1288.67%) 13.65 ( 30.24%) 19.56
length=520, char=0: 272.14 (-1291.04%) 13.65 ( 30.22%) 19.56
length=521, char=0: 272.66 (-1293.69%) 13.65 ( 30.23%) 19.56
length=522, char=0: 273.14 (-1296.13%) 13.65 ( 30.20%) 19.56
length=523, char=0: 273.64 (-1298.75%) 13.65 ( 30.23%) 19.56
length=524, char=0: 274.34 (-1302.16%) 13.66 ( 30.20%) 19.57
length=525, char=0: 274.64 (-1297.78%) 13.56 ( 30.99%) 19.65
length=526, char=0: 275.20 (-1300.04%) 13.56 ( 31.01%) 19.66
length=527, char=0: 275.66 (-1302.86%) 13.56 ( 30.99%) 19.65
length=1024, char=0: 524.46 (-2169.75%) 20.12 ( 12.92%) 23.11
length=1025, char=0: 525.14 (-2124.63%) 21.62 ( 8.40%) 23.61
length=1026, char=0: 525.59 (-2125.36%) 21.88 ( 7.37%) 23.62
length=1027, char=0: 525.98 (-2127.14%) 21.62 ( 8.46%) 23.62
length=1028, char=0: 526.68 (-2131.10%) 21.62 ( 8.42%) 23.61
length=1029, char=0: 527.10 (-2131.70%) 21.79 ( 7.73%) 23.62
length=1030, char=0: 527.54 (-2118.51%) 21.62 ( 9.10%) 23.78
length=1031, char=0: 527.98 (-2136.37%) 21.62 ( 8.43%) 23.61
length=1032, char=0: 528.70 (-2139.38%) 21.62 ( 8.43%) 23.61
length=1033, char=0: 529.25 (-2124.37%) 21.62 ( 9.11%) 23.79
length=1034, char=0: 529.48 (-2142.95%) 21.62 ( 8.43%) 23.61
length=1035, char=0: 530.11 (-2145.13%) 21.62 ( 8.44%) 23.61
length=1036, char=0: 530.76 (-2147.10%) 21.79 ( 7.73%) 23.62
length=1037, char=0: 531.03 (-2149.45%) 21.62 ( 8.42%) 23.61
length=1038, char=0: 531.64 (-2151.87%) 21.62 ( 8.42%) 23.61
length=1039, char=0: 531.99 (-2151.63%) 21.80 ( 7.75%) 23.63
* sysdeps/aarch64/memset-reg.h: New file.
* sysdeps/aarch64/memset.S: Use it.
(__memset): Rename to MEMSET macro.
[ZVA_MACRO]: Use zva_macro.
* sysdeps/aarch64/multiarch/Makefile (sysdep_routines):
Add memset_generic and memset_falkor.
* sysdeps/aarch64/multiarch/ifunc-impl-list.c
(__libc_ifunc_impl_list): Add memset ifuncs.
* sysdeps/aarch64/multiarch/init-arch.h (INIT_ARCH): New
local variable zva_size.
* sysdeps/aarch64/multiarch/memset.c: New file.
* sysdeps/aarch64/multiarch/memset_generic.S: New file.
* sysdeps/aarch64/multiarch/memset_falkor.S: New file.
* sysdeps/aarch64/multiarch/rtld-memset.S: New file.
* sysdeps/unix/sysv/linux/aarch64/cpu-features.c
(DCZID_DZP_MASK): New macro.
(DCZID_BS_MASK): Likewise.
(init_cpu_features): Read and set zva_size.
* sysdeps/unix/sysv/linux/aarch64/cpu-features.h
(struct cpu_features): New member zva_size.
2017-11-20 12:55:04 +00:00
|
|
|
#define DCZID_DZP_MASK (1 << 4)
|
|
|
|
#define DCZID_BS_MASK (0xf)
|
|
|
|
|
2020-12-21 15:03:03 +00:00
|
|
|
/* The maximal set of permitted tags that the MTE random tag generation
|
|
|
|
instruction may use. We exclude tag 0 because a) we want to reserve
|
|
|
|
that for the libc heap structures and b) because it makes it easier
|
|
|
|
to see when pointer have been correctly tagged. */
|
|
|
|
#define MTE_ALLOWED_TAGS (0xfffe << PR_MTE_TAG_SHIFT)
|
|
|
|
|
2017-06-30 17:28:39 +00:00
|
|
|
struct cpu_list
|
|
|
|
{
|
|
|
|
const char *name;
|
2023-12-06 13:24:01 +00:00
|
|
|
size_t len;
|
2017-06-30 17:28:39 +00:00
|
|
|
uint64_t midr;
|
|
|
|
};
|
|
|
|
|
2023-12-06 13:24:01 +00:00
|
|
|
static const struct cpu_list cpu_list[] =
|
|
|
|
{
|
|
|
|
#define CPU_LIST_ENTRY(__str, __num) { __str, sizeof (__str) - 1, __num }
|
|
|
|
CPU_LIST_ENTRY ("thunderxt88", 0x430F0A10),
|
|
|
|
CPU_LIST_ENTRY ("thunderx2t99", 0x431F0AF0),
|
|
|
|
CPU_LIST_ENTRY ("thunderx2t99p1", 0x420F5160),
|
|
|
|
CPU_LIST_ENTRY ("ares", 0x411FD0C0),
|
|
|
|
CPU_LIST_ENTRY ("emag", 0x503F0001),
|
|
|
|
CPU_LIST_ENTRY ("kunpeng920", 0x481FD010),
|
|
|
|
CPU_LIST_ENTRY ("a64fx", 0x460F0010),
|
|
|
|
CPU_LIST_ENTRY ("generic", 0x0),
|
2017-06-30 17:28:39 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static uint64_t
|
2023-12-06 13:24:01 +00:00
|
|
|
get_midr_from_mcpu (const struct tunable_str_t *mcpu)
|
2017-06-30 17:28:39 +00:00
|
|
|
{
|
2023-12-06 13:24:01 +00:00
|
|
|
for (int i = 0; i < array_length (cpu_list); i++)
|
|
|
|
if (tunable_strcmp (mcpu, cpu_list[i].name, cpu_list[i].len))
|
2017-06-30 17:28:39 +00:00
|
|
|
return cpu_list[i].midr;
|
|
|
|
|
|
|
|
return UINT64_MAX;
|
|
|
|
}
|
|
|
|
|
2024-03-21 16:48:33 +00:00
|
|
|
#if __LINUX_KERNEL_VERSION < 0x060200
|
|
|
|
|
|
|
|
/* Return true if we prefer using SVE in string ifuncs. Old kernels disable
|
|
|
|
SVE after every system call which results in unnecessary traps if memcpy
|
|
|
|
uses SVE. This is true for kernels between 4.15.0 and before 6.2.0, except
|
|
|
|
for 5.14.0 which was patched. For these versions return false to avoid using
|
|
|
|
SVE ifuncs.
|
|
|
|
Parse the kernel version into a 24-bit kernel.major.minor value without
|
|
|
|
calling any library functions. If uname() is not supported or if the version
|
|
|
|
format is not recognized, assume the kernel is modern and return true. */
|
|
|
|
|
|
|
|
static inline bool
|
|
|
|
prefer_sve_ifuncs (void)
|
|
|
|
{
|
|
|
|
struct utsname buf;
|
|
|
|
const char *p = &buf.release[0];
|
|
|
|
int kernel = 0;
|
|
|
|
int val;
|
|
|
|
|
|
|
|
if (__uname (&buf) < 0)
|
|
|
|
return true;
|
|
|
|
|
|
|
|
for (int shift = 16; shift >= 0; shift -= 8)
|
|
|
|
{
|
|
|
|
for (val = 0; *p >= '0' && *p <= '9'; p++)
|
|
|
|
val = val * 10 + *p - '0';
|
|
|
|
kernel |= (val & 255) << shift;
|
|
|
|
if (*p++ != '.')
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (kernel >= 0x060200 || kernel == 0x050e00)
|
|
|
|
return true;
|
|
|
|
if (kernel >= 0x040f00)
|
|
|
|
return false;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
2017-03-15 23:46:26 +00:00
|
|
|
static inline void
|
|
|
|
init_cpu_features (struct cpu_features *cpu_features)
|
|
|
|
{
|
2017-06-30 17:28:39 +00:00
|
|
|
register uint64_t midr = UINT64_MAX;
|
|
|
|
|
|
|
|
/* Get the tunable override. */
|
2023-12-06 13:24:01 +00:00
|
|
|
const struct tunable_str_t *mcpu = TUNABLE_GET (glibc, cpu, name,
|
|
|
|
struct tunable_str_t *,
|
|
|
|
NULL);
|
2017-06-30 17:28:39 +00:00
|
|
|
if (mcpu != NULL)
|
|
|
|
midr = get_midr_from_mcpu (mcpu);
|
|
|
|
|
|
|
|
/* If there was no useful tunable override, query the MIDR if the kernel
|
|
|
|
allows it. */
|
|
|
|
if (midr == UINT64_MAX)
|
2017-03-15 23:46:26 +00:00
|
|
|
{
|
2018-06-28 13:43:07 +00:00
|
|
|
if (GLRO (dl_hwcap) & HWCAP_CPUID)
|
2017-06-30 17:28:39 +00:00
|
|
|
asm volatile ("mrs %0, midr_el1" : "=r"(midr));
|
|
|
|
else
|
|
|
|
midr = 0;
|
2017-03-15 23:46:26 +00:00
|
|
|
}
|
2017-06-30 17:28:39 +00:00
|
|
|
|
|
|
|
cpu_features->midr_el1 = midr;
|
aarch64: Optimized memset for falkor
The generic memset reads dczid_el0 on every memset. This has a
significant impact on falkor for a range of sizes because reading
dczid_el0 is slow.
The DZP bit in the dczid_el0 register does not change dynamically, so
it is safe to read once during program startup. With this patch
dczid_el0 is read once during startup and zva_size is cached. This is
used to invoke the falkor-specific memset; the generic memset routine
remains unchanged.
The gains due to this are significant for falkor, with run time
reductions as high as 48%. Here's a sample from the falkor tests:
Function: memset
Variant: walk
simple_memset __memset_falkor __memset_generic
=====================================================================
length=256, char=0: 139.96 (-698.28%) 9.07 ( 48.26%) 17.53
length=257, char=0: 140.50 (-699.03%) 9.53 ( 45.80%) 17.58
length=258, char=0: 140.96 (-703.95%) 9.58 ( 45.36%) 17.53
length=259, char=0: 141.56 (-705.16%) 9.53 ( 45.79%) 17.58
length=260, char=0: 142.15 (-710.76%) 9.57 ( 45.39%) 17.53
length=261, char=0: 142.50 (-710.39%) 9.53 ( 45.78%) 17.58
length=262, char=0: 142.97 (-715.09%) 9.57 ( 45.42%) 17.54
length=263, char=0: 143.51 (-716.18%) 9.53 ( 45.80%) 17.58
length=264, char=0: 143.93 (-720.55%) 9.58 ( 45.39%) 17.54
length=265, char=0: 144.56 (-722.07%) 9.53 ( 45.80%) 17.59
length=266, char=0: 144.98 (-726.42%) 9.58 ( 45.42%) 17.54
length=267, char=0: 145.53 (-727.53%) 9.53 ( 45.80%) 17.59
length=268, char=0: 146.25 (-731.81%) 9.53 ( 45.79%) 17.58
length=269, char=0: 146.52 (-735.39%) 9.53 ( 45.66%) 17.54
length=270, char=0: 146.97 (-735.81%) 9.53 ( 45.80%) 17.58
length=271, char=0: 147.54 (-741.08%) 9.58 ( 45.38%) 17.54
length=512, char=0: 268.26 (-1307.85%) 12.06 ( 36.71%) 19.05
length=513, char=0: 268.73 (-1273.89%) 13.56 ( 30.68%) 19.56
length=514, char=0: 269.31 (-1276.89%) 13.56 ( 30.68%) 19.56
length=515, char=0: 269.73 (-1279.05%) 13.56 ( 30.68%) 19.56
length=516, char=0: 270.34 (-1282.24%) 13.56 ( 30.67%) 19.56
length=517, char=0: 270.83 (-1284.71%) 13.56 ( 30.66%) 19.56
length=518, char=0: 271.20 (-1286.54%) 13.56 ( 30.67%) 19.56
length=519, char=0: 271.67 (-1288.67%) 13.65 ( 30.24%) 19.56
length=520, char=0: 272.14 (-1291.04%) 13.65 ( 30.22%) 19.56
length=521, char=0: 272.66 (-1293.69%) 13.65 ( 30.23%) 19.56
length=522, char=0: 273.14 (-1296.13%) 13.65 ( 30.20%) 19.56
length=523, char=0: 273.64 (-1298.75%) 13.65 ( 30.23%) 19.56
length=524, char=0: 274.34 (-1302.16%) 13.66 ( 30.20%) 19.57
length=525, char=0: 274.64 (-1297.78%) 13.56 ( 30.99%) 19.65
length=526, char=0: 275.20 (-1300.04%) 13.56 ( 31.01%) 19.66
length=527, char=0: 275.66 (-1302.86%) 13.56 ( 30.99%) 19.65
length=1024, char=0: 524.46 (-2169.75%) 20.12 ( 12.92%) 23.11
length=1025, char=0: 525.14 (-2124.63%) 21.62 ( 8.40%) 23.61
length=1026, char=0: 525.59 (-2125.36%) 21.88 ( 7.37%) 23.62
length=1027, char=0: 525.98 (-2127.14%) 21.62 ( 8.46%) 23.62
length=1028, char=0: 526.68 (-2131.10%) 21.62 ( 8.42%) 23.61
length=1029, char=0: 527.10 (-2131.70%) 21.79 ( 7.73%) 23.62
length=1030, char=0: 527.54 (-2118.51%) 21.62 ( 9.10%) 23.78
length=1031, char=0: 527.98 (-2136.37%) 21.62 ( 8.43%) 23.61
length=1032, char=0: 528.70 (-2139.38%) 21.62 ( 8.43%) 23.61
length=1033, char=0: 529.25 (-2124.37%) 21.62 ( 9.11%) 23.79
length=1034, char=0: 529.48 (-2142.95%) 21.62 ( 8.43%) 23.61
length=1035, char=0: 530.11 (-2145.13%) 21.62 ( 8.44%) 23.61
length=1036, char=0: 530.76 (-2147.10%) 21.79 ( 7.73%) 23.62
length=1037, char=0: 531.03 (-2149.45%) 21.62 ( 8.42%) 23.61
length=1038, char=0: 531.64 (-2151.87%) 21.62 ( 8.42%) 23.61
length=1039, char=0: 531.99 (-2151.63%) 21.80 ( 7.75%) 23.63
* sysdeps/aarch64/memset-reg.h: New file.
* sysdeps/aarch64/memset.S: Use it.
(__memset): Rename to MEMSET macro.
[ZVA_MACRO]: Use zva_macro.
* sysdeps/aarch64/multiarch/Makefile (sysdep_routines):
Add memset_generic and memset_falkor.
* sysdeps/aarch64/multiarch/ifunc-impl-list.c
(__libc_ifunc_impl_list): Add memset ifuncs.
* sysdeps/aarch64/multiarch/init-arch.h (INIT_ARCH): New
local variable zva_size.
* sysdeps/aarch64/multiarch/memset.c: New file.
* sysdeps/aarch64/multiarch/memset_generic.S: New file.
* sysdeps/aarch64/multiarch/memset_falkor.S: New file.
* sysdeps/aarch64/multiarch/rtld-memset.S: New file.
* sysdeps/unix/sysv/linux/aarch64/cpu-features.c
(DCZID_DZP_MASK): New macro.
(DCZID_BS_MASK): Likewise.
(init_cpu_features): Read and set zva_size.
* sysdeps/unix/sysv/linux/aarch64/cpu-features.h
(struct cpu_features): New member zva_size.
2017-11-20 12:55:04 +00:00
|
|
|
|
|
|
|
/* Check if ZVA is enabled. */
|
|
|
|
unsigned dczid;
|
|
|
|
asm volatile ("mrs %0, dczid_el0" : "=r"(dczid));
|
|
|
|
|
|
|
|
if ((dczid & DCZID_DZP_MASK) == 0)
|
|
|
|
cpu_features->zva_size = 4 << (dczid & DCZID_BS_MASK);
|
2020-06-22 09:57:20 +00:00
|
|
|
|
|
|
|
/* Check if BTI is supported. */
|
|
|
|
cpu_features->bti = GLRO (dl_hwcap2) & HWCAP2_BTI;
|
2020-12-21 15:03:03 +00:00
|
|
|
|
|
|
|
/* Setup memory tagging support if the HW and kernel support it, and if
|
|
|
|
the user has requested it. */
|
|
|
|
cpu_features->mte_state = 0;
|
|
|
|
|
|
|
|
#ifdef USE_MTAG
|
|
|
|
int mte_state = TUNABLE_GET (glibc, mem, tagging, unsigned, 0);
|
|
|
|
cpu_features->mte_state = (GLRO (dl_hwcap2) & HWCAP2_MTE) ? mte_state : 0;
|
|
|
|
/* If we lack the MTE feature, disable the tunable, since it will
|
|
|
|
otherwise cause instructions that won't run on this CPU to be used. */
|
2021-02-05 07:48:58 +00:00
|
|
|
TUNABLE_SET (glibc, mem, tagging, cpu_features->mte_state);
|
2020-12-21 15:03:03 +00:00
|
|
|
|
2022-06-27 18:00:50 +00:00
|
|
|
if (cpu_features->mte_state & 4)
|
|
|
|
/* Enable choosing system-preferred faulting mode. */
|
|
|
|
__prctl (PR_SET_TAGGED_ADDR_CTRL,
|
|
|
|
(PR_TAGGED_ADDR_ENABLE | PR_MTE_TCF_SYNC | PR_MTE_TCF_ASYNC
|
|
|
|
| MTE_ALLOWED_TAGS),
|
|
|
|
0, 0, 0);
|
|
|
|
else if (cpu_features->mte_state & 2)
|
2020-12-21 15:03:03 +00:00
|
|
|
__prctl (PR_SET_TAGGED_ADDR_CTRL,
|
|
|
|
(PR_TAGGED_ADDR_ENABLE | PR_MTE_TCF_SYNC | MTE_ALLOWED_TAGS),
|
|
|
|
0, 0, 0);
|
|
|
|
else if (cpu_features->mte_state)
|
|
|
|
__prctl (PR_SET_TAGGED_ADDR_CTRL,
|
|
|
|
(PR_TAGGED_ADDR_ENABLE | PR_MTE_TCF_ASYNC | MTE_ALLOWED_TAGS),
|
|
|
|
0, 0, 0);
|
|
|
|
#endif
|
2021-05-27 07:42:35 +00:00
|
|
|
|
|
|
|
/* Check if SVE is supported. */
|
|
|
|
cpu_features->sve = GLRO (dl_hwcap) & HWCAP_SVE;
|
2023-10-17 15:54:21 +00:00
|
|
|
|
2024-03-21 16:48:33 +00:00
|
|
|
cpu_features->prefer_sve_ifuncs = cpu_features->sve;
|
|
|
|
|
|
|
|
#if __LINUX_KERNEL_VERSION < 0x060200
|
|
|
|
if (cpu_features->sve)
|
|
|
|
cpu_features->prefer_sve_ifuncs = prefer_sve_ifuncs ();
|
|
|
|
#endif
|
|
|
|
|
2023-10-17 15:54:21 +00:00
|
|
|
/* Check if MOPS is supported. */
|
|
|
|
cpu_features->mops = GLRO (dl_hwcap2) & HWCAP2_MOPS;
|
2017-03-15 23:46:26 +00:00
|
|
|
}
|