diff options
author | Carlos Eduardo Seo <cseo@linux.vnet.ibm.com> | 2015-10-22 19:26:58 -0500 |
---|---|---|
committer | Tulio Magno Quites Machado Filho <tuliom@linux.vnet.ibm.com> | 2015-12-03 13:56:13 -0200 |
commit | 67385a01d229751569b6aac067ffdcd813a15d7a (patch) | |
tree | 2012071b67d002ad49438bd7d626f7b4514bbdce /sysdeps/powerpc/hwcapinfo.c | |
parent | db340c904dd519142025a09190bf48ad28152ab9 (diff) | |
download | glibc-67385a01d229751569b6aac067ffdcd813a15d7a.tar.gz |
powerpc: Add hwcap/hwcap2/platform data to TCB.
This patch adds a new feature for powerpc. In order to get faster access to
the HWCAP/HWCAP2 bits and platform number (i.e. for implementing
__builtin_cpu_is () / __builtin_cpu_supports () in GCC) without the overhead of
reading from the auxiliary vector, we now reserve space for them in the TCB.
This is an ABI change for GLIBC 2.23.
A new versioned symbol '__parse_hwcap_and_convert_at_platform' is available to
get the data from the auxiliary vector and parse it, and store it for later use
in the TLS initialization code. This function is called very early
(in _dl_sysdep_start () via DL_PLATFORM_INFO for the dynamic linking case, and
in __libc_start_main () for the static linking case) to make sure the data is
available at the time of TLS initialization.
* sysdeps/powerpc/Makefile (sysdep-dl-routines): Add hwcapinfo.
(sysdep_routines): Likewise.
(sysdep-rtld-routines): Likewise.
[$(subdir) = nptl](tests): Add test-get_hwcap and test-get_hwcap-static
[$(subdir) = nptl](tests-static): test-get_hwcap-static
* sysdeps/powerpc/Versions: Added new
__parse_hwcap_and_convert_at_platform symbol to GLIBC-2.23.
* sysdeps/powerpc/hwcapinfo.c: New file.
(__tcb_parse_hwcap_and_convert_at_platform): New function to initialize
and parse hwcap, hwcap2 and platform number information.
* sysdeps/powerpc/hwcapinfo.h: New file. Creates global variables
to store HWCAP+HWCAP2 and platform number.
* sysdeps/powerpc/nptl/tcb-offsets.sym: Added new offsets
for HWCAP+HWCAP2 and platform number in the TCB.
* sysdeps/powerpc/nptl/tls.h: New functionality. Stores
the HWCAP, HWCAP2 and platform number in the TCB.
(dtv): Added new fields for HWCAP+HWCAP2 and platform number.
(TLS_INIT_TP): Included calls to add the hwcap and
at_platform values in the TCB in TP initialization.
(TLS_DEFINE_INIT_TP): Likewise.
(THREAD_GET_HWCAP): New macro.
(THREAD_SET_HWCAP): Likewise.
(THREAD_GET_AT_PLATFORM): Likewise.
(THREAD_SET_AT_PLATFORM): Likewise.
* sysdeps/powerpc/powerpc32/dl-machine.h:
(dl_platform_init): New function that calls
__parse_hwcap_and_convert_at_platform for the dymanic linking case for
powerpc32.
* sysdeps/powerpc/powerpc64/dl-machine.h: Likewise, for powerpc64.
* sysdeps/powerpc/test-get_hwcap-static.c: New file. Testcase for
this functionality, static linking case.
* sysdeps/powerpc/test-get_hwcap.c: New file. Likewise, dynamic
linking case.
* sysdeps/unix/sysv/linux/powerpc/libc-start.c: Added call to
__parse_hwcap_and_convert_at_platform for the static linking case.
* sysdeps/unix/sysv/linux/powerpc/powerpc32/ld.abilist:
Included the new __parse_hwcap_and_convert_at_platform symbol in the
ABI list for GLIBC 2.23.
* sysdeps/unix/sysv/linux/powerpc/powerpc64/ld-le.abilist:
Likewise.
* sysdeps/unix/sysv/linux/powerpc/powerpc64/ld.abilist:
Likewise.
Diffstat (limited to 'sysdeps/powerpc/hwcapinfo.c')
-rw-r--r-- | sysdeps/powerpc/hwcapinfo.c | 76 |
1 files changed, 76 insertions, 0 deletions
diff --git a/sysdeps/powerpc/hwcapinfo.c b/sysdeps/powerpc/hwcapinfo.c new file mode 100644 index 0000000000..a115ffccd9 --- /dev/null +++ b/sysdeps/powerpc/hwcapinfo.c @@ -0,0 +1,76 @@ +/* powerpc HWCAP/HWCAP2 and AT_PLATFORM data pre-processing. + Copyright (C) 2015 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + 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 + <http://www.gnu.org/licenses/>. */ + +#include <unistd.h> +#include <shlib-compat.h> +#include <dl-procinfo.h> + +uint64_t __tcb_hwcap __attribute__ ((visibility ("hidden"))); +uint32_t __tcb_platform __attribute__ ((visibility ("hidden"))); + +/* This function parses the HWCAP/HWCAP2 fields, adding the previous supported + ISA bits, as well as converting the AT_PLATFORM string to a number. This + data is stored in two global variables that can be used later by the + powerpc-specific code to store it into the TCB. */ +void +__tcb_parse_hwcap_and_convert_at_platform (void) +{ + + uint64_t h1, h2; + + /* Read AT_PLATFORM string from auxv and convert it to a number. */ + __tcb_platform = _dl_string_platform (GLRO (dl_platform)); + + /* Read HWCAP and HWCAP2 from auxv. */ + h1 = GLRO (dl_hwcap); + h2 = GLRO (dl_hwcap2); + + /* hwcap contains only the latest supported ISA, the code checks which is + and fills the previous supported ones. */ + + if (h2 & PPC_FEATURE2_ARCH_2_07) + h1 |= PPC_FEATURE_ARCH_2_06 + | PPC_FEATURE_ARCH_2_05 + | PPC_FEATURE_POWER5_PLUS + | PPC_FEATURE_POWER5 + | PPC_FEATURE_POWER4; + else if (h1 & PPC_FEATURE_ARCH_2_06) + h1 |= PPC_FEATURE_ARCH_2_05 + | PPC_FEATURE_POWER5_PLUS + | PPC_FEATURE_POWER5 + | PPC_FEATURE_POWER4; + else if (h1 & PPC_FEATURE_ARCH_2_05) + h1 |= PPC_FEATURE_POWER5_PLUS + | PPC_FEATURE_POWER5 + | PPC_FEATURE_POWER4; + else if (h1 & PPC_FEATURE_POWER5_PLUS) + h1 |= PPC_FEATURE_POWER5 + | PPC_FEATURE_POWER4; + else if (h1 & PPC_FEATURE_POWER5) + h1 |= PPC_FEATURE_POWER4; + + /* Consolidate both HWCAP and HWCAP2 into a single doubleword so that + we can read both in a single load later. */ + __tcb_hwcap = h2; + __tcb_hwcap = (h1 << 32) | __tcb_hwcap; + +} +#if IS_IN (rtld) +versioned_symbol (ld, __tcb_parse_hwcap_and_convert_at_platform, \ + __parse_hwcap_and_convert_at_platform, GLIBC_2_23); +#endif |