This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

PowerPC: Reserve TCB space for EBB framework


Hi all,

This patch reserves four pointer to be used in future Event-Based
Branch (EBB) framework for PowerPC. The EBB is a new facility
described at Power ISA 2.07, Book II, Chapter 7 and POWER8 will
implement it for Processor Monitoring Units (PMU). The idea is
to trigger some function callback when certain PMU event (for
instance a branch prediction counter) happen.

Initial kernel support is already upstream (commit
9353374b8e1585d5fa47a1e5c1d3e9155dd0eb7c), however full support
(EBB initialization using perf subsystem) is not already complete.

The idea is to provide an API to a callback function (thread_handler
) along with per-thread context field (context_pointer) to be used
along with EBB field. This initial patch is to push the TCB size
adjustment on 2.18.

---

2013-05-30  Adhemerval Zanella  <azanella@linux.vnet.ibm.com>

	* nptl/sysdeps/powerpc/tcb-offsets.sym (STACK_GUARD): Add TCB
	stack_guard offset.
	* nptl/sysdeps/powerpc/tls.h (tcbhead_t): Add Event-Based Branch
	fields.
	* sysdeps/powerpc/powerpc32/stackguard-macros.h (STACK_CHK_GUARD): 
	Adjust the stack_guard offset.
	* sysdeps/powerpc/powerpc64/stackguard-macros.h: Likewise.

--

diff --git a/nptl/sysdeps/powerpc/tcb-offsets.sym b/nptl/sysdeps/powerpc/tcb-offsets.sym
index 8ac133d..39d05cd 100644
--- a/nptl/sysdeps/powerpc/tcb-offsets.sym
+++ b/nptl/sysdeps/powerpc/tcb-offsets.sym
@@ -15,6 +15,7 @@ MULTIPLE_THREADS_OFFSET               thread_offsetof (header.multiple_threads)
 PID                            thread_offsetof (pid)
 TID                            thread_offsetof (tid)
 POINTER_GUARD                  (offsetof (tcbhead_t, pointer_guard) - TLS_TCB_OFFSET - sizeof (tcbhead_t))
+STACK_GUARD                    (offsetof (tcbhead_t, stack_guard) - TLS_TCB_OFFSET - sizeof (tcbhead_t))
 #ifndef __ASSUME_PRIVATE_FUTEX
 PRIVATE_FUTEX_OFFSET           thread_offsetof (header.private_futex)
 #endif
diff --git a/nptl/sysdeps/powerpc/tls.h b/nptl/sysdeps/powerpc/tls.h
index 46dac9e..56198fa 100644
--- a/nptl/sysdeps/powerpc/tls.h
+++ b/nptl/sysdeps/powerpc/tls.h
@@ -64,6 +64,10 @@ typedef struct
   uintptr_t pointer_guard;
   uintptr_t stack_guard;
   dtv_t *dtv;
+  uintptr_t thread_handler;
+  uintptr_t context_pointer;
+  uintptr_t reserved1;
+  uintptr_t reserved2;
 } tcbhead_t;
 
 /* This is the size of the initial TCB.  */
diff --git a/sysdeps/powerpc/powerpc32/stackguard-macros.h b/sysdeps/powerpc/powerpc32/stackguard-macros.h
index 839f6a4..2165bfc 100644
--- a/sysdeps/powerpc/powerpc32/stackguard-macros.h
+++ b/sysdeps/powerpc/powerpc32/stackguard-macros.h
@@ -1,4 +1,7 @@
 #include <stdint.h>
+#include "tcb-offsets.h"
 
 #define STACK_CHK_GUARD \
-  ({ uintptr_t x; asm ("lwz %0,-28680(2)" : "=r" (x)); x; })
+  ({ uintptr_t x;                                              \
+     asm ("lwz %0,%1(2)" : "=r" (x)                            \
+          : "i" (STACK_GUARD)); x; })
diff --git a/sysdeps/powerpc/powerpc64/stackguard-macros.h b/sysdeps/powerpc/powerpc64/stackguard-macros.h
index 9da879c..2f59a8a 100644
--- a/sysdeps/powerpc/powerpc64/stackguard-macros.h
+++ b/sysdeps/powerpc/powerpc64/stackguard-macros.h
@@ -1,4 +1,7 @@
 #include <stdint.h>
+#include "tcb-offsets.h"
 
 #define STACK_CHK_GUARD \
-  ({ uintptr_t x; asm ("ld %0,-28688(13)" : "=r" (x)); x; })
+  ({ uintptr_t x;                                              \
+     asm ("ld %0,%1(13)" : "=r" (x)                            \
+         : "i" (STACK_GUARD)); x; })
-- 
1.7.1


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]