aboutsummaryrefslogtreecommitdiff
path: root/sysdeps/powerpc/nptl
diff options
context:
space:
mode:
authorCarlos Eduardo Seo <cseo@linux.vnet.ibm.com>2015-10-22 19:26:58 -0500
committerTulio Magno Quites Machado Filho <tuliom@linux.vnet.ibm.com>2015-12-03 13:56:13 -0200
commit67385a01d229751569b6aac067ffdcd813a15d7a (patch)
tree2012071b67d002ad49438bd7d626f7b4514bbdce /sysdeps/powerpc/nptl
parentdb340c904dd519142025a09190bf48ad28152ab9 (diff)
downloadglibc-67385a01d229751569b6aac067ffdcd813a15d7a.zip
glibc-67385a01d229751569b6aac067ffdcd813a15d7a.tar.gz
glibc-67385a01d229751569b6aac067ffdcd813a15d7a.tar.bz2
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/nptl')
-rw-r--r--sysdeps/powerpc/nptl/tcb-offsets.sym8
-rw-r--r--sysdeps/powerpc/nptl/tls.h44
2 files changed, 49 insertions, 3 deletions
diff --git a/sysdeps/powerpc/nptl/tcb-offsets.sym b/sysdeps/powerpc/nptl/tcb-offsets.sym
index d955142..f580e69 100644
--- a/sysdeps/powerpc/nptl/tcb-offsets.sym
+++ b/sysdeps/powerpc/nptl/tcb-offsets.sym
@@ -19,7 +19,15 @@ POINTER_GUARD (offsetof (tcbhead_t, pointer_guard) - TLS_TCB_OFFSET - sizeof (
TAR_SAVE (offsetof (tcbhead_t, tar_save) - TLS_TCB_OFFSET - sizeof (tcbhead_t))
DSO_SLOT1 (offsetof (tcbhead_t, dso_slot1) - TLS_TCB_OFFSET - sizeof (tcbhead_t))
DSO_SLOT2 (offsetof (tcbhead_t, dso_slot2) - TLS_TCB_OFFSET - sizeof (tcbhead_t))
+#ifdef __powerpc64__
+TCB_AT_PLATFORM (offsetof (tcbhead_t, at_platform) - TLS_TCB_OFFSET - sizeof(tcbhead_t))
+#endif
TM_CAPABLE (offsetof (tcbhead_t, tm_capable) - TLS_TCB_OFFSET - sizeof (tcbhead_t))
+#ifndef __powerpc64__
+TCB_AT_PLATFORM (offsetof (tcbhead_t, at_platform) - TLS_TCB_OFFSET - sizeof(tcbhead_t))
+PADDING (offsetof (tcbhead_t, padding) - TLS_TCB_OFFSET - sizeof(tcbhead_t))
+#endif
+TCB_HWCAP (offsetof (tcbhead_t, hwcap) - TLS_TCB_OFFSET - sizeof (tcbhead_t))
#ifndef __ASSUME_PRIVATE_FUTEX
PRIVATE_FUTEX_OFFSET thread_offsetof (header.private_futex)
#endif
diff --git a/sysdeps/powerpc/nptl/tls.h b/sysdeps/powerpc/nptl/tls.h
index 1f3d97a..7b6682c 100644
--- a/sysdeps/powerpc/nptl/tls.h
+++ b/sysdeps/powerpc/nptl/tls.h
@@ -44,6 +44,8 @@ typedef union dtv
#ifndef __ASSEMBLER__
+# include <hwcapinfo.h>
+
/* Get system call information. */
# include <sysdep.h>
@@ -63,8 +65,24 @@ typedef union dtv
are private. */
typedef struct
{
+ /* Reservation for HWCAP data. To be accessed by GCC in
+ __builtin_cpu_supports(), so it is a part of public ABI. */
+ uint64_t hwcap;
+ /* Reservation for AT_PLATFORM data. To be accessed by GCC in
+ __builtin_cpu_is(), so it is a part of public ABI. Since there
+ are different ABIs for 32 and 64 bit, we put this field in a
+ previously empty padding space for powerpc64. */
+#ifndef __powerpc64__
+ /* Padding to maintain alignment. */
+ uint32_t padding;
+ uint32_t at_platform;
+#endif
/* Indicate if HTM capable (ISA 2.07). */
- int tm_capable;
+ uint32_t tm_capable;
+ /* Reservation for AT_PLATFORM data - powerpc64. */
+#ifdef __powerpc64__
+ uint32_t at_platform;
+#endif
/* Reservation for Dynamic System Optimizer ABI. */
uintptr_t dso_slot2;
uintptr_t dso_slot1;
@@ -134,7 +152,9 @@ register void *__thread_register __asm__ ("r13");
# define TLS_INIT_TP(tcbp) \
({ \
__thread_register = (void *) (tcbp) + TLS_TCB_OFFSET; \
- THREAD_SET_TM_CAPABLE (GLRO (dl_hwcap2) & PPC_FEATURE2_HAS_HTM ? 1 : 0); \
+ THREAD_SET_TM_CAPABLE (__tcb_hwcap & PPC_FEATURE2_HAS_HTM ? 1 : 0); \
+ THREAD_SET_HWCAP (__tcb_hwcap); \
+ THREAD_SET_AT_PLATFORM (__tcb_platform); \
NULL; \
})
@@ -142,7 +162,11 @@ register void *__thread_register __asm__ ("r13");
# define TLS_DEFINE_INIT_TP(tp, pd) \
void *tp = (void *) (pd) + TLS_TCB_OFFSET + TLS_PRE_TCB_SIZE; \
(((tcbhead_t *) ((char *) tp - TLS_TCB_OFFSET))[-1].tm_capable) = \
- THREAD_GET_TM_CAPABLE ();
+ THREAD_GET_TM_CAPABLE (); \
+ (((tcbhead_t *) ((char *) tp - TLS_TCB_OFFSET))[-1].hwcap) = \
+ THREAD_GET_HWCAP (); \
+ (((tcbhead_t *) ((char *) tp - TLS_TCB_OFFSET))[-1].at_platform) = \
+ THREAD_GET_AT_PLATFORM ();
/* Return the address of the dtv for the current thread. */
# define THREAD_DTV() \
@@ -203,6 +227,20 @@ register void *__thread_register __asm__ ("r13");
# define THREAD_SET_TM_CAPABLE(value) \
(THREAD_GET_TM_CAPABLE () = (value))
+/* hwcap field in TCB head. */
+# define THREAD_GET_HWCAP() \
+ (((tcbhead_t *) ((char *) __thread_register \
+ - TLS_TCB_OFFSET))[-1].hwcap)
+# define THREAD_SET_HWCAP(value) \
+ (THREAD_GET_HWCAP () = (value))
+
+/* at_platform field in TCB head. */
+# define THREAD_GET_AT_PLATFORM() \
+ (((tcbhead_t *) ((char *) __thread_register \
+ - TLS_TCB_OFFSET))[-1].at_platform)
+# define THREAD_SET_AT_PLATFORM(value) \
+ (THREAD_GET_AT_PLATFORM () = (value))
+
/* l_tls_offset == 0 is perfectly valid on PPC, so we have to use some
different value to mean unset l_tls_offset. */
# define NO_TLS_OFFSET -1