aboutsummaryrefslogtreecommitdiff
path: root/libitm/config
diff options
context:
space:
mode:
authorTorvald Riegel <triegel@redhat.com>2012-01-13 23:45:06 +0000
committerTorvald Riegel <torvald@gcc.gnu.org>2012-01-13 23:45:06 +0000
commit07b6642b935e1cd499a2aae071db06d845e39a8b (patch)
tree8ed0df69ae3d1543fa4811e7cb7e72a8d99333b5 /libitm/config
parent4cce1836bde85844781736f0f87b51ae9393da5f (diff)
libitm: Filter out undo writes that overlap with the libitm stack.
PR libitm/51855 * config/generic/tls.h (GTM::mask_stack_top): New. (GTM::mask_stack_bottom): Declare. * config/generic/tls.c (GTM::mask_stack_bottom): New. * local.cc (gtm_undolog::rollback): Filter out any updates that overlap the libitm stack. Add current transaction as parameter. * libitm_i.h (GTM::gtm_undolog::rollback): Adapt. * beginend.cc (GTM::gtm_thread::rollback): Adapt. * testsuite/libitm.c/stackundo.c: New test. From-SVN: r183172
Diffstat (limited to 'libitm/config')
-rw-r--r--libitm/config/generic/tls.cc7
-rw-r--r--libitm/config/generic/tls.h17
2 files changed, 24 insertions, 0 deletions
diff --git a/libitm/config/generic/tls.cc b/libitm/config/generic/tls.cc
index e502e50869b..f07d082b4ee 100644
--- a/libitm/config/generic/tls.cc
+++ b/libitm/config/generic/tls.cc
@@ -30,4 +30,11 @@ namespace GTM HIDDEN {
__thread gtm_thread_tls _gtm_thr_tls;
#endif
+// See tls.h for comments.
+void * __attribute__((noinline))
+mask_stack_bottom(gtm_thread *tx)
+{
+ return (uint8_t*)__builtin_dwarf_cfa() - 256;
+}
+
} // namespace GTM
diff --git a/libitm/config/generic/tls.h b/libitm/config/generic/tls.h
index 6bbdccf2be1..dfcd76a0dac 100644
--- a/libitm/config/generic/tls.h
+++ b/libitm/config/generic/tls.h
@@ -60,6 +60,23 @@ static inline abi_dispatch * abi_disp() { return _gtm_thr_tls.disp; }
static inline void set_abi_disp(abi_dispatch *x) { _gtm_thr_tls.disp = x; }
#endif
+#ifndef HAVE_ARCH_GTM_MASK_STACK
+// To filter out any updates that overlap the libitm stack, we define
+// gtm_mask_stack_top to the entry point to the library and
+// gtm_mask_stack_bottom to below the calling function (enforced with the
+// noinline attribute). This definition should be fine for all
+// stack-grows-down architectures.
+// FIXME We fake the bottom to be lower so that we are safe even if we might
+// call further functions (compared to where we called gtm_mask_stack_bottom
+// in the call hierarchy) to actually undo or redo writes (e.g., memcpy).
+// This is a completely arbitrary value; can we instead ensure that there are
+// no such calls, or can we determine a future-proof value otherwise?
+static inline void *
+mask_stack_top(gtm_thread *tx) { return tx->jb.cfa; }
+void * __attribute__((noinline))
+mask_stack_bottom(gtm_thread *tx);
+#endif
+
} // namespace GTM
#endif // LIBITM_TLS_H