* [PATCH glibc] Define PC, SP and SYSRETURN for hurd x86_64
@ 2023-02-15 6:16 Flavio Cruz
2023-02-15 6:42 ` Sergey Bugaev
2023-02-20 0:33 ` Samuel Thibault
0 siblings, 2 replies; 3+ messages in thread
From: Flavio Cruz @ 2023-02-15 6:16 UTC (permalink / raw)
To: bug-hurd, libc-alpha
Moved thread_state.h to x86 directory since we only need to customize
those 3 definitions.
---
sysdeps/mach/{i386 => x86}/thread_state.h | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
rename sysdeps/mach/{i386 => x86}/thread_state.h (90%)
diff --git a/sysdeps/mach/i386/thread_state.h b/sysdeps/mach/x86/thread_state.h
similarity index 90%
rename from sysdeps/mach/i386/thread_state.h
rename to sysdeps/mach/x86/thread_state.h
index 4e6ce1f7dd..5be0bec150 100644
--- a/sysdeps/mach/i386/thread_state.h
+++ b/sysdeps/mach/x86/thread_state.h
@@ -16,8 +16,8 @@
License along with the GNU C Library; if not, see
<https://www.gnu.org/licenses/>. */
-#ifndef _MACH_I386_THREAD_STATE_H
-#define _MACH_I386_THREAD_STATE_H 1
+#ifndef _MACH_X86_THREAD_STATE_H
+#define _MACH_X86_THREAD_STATE_H 1
#include <mach/machine/thread_status.h>
@@ -29,9 +29,15 @@
#define machine_thread_state i386_thread_state
+#ifdef __x86_64__
+#define PC rip
+#define SP ursp
+#define SYSRETURN rax
+#else
#define PC eip
#define SP uesp
#define SYSRETURN eax
+#endif
#define MACHINE_THREAD_STATE_FIX_NEW(ts) do { \
asm ("mov %%cs, %w0" : "=q" ((ts)->cs)); \
@@ -50,4 +56,4 @@ struct machine_thread_all_state
#include <sysdeps/mach/thread_state.h>
-#endif /* mach/i386/thread_state.h */
+#endif /* mach/x86/thread_state.h */
--
2.39.1
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH glibc] Define PC, SP and SYSRETURN for hurd x86_64
2023-02-15 6:16 [PATCH glibc] Define PC, SP and SYSRETURN for hurd x86_64 Flavio Cruz
@ 2023-02-15 6:42 ` Sergey Bugaev
2023-02-20 0:33 ` Samuel Thibault
1 sibling, 0 replies; 3+ messages in thread
From: Sergey Bugaev @ 2023-02-15 6:42 UTC (permalink / raw)
To: Flavio Cruz; +Cc: bug-hurd, libc-alpha
On Wed, Feb 15, 2023 at 9:17 AM Flavio Cruz <flaviocruz@gmail.com> wrote:
>
> Moved thread_state.h to x86 directory since we only need to customize
> those 3 definitions.
No, that won't be enough. We also need to customize those
MACHINE_THREAD_STATE_FLAVOR definitions to include the potential new
i386_FSGS_BASE_STATE that we were discussing recently [0].
[0] https://sourceware.org/pipermail/libc-alpha/2023-February/145528.html
I was just looking at this file yesterday and concluded the
MACHINE_THREAD_STATE_FLAVOR / MACHINE_NEW_THREAD_STATE_FLAVOR
abstraction cannot work as is for x86_64, because half of the time
it's used for indeed accessing registers like SP and PC, and other
times it's used to access TLS/TCB. So this needs to be two distinct
definitions, and all the users inside glibc have to be reworked.
So let's please not rush with moving this to x86/
Sergey
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH glibc] Define PC, SP and SYSRETURN for hurd x86_64
2023-02-15 6:16 [PATCH glibc] Define PC, SP and SYSRETURN for hurd x86_64 Flavio Cruz
2023-02-15 6:42 ` Sergey Bugaev
@ 2023-02-20 0:33 ` Samuel Thibault
1 sibling, 0 replies; 3+ messages in thread
From: Samuel Thibault @ 2023-02-20 0:33 UTC (permalink / raw)
To: Flavio Cruz; +Cc: bug-hurd, libc-alpha
Applied, thanks!
Flavio Cruz, le mer. 15 févr. 2023 01:16:38 -0500, a ecrit:
> Moved thread_state.h to x86 directory since we only need to customize
> those 3 definitions.
> ---
> sysdeps/mach/{i386 => x86}/thread_state.h | 12 +++++++++---
> 1 file changed, 9 insertions(+), 3 deletions(-)
> rename sysdeps/mach/{i386 => x86}/thread_state.h (90%)
>
> diff --git a/sysdeps/mach/i386/thread_state.h b/sysdeps/mach/x86/thread_state.h
> similarity index 90%
> rename from sysdeps/mach/i386/thread_state.h
> rename to sysdeps/mach/x86/thread_state.h
> index 4e6ce1f7dd..5be0bec150 100644
> --- a/sysdeps/mach/i386/thread_state.h
> +++ b/sysdeps/mach/x86/thread_state.h
> @@ -16,8 +16,8 @@
> License along with the GNU C Library; if not, see
> <https://www.gnu.org/licenses/>. */
>
> -#ifndef _MACH_I386_THREAD_STATE_H
> -#define _MACH_I386_THREAD_STATE_H 1
> +#ifndef _MACH_X86_THREAD_STATE_H
> +#define _MACH_X86_THREAD_STATE_H 1
>
> #include <mach/machine/thread_status.h>
>
> @@ -29,9 +29,15 @@
>
> #define machine_thread_state i386_thread_state
>
> +#ifdef __x86_64__
> +#define PC rip
> +#define SP ursp
> +#define SYSRETURN rax
> +#else
> #define PC eip
> #define SP uesp
> #define SYSRETURN eax
> +#endif
>
> #define MACHINE_THREAD_STATE_FIX_NEW(ts) do { \
> asm ("mov %%cs, %w0" : "=q" ((ts)->cs)); \
> @@ -50,4 +56,4 @@ struct machine_thread_all_state
>
> #include <sysdeps/mach/thread_state.h>
>
> -#endif /* mach/i386/thread_state.h */
> +#endif /* mach/x86/thread_state.h */
> --
> 2.39.1
>
>
--
Samuel
---
Pour une évaluation indépendante, transparente et rigoureuse !
Je soutiens la Commission d'Évaluation de l'Inria.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-02-20 11:49 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-02-15 6:16 [PATCH glibc] Define PC, SP and SYSRETURN for hurd x86_64 Flavio Cruz
2023-02-15 6:42 ` Sergey Bugaev
2023-02-20 0:33 ` Samuel Thibault
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).