Add thunderx2t99 and thunderx2t99p1 CPU names to tunables list
[glibc.git] / sysdeps / unix / sysv / linux / aarch64 / cpu-features.c
blobe769eeb35f7fdec4b6c912956777cc1c11d65aa9
1 /* Initialize CPU feature data. AArch64 version.
2 This file is part of the GNU C Library.
3 Copyright (C) 2017 Free Software Foundation, Inc.
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
19 #include <cpu-features.h>
20 #include <sys/auxv.h>
21 #include <elf/dl-hwcaps.h>
23 #if HAVE_TUNABLES
24 struct cpu_list
26 const char *name;
27 uint64_t midr;
30 static struct cpu_list cpu_list[] = {
31 {"falkor", 0x510FC000},
32 {"thunderxt88", 0x430F0A10},
33 {"thunderx2t99", 0x431F0AF0},
34 {"thunderx2t99p1", 0x420F5160},
35 {"generic", 0x0}
38 static uint64_t
39 get_midr_from_mcpu (const char *mcpu)
41 for (int i = 0; i < sizeof (cpu_list) / sizeof (struct cpu_list); i++)
42 if (strcmp (mcpu, cpu_list[i].name) == 0)
43 return cpu_list[i].midr;
45 return UINT64_MAX;
47 #endif
49 static inline void
50 init_cpu_features (struct cpu_features *cpu_features)
52 uint64_t hwcap_mask = GET_HWCAP_MASK();
53 uint64_t hwcap = GLRO (dl_hwcap) & hwcap_mask;
55 register uint64_t midr = UINT64_MAX;
57 #if HAVE_TUNABLES
58 /* Get the tunable override. */
59 const char *mcpu = TUNABLE_GET (glibc, tune, cpu, const char *, NULL);
60 if (mcpu != NULL)
61 midr = get_midr_from_mcpu (mcpu);
62 #endif
64 /* If there was no useful tunable override, query the MIDR if the kernel
65 allows it. */
66 if (midr == UINT64_MAX)
68 if (hwcap & HWCAP_CPUID)
69 asm volatile ("mrs %0, midr_el1" : "=r"(midr));
70 else
71 midr = 0;
74 cpu_features->midr_el1 = midr;