The patch below seems to toggle between crash (#if 1) and working (#if 0).

Matt: we verified some time ago that rdhwr works in principle, but something
must go wrong somewhere (tm).

Testcase: invoke gdb (no params), if you get to the (gdb) prompt, it works.

Carefull: for testing you need to replace both libpthread.so and ld.elf_so!

Martin


Index: mcontext.h
===================================================================
RCS file: /cvsroot/src/sys/arch/mips/include/mcontext.h,v
retrieving revision 1.20
diff -u -r1.20 mcontext.h
--- mcontext.h  12 Sep 2012 15:09:49 -0000      1.20
+++ mcontext.h  19 May 2015 15:25:45 -0000
@@ -195,11 +195,15 @@
 __CTASSERT(TLS_TP_OFFSET + sizeof(struct tls_tcb) < 0x8000);
 __CTASSERT(TLS_TP_OFFSET % sizeof(struct tls_tcb) == 0);
 
+void _lwp_setprivate(void *);
+void *_lwp_getprivate(void);
+
 static __inline struct tls_tcb *
 __lwp_gettcb_fast(void)
 {
        struct tls_tcb *__tcb;
 
+#if 1
        /*
         * Only emit a rdhwr $3, $29 so the kernel can quickly emulate it.
         */
@@ -213,11 +217,13 @@
            : [__tcb]"=r"(__tcb)
            : [__offset]"n"(-(TLS_TP_OFFSET + sizeof(*__tcb)))
            : "v1");
+#else
+       __tcb = _lwp_getprivate();
+       __tcb -= TLS_TP_OFFSET / sizeof(*__tcb) + 1;
+#endif
        return __tcb;
 }
 
-void _lwp_setprivate(void *);
-
 static inline void
 __lwp_settcb(struct tls_tcb *__tcb)
 {

Reply via email to