summaryrefslogtreecommitdiff
path: root/sysdeps/mach/i386
diff options
context:
space:
mode:
authorSamuel Thibault <samuel.thibault@ens-lyon.org>2018-03-17 03:17:36 +0100
committerSamuel Thibault <samuel.thibault@ens-lyon.org>2018-03-17 03:17:36 +0100
commitf8baf2a2242029600beb213d3f042e7c0482e502 (patch)
tree43df708e6da8a0cb7520bb218d6ebfcecfe54c86 /sysdeps/mach/i386
parentc553cd6f7e939ae4ef62b52b3c55fbe76dddecee (diff)
hurd: add TLS support
* sysdeps/generic/thread_state.h (MACHINE_NEW_THREAD_STATE_FLAVOR): Define macro. * sysdeps/mach/thread_state.h (MACHINE_THREAD_STATE_FIX_NEW): New macro. * sysdeps/mach/i386/thread_state.h (MACHINE_NEW_THREAD_STATE_FLAVOR): New macro, defined to i386_THREAD_STATE. (MACHINE_THREAD_STATE_FLAVOR): Define to i386_REGS_SEGS_STATE instead of i386_THREAD_STATE. (MACHINE_THREAD_STATE_FIX_NEW): New macro, reads segments. * sysdeps/mach/hurd/i386/trampoline.c (_hurd_setup_sighandler): Use i386_REGS_SEGS_STATE instead of i386_THREAD_STATE. * sysdeps/mach/hurd/i386/tls.h (TCB_ALIGNMENT, HURD_SEL_LDT): New macros. (_hurd_tls_fork): Add original thread parameter, Duplicate existing LDT descriptor instead of creating a new one. (_hurd_tls_new): New function, creates a new descriptor and updates tcb. * mach/setup-thread.c: Include <ldsodefs.h>. (__mach_setup_thread): Call _dl_allocate_tls, pass MACHINE_NEW_THREAD_STATE_FLAVOR to __thread_set_state instead of MACHINE_THREAD_STATE_FLAVOR, before getting MACHINE_THREAD_STATE_FLAVOR, calling _hurd_tls_new, and setting MACHINE_THREAD_STATE_FLAVOR with the result. * hurd/hurdfault.c (_hurdsig_fault_init): Call MACHINE_THREAD_STATE_FIX_NEW. * sysdeps/mach/hurd/fork.c (__fork): Call _hurd_tls_fork for sigthread too. Add original thread parameter.
Diffstat (limited to 'sysdeps/mach/i386')
-rw-r--r--sysdeps/mach/i386/thread_state.h13
1 files changed, 12 insertions, 1 deletions
diff --git a/sysdeps/mach/i386/thread_state.h b/sysdeps/mach/i386/thread_state.h
index 56d91dfdb7..be3c8a9cee 100644
--- a/sysdeps/mach/i386/thread_state.h
+++ b/sysdeps/mach/i386/thread_state.h
@@ -21,7 +21,10 @@
#include <mach/machine/thread_status.h>
-#define MACHINE_THREAD_STATE_FLAVOR i386_THREAD_STATE
+/* This lets the kernel define segments for a new thread. */
+#define MACHINE_NEW_THREAD_STATE_FLAVOR i386_THREAD_STATE
+/* This makes the kernel load our segments descriptors. */
+#define MACHINE_THREAD_STATE_FLAVOR i386_REGS_SEGS_STATE
#define MACHINE_THREAD_STATE_COUNT i386_THREAD_STATE_COUNT
#define machine_thread_state i386_thread_state
@@ -30,6 +33,14 @@
#define SP uesp
#define SYSRETURN eax
+#define MACHINE_THREAD_STATE_FIX_NEW(ts) do { \
+ asm ("mov %%cs, %w0" : "=q" ((ts)->cs)); \
+ asm ("mov %%ds, %w0" : "=q" ((ts)->ds)); \
+ asm ("mov %%es, %w0" : "=q" ((ts)->es)); \
+ asm ("mov %%fs, %w0" : "=q" ((ts)->fs)); \
+ asm ("mov %%gs, %w0" : "=q" ((ts)->gs)); \
+} while(0)
+
struct machine_thread_all_state
{
int set; /* Mask of bits (1 << FLAVOR). */