diff options
author | Adhemerval Zanella <adhemerval.zanella@linaro.org> | 2025-02-26 12:54:17 -0300 |
---|---|---|
committer | Adhemerval Zanella <adhemerval.zanella@linaro.org> | 2025-03-05 11:22:09 -0300 |
commit | 8a995670a8c25e7145201ec52b0c648dae0ff9c2 (patch) | |
tree | 6449aecfb9ca686ac93f701d92df3318f8967be6 /sysdeps/unix/sysv/linux/powerpc | |
parent | 3a9fb97caf3d4c04a812f51d4c5139cb2b9ed52e (diff) | |
download | glibc-8a995670a8c25e7145201ec52b0c648dae0ff9c2.zip glibc-8a995670a8c25e7145201ec52b0c648dae0ff9c2.tar.gz glibc-8a995670a8c25e7145201ec52b0c648dae0ff9c2.tar.bz2 |
powerpc: Move AT_HWCAP descriptions to ld diagnostics
The ld.so diagnostics already prints AT_HWCAP values, but only in
hexadecimal. To avoid duplicating the strings, consolidate the
hwcap_names from cpu-features.h on a new file, dl-hwcap-info.h
(and it also improves the hwcap string description with more
values).
For future AT_HWCAP3/AT_HWCAP4 extensions, it is just a matter
to add them on dl-hwcap-info.c so both ld diagnostics and
tunable filtering will parse the new values.
Checked on powerpc64le-linux-gnu.
Reviewed-by: Peter Bergner <bergner@linux.ibm.com>
Diffstat (limited to 'sysdeps/unix/sysv/linux/powerpc')
-rw-r--r-- | sysdeps/unix/sysv/linux/powerpc/Makefile | 4 | ||||
-rw-r--r-- | sysdeps/unix/sysv/linux/powerpc/cpu-features.c | 43 | ||||
-rw-r--r-- | sysdeps/unix/sysv/linux/powerpc/cpu-features.h | 99 | ||||
-rw-r--r-- | sysdeps/unix/sysv/linux/powerpc/dl-hwcap-info.c | 117 | ||||
-rw-r--r-- | sysdeps/unix/sysv/linux/powerpc/dl-hwcap-info.h | 34 |
5 files changed, 179 insertions, 118 deletions
diff --git a/sysdeps/unix/sysv/linux/powerpc/Makefile b/sysdeps/unix/sysv/linux/powerpc/Makefile index 24827ef..cddb624 100644 --- a/sysdeps/unix/sysv/linux/powerpc/Makefile +++ b/sysdeps/unix/sysv/linux/powerpc/Makefile @@ -13,6 +13,10 @@ gen-as-const-headers += ucontext_i.sym endif ifeq ($(subdir),elf) +dl-routines += \ + dl-hwcap-info \ + # dl-routines + # Otherwise tst-tls-dlinfo fails due to tst-tlsmod2.so using static tls. ifeq ($(have-tls-get-addr-optimize),yes) LDFLAGS-tst-tlsmod2.so += -Wl,--no-tls-get-addr-optimize diff --git a/sysdeps/unix/sysv/linux/powerpc/cpu-features.c b/sysdeps/unix/sysv/linux/powerpc/cpu-features.c index bcce635..520ccaa 100644 --- a/sysdeps/unix/sysv/linux/powerpc/cpu-features.c +++ b/sysdeps/unix/sysv/linux/powerpc/cpu-features.c @@ -21,9 +21,19 @@ #include <cpu-features.h> #include <elf/dl-tunables.h> #include <dl-tunables-parse.h> +#include <dl-hwcap-info.h> #include <unistd.h> #include <string.h> +static void set_hwcap_bit (unsigned long int *hwcap, bool disable, + unsigned long int tcb_value, unsigned int value) +{ + if (disable) + *hwcap &= ~value; + else + *hwcap |= tcb_value & value; +} + static void TUNABLE_CALLBACK (set_hwcaps) (tunable_val_t *valp) { @@ -55,32 +65,27 @@ TUNABLE_CALLBACK (set_hwcaps) (tunable_val_t *valp) continue; size_t offset = 0; - for (int i = 0; i < array_length (hwcap_tunables); ++i) + for (int i = 0; i < __dl_hwcap_info_size; ++i) { - const char *hwcap_name = hwcap_names + offset; + const char *hwcap_name = __dl_hwcap_names + offset; size_t hwcap_name_len = strlen (hwcap_name); /* Check the tunable name on the supported list. */ if (tunable_str_comma_strcmp (&t, hwcap_name, hwcap_name_len)) { - /* Update the hwcap and hwcap2 bits. */ - if (t.disable) + switch (__dl_hwcap_info[i].hwcap) { - /* Id is 1 for hwcap2 tunable. */ - if (hwcap_tunables[i].id) - cpu_features->hwcap2 &= ~(hwcap_tunables[i].mask); - else - cpu_features->hwcap &= ~(hwcap_tunables[i].mask); - } - else - { - /* Enable the features and also check that no unsupported - features were enabled by user. */ - if (hwcap_tunables[i].id) - cpu_features->hwcap2 |= (tcbv_hwcap2 & hwcap_tunables[i].mask); - else - cpu_features->hwcap |= (tcbv_hwcap & hwcap_tunables[i].mask); + case AT_HWCAP: + set_hwcap_bit (&cpu_features->hwcap, t.disable, tcbv_hwcap, + __dl_hwcap_info[i].value); + break; + + case AT_HWCAP2: + set_hwcap_bit (&cpu_features->hwcap2, t.disable, tcbv_hwcap2, + __dl_hwcap_info[i].value); + break; + + /* Ignore unknown values. */ } - break; } offset += hwcap_name_len + 1; } diff --git a/sysdeps/unix/sysv/linux/powerpc/cpu-features.h b/sysdeps/unix/sysv/linux/powerpc/cpu-features.h index 3c5cc6e..f15a803 100644 --- a/sysdeps/unix/sysv/linux/powerpc/cpu-features.h +++ b/sysdeps/unix/sysv/linux/powerpc/cpu-features.h @@ -30,103 +30,4 @@ struct cpu_features unsigned long int hwcap4; }; -static const char hwcap_names[] = { - "4xxmac\0" - "altivec\0" - "arch_2_05\0" - "arch_2_06\0" - "archpmu\0" - "booke\0" - "cellbe\0" - "dfp\0" - "efpdouble\0" - "efpsingle\0" - "fpu\0" - "ic_snoop\0" - "mmu\0" - "notb\0" - "pa6t\0" - "power4\0" - "power5\0" - "power5+\0" - "power6x\0" - "ppc32\0" - "ppc601\0" - "ppc64\0" - "ppcle\0" - "smt\0" - "spe\0" - "true_le\0" - "ucache\0" - "vsx\0" - "arch_2_07\0" - "dscr\0" - "ebb\0" - "htm\0" - "htm-nosc\0" - "htm-no-suspend\0" - "isel\0" - "tar\0" - "vcrypto\0" - "arch_3_00\0" - "ieee128\0" - "darn\0" - "scv\0" - "arch_3_1\0" - "mma\0" -}; - -static const struct -{ - unsigned int mask; - bool id; -} hwcap_tunables[] = { - /* AT_HWCAP tunable masks. */ - { PPC_FEATURE_HAS_4xxMAC, 0 }, - { PPC_FEATURE_HAS_ALTIVEC, 0 }, - { PPC_FEATURE_ARCH_2_05, 0 }, - { PPC_FEATURE_ARCH_2_06, 0 }, - { PPC_FEATURE_PSERIES_PERFMON_COMPAT, 0 }, - { PPC_FEATURE_BOOKE, 0 }, - { PPC_FEATURE_CELL_BE, 0 }, - { PPC_FEATURE_HAS_DFP, 0 }, - { PPC_FEATURE_HAS_EFP_DOUBLE, 0 }, - { PPC_FEATURE_HAS_EFP_SINGLE, 0 }, - { PPC_FEATURE_HAS_FPU, 0 }, - { PPC_FEATURE_ICACHE_SNOOP, 0 }, - { PPC_FEATURE_HAS_MMU, 0 }, - { PPC_FEATURE_NO_TB, 0 }, - { PPC_FEATURE_PA6T, 0 }, - { PPC_FEATURE_POWER4, 0 }, - { PPC_FEATURE_POWER5, 0 }, - { PPC_FEATURE_POWER5_PLUS, 0 }, - { PPC_FEATURE_POWER6_EXT, 0 }, - { PPC_FEATURE_32, 0 }, - { PPC_FEATURE_601_INSTR, 0 }, - { PPC_FEATURE_64, 0 }, - { PPC_FEATURE_PPC_LE, 0 }, - { PPC_FEATURE_SMT, 0 }, - { PPC_FEATURE_HAS_SPE, 0 }, - { PPC_FEATURE_TRUE_LE, 0 }, - { PPC_FEATURE_UNIFIED_CACHE, 0 }, - { PPC_FEATURE_HAS_VSX, 0 }, - - /* AT_HWCAP2 tunable masks. */ - { PPC_FEATURE2_ARCH_2_07, 1 }, - { PPC_FEATURE2_HAS_DSCR, 1 }, - { PPC_FEATURE2_HAS_EBB, 1 }, - { PPC_FEATURE2_HAS_HTM, 1 }, - { PPC_FEATURE2_HTM_NOSC, 1 }, - { PPC_FEATURE2_HTM_NO_SUSPEND, 1 }, - { PPC_FEATURE2_HAS_ISEL, 1 }, - { PPC_FEATURE2_HAS_TAR, 1 }, - { PPC_FEATURE2_HAS_VEC_CRYPTO, 1 }, - { PPC_FEATURE2_ARCH_3_00, 1 }, - { PPC_FEATURE2_HAS_IEEE128, 1 }, - { PPC_FEATURE2_DARN, 1 }, - { PPC_FEATURE2_SCV, 1 }, - { PPC_FEATURE2_ARCH_3_1, 1 }, - { PPC_FEATURE2_MMA, 1 }, -}; - #endif /* __CPU_FEATURES_H */ diff --git a/sysdeps/unix/sysv/linux/powerpc/dl-hwcap-info.c b/sysdeps/unix/sysv/linux/powerpc/dl-hwcap-info.c new file mode 100644 index 0000000..1178828 --- /dev/null +++ b/sysdeps/unix/sysv/linux/powerpc/dl-hwcap-info.c @@ -0,0 +1,117 @@ +/* HWCAP string information. PowerPC version. + Copyright (C) 2017-2025 Free Software Foundation, Inc. + + 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 + <https://www.gnu.org/licenses/>. */ + +#include <array_length.h> +#include <dl-hwcap-info.h> + +const char __dl_hwcap_names[] = { + "4xxmac\0" + "altivec\0" + "arch_2_05\0" + "arch_2_06\0" + "archpmu\0" + "booke\0" + "cellbe\0" + "dfp\0" + "efpdouble\0" + "efpsingle\0" + "fpu\0" + "ic_snoop\0" + "mmu\0" + "notb\0" + "pa6t\0" + "power4\0" + "power5\0" + "power5+\0" + "power6x\0" + "ppc32\0" + "ppc601\0" + "ppc64\0" + "ppcle\0" + "smt\0" + "spe\0" + "true_le\0" + "ucache\0" + "vsx\0" + "arch_2_07\0" + "dscr\0" + "ebb\0" + "htm\0" + "htm-nosc\0" + "htm-no-suspend\0" + "isel\0" + "tar\0" + "vcrypto\0" + "arch_3_00\0" + "ieee128\0" + "darn\0" + "scv\0" + "arch_3_1\0" + "mma\0" +}; + +const struct hwcap_info_t __dl_hwcap_info[] = +{ + /* AT_HWCAP tunable masks. */ + { PPC_FEATURE_HAS_4xxMAC, AT_HWCAP }, + { PPC_FEATURE_HAS_ALTIVEC, AT_HWCAP }, + { PPC_FEATURE_ARCH_2_05, AT_HWCAP }, + { PPC_FEATURE_ARCH_2_06, AT_HWCAP }, + { PPC_FEATURE_PSERIES_PERFMON_COMPAT, AT_HWCAP }, + { PPC_FEATURE_BOOKE, AT_HWCAP }, + { PPC_FEATURE_CELL_BE, AT_HWCAP }, + { PPC_FEATURE_HAS_DFP, AT_HWCAP }, + { PPC_FEATURE_HAS_EFP_DOUBLE, AT_HWCAP }, + { PPC_FEATURE_HAS_EFP_SINGLE, AT_HWCAP }, + { PPC_FEATURE_HAS_FPU, AT_HWCAP }, + { PPC_FEATURE_ICACHE_SNOOP, AT_HWCAP }, + { PPC_FEATURE_HAS_MMU, AT_HWCAP }, + { PPC_FEATURE_NO_TB, AT_HWCAP }, + { PPC_FEATURE_PA6T, AT_HWCAP }, + { PPC_FEATURE_POWER4, AT_HWCAP }, + { PPC_FEATURE_POWER5, AT_HWCAP }, + { PPC_FEATURE_POWER5_PLUS, AT_HWCAP }, + { PPC_FEATURE_POWER6_EXT, AT_HWCAP }, + { PPC_FEATURE_32, AT_HWCAP }, + { PPC_FEATURE_601_INSTR, AT_HWCAP }, + { PPC_FEATURE_64, AT_HWCAP }, + { PPC_FEATURE_PPC_LE, AT_HWCAP }, + { PPC_FEATURE_SMT, AT_HWCAP }, + { PPC_FEATURE_HAS_SPE, AT_HWCAP }, + { PPC_FEATURE_TRUE_LE, AT_HWCAP }, + { PPC_FEATURE_UNIFIED_CACHE, AT_HWCAP }, + { PPC_FEATURE_HAS_VSX, AT_HWCAP }, + + /* AT_HWCAP2 tunable masks. */ + { PPC_FEATURE2_ARCH_2_07, AT_HWCAP2 }, + { PPC_FEATURE2_HAS_DSCR, AT_HWCAP2 }, + { PPC_FEATURE2_HAS_EBB, AT_HWCAP2 }, + { PPC_FEATURE2_HAS_HTM, AT_HWCAP2 }, + { PPC_FEATURE2_HTM_NOSC, AT_HWCAP2 }, + { PPC_FEATURE2_HTM_NO_SUSPEND, AT_HWCAP2 }, + { PPC_FEATURE2_HAS_ISEL, AT_HWCAP2 }, + { PPC_FEATURE2_HAS_TAR, AT_HWCAP2 }, + { PPC_FEATURE2_HAS_VEC_CRYPTO, AT_HWCAP2 }, + { PPC_FEATURE2_ARCH_3_00, AT_HWCAP2 }, + { PPC_FEATURE2_HAS_IEEE128, AT_HWCAP2 }, + { PPC_FEATURE2_DARN, AT_HWCAP2 }, + { PPC_FEATURE2_SCV, AT_HWCAP2 }, + { PPC_FEATURE2_ARCH_3_1, AT_HWCAP2 }, + { PPC_FEATURE2_MMA, AT_HWCAP2 }, +}; + +size_t __dl_hwcap_info_size = array_length (__dl_hwcap_info); diff --git a/sysdeps/unix/sysv/linux/powerpc/dl-hwcap-info.h b/sysdeps/unix/sysv/linux/powerpc/dl-hwcap-info.h new file mode 100644 index 0000000..194f40c --- /dev/null +++ b/sysdeps/unix/sysv/linux/powerpc/dl-hwcap-info.h @@ -0,0 +1,34 @@ +/* HWCAP string information. PowerPC version. + Copyright (C) 2017-2025 Free Software Foundation, Inc. + + 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 + <https://www.gnu.org/licenses/>. */ + +#ifndef _DL_HWCAP_INFO_H +#define _DL_HWCAP_INFO_H + +#include <stddef.h> +#include <sys/auxv.h> + +extern const char __dl_hwcap_names[] attribute_hidden; + +struct hwcap_info_t +{ + unsigned int value; + int hwcap; +}; +extern const struct hwcap_info_t __dl_hwcap_info[] attribute_hidden; +extern size_t __dl_hwcap_info_size attribute_hidden; + +#endif |