aboutsummaryrefslogtreecommitdiff
path: root/sysdeps
diff options
context:
space:
mode:
authorSergey Bugaev <bugaevc@gmail.com>2023-02-18 23:37:09 +0300
committerSamuel Thibault <samuel.thibault@ens-lyon.org>2023-02-20 00:32:35 +0100
commite48f33e76be2a3baa920b7e9f472354f7ff0c0a6 (patch)
tree91f9a53fb29a3074d77dc511af46290d94b007cc /sysdeps
parenta307e1b31551821946b242ca98f5db9e7d9f558a (diff)
downloadglibc-e48f33e76be2a3baa920b7e9f472354f7ff0c0a6.tar
glibc-e48f33e76be2a3baa920b7e9f472354f7ff0c0a6.tar.gz
glibc-e48f33e76be2a3baa920b7e9f472354f7ff0c0a6.tar.bz2
glibc-e48f33e76be2a3baa920b7e9f472354f7ff0c0a6.zip
hurd: Move thread state manipulation into _hurd_tls_new ()
This is going to be done differently on x86_64. Signed-off-by: Sergey Bugaev <bugaevc@gmail.com> Message-Id: <20230218203717.373211-2-bugaevc@gmail.com>
Diffstat (limited to 'sysdeps')
-rw-r--r--sysdeps/mach/hurd/i386/tls.h25
1 files changed, 20 insertions, 5 deletions
diff --git a/sysdeps/mach/hurd/i386/tls.h b/sysdeps/mach/hurd/i386/tls.h
index 590abd47fe..0f8dd24145 100644
--- a/sysdeps/mach/hurd/i386/tls.h
+++ b/sysdeps/mach/hurd/i386/tls.h
@@ -378,16 +378,25 @@ _hurd_tls_fork (thread_t child, thread_t orig, struct i386_thread_state *state)
}
static inline kern_return_t __attribute__ ((unused))
-_hurd_tls_new (thread_t child, struct i386_thread_state *state, tcbhead_t *tcb)
+_hurd_tls_new (thread_t child, tcbhead_t *tcb)
{
+ error_t err;
+ /* Fetch the target thread's state. */
+ struct i386_thread_state state;
+ mach_msg_type_number_t state_count = i386_THREAD_STATE_COUNT;
+ err = __thread_get_state (child, i386_REGS_SEGS_STATE,
+ (thread_state_t) &state,
+ &state_count);
+ if (err)
+ return err;
+ assert (state_count == i386_THREAD_STATE_COUNT);
/* Fetch the selector set by _hurd_tls_init. */
int sel;
asm ("mov %%gs, %w0" : "=q" (sel) : "0" (0));
- if (sel == state->ds) /* _hurd_tls_init was never called. */
+ if (sel == state.ds) /* _hurd_tls_init was never called. */
return 0;
HURD_TLS_DESC_DECL (desc, tcb);
- error_t err;
tcb->tcb = tcb;
tcb->self = child;
@@ -397,8 +406,14 @@ _hurd_tls_new (thread_t child, struct i386_thread_state *state, tcbhead_t *tcb)
else
err = __i386_set_gdt (child, &sel, desc);
- state->gs = sel;
- return err;
+ if (err)
+ return err;
+
+ /* Update gs to use the selector. */
+ state.gs = sel;
+ return __thread_set_state (child, i386_REGS_SEGS_STATE,
+ (thread_state_t) &state,
+ state_count);
}
/* Global scope switch support. */