From: Samuel Thibault <samuel.thibault@gnu.org>
To: Sergey Bugaev <bugaevc@gmail.com>
Cc: bug-hurd@gnu.org, libc-alpha@sourceware.org,
"Flávio Cruz" <flaviocruz@gmail.com>
Subject: Re: [RFC PATCH 1/9] hurd: Move thread state manipulation into _hurd_tls_new ()
Date: Mon, 20 Feb 2023 00:32:46 +0100 [thread overview]
Message-ID: <20230219233246.jhl4ohsescupm5ox@begin> (raw)
In-Reply-To: <20230218203717.373211-2-bugaevc@gmail.com>
Applied, thanks!
Sergey Bugaev, le sam. 18 févr. 2023 23:37:09 +0300, a ecrit:
> This is going to be done differently on x86_64.
>
> Signed-off-by: Sergey Bugaev <bugaevc@gmail.com>
> ---
> mach/setup-thread.c | 18 ++----------------
> sysdeps/mach/hurd/i386/tls.h | 25 ++++++++++++++++++++-----
> 2 files changed, 22 insertions(+), 21 deletions(-)
>
> diff --git a/mach/setup-thread.c b/mach/setup-thread.c
> index 6ce5c13d..ae24a149 100644
> --- a/mach/setup-thread.c
> +++ b/mach/setup-thread.c
> @@ -83,25 +83,11 @@ weak_alias (__mach_setup_thread, mach_setup_thread)
> kern_return_t
> __mach_setup_tls (thread_t thread)
> {
> - kern_return_t error;
> - struct machine_thread_state ts;
> - mach_msg_type_number_t tssize = MACHINE_THREAD_STATE_COUNT;
> - tcbhead_t *tcb;
> -
> - tcb = _dl_allocate_tls (NULL);
> + tcbhead_t *tcb = _dl_allocate_tls (NULL);
> if (tcb == NULL)
> return KERN_RESOURCE_SHORTAGE;
>
> - if (error = __thread_get_state (thread, MACHINE_THREAD_STATE_FLAVOR,
> - (natural_t *) &ts, &tssize))
> - return error;
> - assert (tssize == MACHINE_THREAD_STATE_COUNT);
> -
> - _hurd_tls_new (thread, &ts, tcb);
> -
> - error = __thread_set_state (thread, MACHINE_THREAD_STATE_FLAVOR,
> - (natural_t *) &ts, tssize);
> - return error;
> + return _hurd_tls_new (thread, tcb);
> }
>
> weak_alias (__mach_setup_tls, mach_setup_tls)
> diff --git a/sysdeps/mach/hurd/i386/tls.h b/sysdeps/mach/hurd/i386/tls.h
> index 590abd47..0f8dd241 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. */
> --
> 2.39.2
>
>
--
Samuel
---
Pour une évaluation indépendante, transparente et rigoureuse !
Je soutiens la Commission d'Évaluation de l'Inria.
next prev parent reply other threads:[~2023-02-20 10:32 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-02-18 20:37 [RFC PATCH 0/9] More x86_64-gnu glibc work Sergey Bugaev
2023-02-18 20:37 ` [RFC PATCH 1/9] hurd: Move thread state manipulation into _hurd_tls_new () Sergey Bugaev
2023-02-19 23:32 ` Samuel Thibault [this message]
2023-02-18 20:37 ` [RFC PATCH 2/9] hurd: Use proper integer types Sergey Bugaev
2023-02-19 23:33 ` Samuel Thibault
2023-02-18 20:37 ` [RFC PATCH 3/9] hurd: Fix xattr function return type Sergey Bugaev
2023-02-19 23:34 ` Samuel Thibault
2023-02-18 20:37 ` [RFC PATCH 4/9] hurd: Make timer_t pointer-sized Sergey Bugaev
2023-02-19 23:35 ` Samuel Thibault
2023-02-18 20:37 ` [RFC PATCH 5/9] hurd: Simplify init-first.c a bit Sergey Bugaev
2023-02-19 23:45 ` Samuel Thibault
2023-02-18 20:37 ` [RFC PATCH 6/9] mach: Use PAGE_SIZE Sergey Bugaev
2023-02-19 23:47 ` Samuel Thibault
2023-02-18 20:37 ` [RFC PATCH 7/9] hurd: Generalize init-first.c to support x86_64 Sergey Bugaev
2023-02-20 0:01 ` Samuel Thibault
2023-02-20 16:16 ` Sergey Bugaev
2023-02-20 17:10 ` Sergey Bugaev
2023-02-20 17:31 ` Samuel Thibault
2023-02-20 17:27 ` Noah Goldstein
2023-02-18 20:37 ` [RFC PATCH 8/9 gnumach] Add i386_fsgs_base_state Sergey Bugaev
2023-02-18 20:37 ` [RFC PATCH 9/9] hurd, htl: Add some more x86_64-specific code Sergey Bugaev
2023-02-20 0:30 ` Samuel Thibault
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230219233246.jhl4ohsescupm5ox@begin \
--to=samuel.thibault@gnu.org \
--cc=bug-hurd@gnu.org \
--cc=bugaevc@gmail.com \
--cc=flaviocruz@gmail.com \
--cc=libc-alpha@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).