GNU bug report logs -
#63333
[PATCH] Add hurd-amd64 support
Previous Next
To reply to this bug, email your comments to 63333 AT debbugs.gnu.org.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
bug-diffutils <at> gnu.org
:
bug#63333
; Package
diffutils
.
(Sat, 06 May 2023 18:34:02 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
Samuel Thibault <samuel.thibault <at> ens-lyon.org>
:
New bug report received and forwarded. Copy sent to
bug-diffutils <at> gnu.org
.
(Sat, 06 May 2023 18:34:02 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
This adds SIGSEGV_FAULT_STACKPOINTER for the hurd-amd64 case
--- ./lib/sigsegv.c.original 2023-05-05 10:45:54.673751100 +0000
+++ ./lib/sigsegv.c 2023-05-05 10:48:47.903577554 +0000
@@ -351,6 +351,17 @@
"old esp, if trapped from user". */
# define SIGSEGV_FAULT_STACKPOINTER scp->sc_uesp
+# elif defined __x86_64__
+
+/* scp points to a 'struct sigcontext' (defined in
+ glibc/sysdeps/mach/hurd/x86_64/bits/sigcontext.h).
+ The registers of this struct get pushed on the stack through
+ gnumach/x86_64/i386/locore.S:trapall. */
+/* Both sc_rsp and sc_ursp appear to have the same value.
+ It appears more reliable to use sc_ursp because it is labelled as
+ "old rsp, if trapped from user". */
+# define SIGSEGV_FAULT_STACKPOINTER scp->sc_ursp
+
# endif
#endif
Information forwarded
to
bug-diffutils <at> gnu.org
:
bug#63333
; Package
diffutils
.
(Mon, 08 May 2023 10:32:01 GMT)
Full text and
rfc822 format available.
Message #8 received at submit <at> debbugs.gnu.org (full text, mbox):
On Sat, May 6, 2023 at 8:34 PM Samuel Thibault
<samuel.thibault <at> ens-lyon.org> wrote:
> This adds SIGSEGV_FAULT_STACKPOINTER for the hurd-amd64 case
>
> --- ./lib/sigsegv.c.original 2023-05-05 10:45:54.673751100 +0000
> +++ ./lib/sigsegv.c 2023-05-05 10:48:47.903577554 +0000
> @@ -351,6 +351,17 @@
> "old esp, if trapped from user". */
> # define SIGSEGV_FAULT_STACKPOINTER scp->sc_uesp
>
> +# elif defined __x86_64__
> +
> +/* scp points to a 'struct sigcontext' (defined in
> + glibc/sysdeps/mach/hurd/x86_64/bits/sigcontext.h).
> + The registers of this struct get pushed on the stack through
> + gnumach/x86_64/i386/locore.S:trapall. */
> +/* Both sc_rsp and sc_ursp appear to have the same value.
> + It appears more reliable to use sc_ursp because it is labelled as
> + "old rsp, if trapped from user". */
> +# define SIGSEGV_FAULT_STACKPOINTER scp->sc_ursp
> +
> # endif
>
> #endif
Hi Samuel, thanks. This belongs in gnulib, so cc'ing that list.
Information forwarded
to
bug-diffutils <at> gnu.org
:
bug#63333
; Package
diffutils
.
(Mon, 08 May 2023 10:32:02 GMT)
Full text and
rfc822 format available.
Information forwarded
to
bug-diffutils <at> gnu.org
:
bug#63333
; Package
diffutils
.
(Fri, 12 May 2023 19:39:01 GMT)
Full text and
rfc822 format available.
Message #14 received at submit <at> debbugs.gnu.org (full text, mbox):
Samuel Thibault <samuel.thibault <at> ens-lyon.org> wrote:
> > This adds SIGSEGV_FAULT_STACKPOINTER for the hurd-amd64 case
> >
> > --- ./lib/sigsegv.c.original 2023-05-05 10:45:54.673751100 +0000
> > +++ ./lib/sigsegv.c 2023-05-05 10:48:47.903577554 +0000
> > @@ -351,6 +351,17 @@
> > "old esp, if trapped from user". */
> > # define SIGSEGV_FAULT_STACKPOINTER scp->sc_uesp
> >
> > +# elif defined __x86_64__
> > +
> > +/* scp points to a 'struct sigcontext' (defined in
> > + glibc/sysdeps/mach/hurd/x86_64/bits/sigcontext.h).
> > + The registers of this struct get pushed on the stack through
> > + gnumach/x86_64/i386/locore.S:trapall. */
> > +/* Both sc_rsp and sc_ursp appear to have the same value.
> > + It appears more reliable to use sc_ursp because it is labelled as
> > + "old rsp, if trapped from user". */
> > +# define SIGSEGV_FAULT_STACKPOINTER scp->sc_ursp
> > +
> > # endif
> >
> > #endif
Thanks Samuel. The definition of SIGSEGV_FAULT_STACKPOINTER seems correct in
this patch, but the comments are not. I am applying this instead.
I'm calling this "tentative" support for Hurd/x86_64, because
- I have no way to test it,
- some of the code paths involved seem to be incorrect so far, see
https://lists.gnu.org/archive/html/bug-hurd/2023-05/msg00207.html
2023-05-12 Bruno Haible <bruno <at> clisp.org>
sigsegv: Add tentative support for Hurd/x86_64.
Reported by Samuel Thibault <samuel.thibault <at> ens-lyon.org>.
* lib/sigsegv.c: Update from libsigsegv/src/fault-hurd-i386.h.
diff --git a/lib/sigsegv.c b/lib/sigsegv.c
index 5e943e4d5d..aadba4e060 100644
--- a/lib/sigsegv.c
+++ b/lib/sigsegv.c
@@ -365,12 +365,26 @@ int libsigsegv_version = LIBSIGSEGV_VERSION;
# define SIGSEGV_FAULT_ADDRESS (unsigned long) code
# define SIGSEGV_FAULT_CONTEXT scp
-# if defined __i386__
+# if defined __x86_64__
+/* 64 bit registers */
+
+/* scp points to a 'struct sigcontext' (defined in
+ glibc/sysdeps/mach/hurd/x86_64/bits/sigcontext.h).
+ The registers, at the moment the signal occurred, get pushed on the stack
+ through gnumach/x86_64/locore.S:alltraps and then copied into the struct
+ through glibc/sysdeps/mach/hurd/x86/trampoline.c. */
+/* sc_rsp is unused (not set by gnumach/x86_64/locore.S:alltraps). We need
+ to use sc_ursp. */
+# define SIGSEGV_FAULT_STACKPOINTER scp->sc_ursp
+
+# elif defined __i386__
+/* 32 bit registers */
/* scp points to a 'struct sigcontext' (defined in
glibc/sysdeps/mach/hurd/i386/bits/sigcontext.h).
- The registers of this struct get pushed on the stack through
- gnumach/i386/i386/locore.S:trapall. */
+ The registers, at the moment the signal occurred, get pushed on the stack
+ through gnumach/i386/i386/locore.S:alltraps and then copied into the struct
+ through glibc/sysdeps/mach/hurd/x86/trampoline.c. */
/* Both sc_esp and sc_uesp appear to have the same value.
It appears more reliable to use sc_uesp because it is labelled as
"old esp, if trapped from user". */
Information forwarded
to
bug-diffutils <at> gnu.org
:
bug#63333
; Package
diffutils
.
(Fri, 12 May 2023 19:39:02 GMT)
Full text and
rfc822 format available.
Information forwarded
to
bug-diffutils <at> gnu.org
:
bug#63333
; Package
diffutils
.
(Mon, 15 May 2023 17:03:01 GMT)
Full text and
rfc822 format available.
Message #20 received at submit <at> debbugs.gnu.org (full text, mbox):
I committed:
> 2023-05-12 Bruno Haible <bruno <at> clisp.org>
>
> sigsegv: Add tentative support for Hurd/x86_64.
> Reported by Samuel Thibault <samuel.thibault <at> ens-lyon.org>.
> * lib/sigsegv.c: Update from libsigsegv/src/fault-hurd-i386.h.
This was not sufficient. Sergey Bugaev pointed out that
- my comments were wrong,
- the handler's parameter list needs to include 'long code', not 'int code',
for x86_64.
This patch fixes it, in sync with libsigsegv.
2023-05-15 Bruno Haible <bruno <at> clisp.org>
sigsegv: Add tentative support for Hurd/x86_64.
Based on explanations by Sergey Bugaev <bugaevc <at> gmail.com>.
* lib/sigsegv.c: Update from libsigsegv/src/fault-hurd-i386-old.h.
diff --git a/lib/sigsegv.c b/lib/sigsegv.c
index aadba4e060..8263d9b7bd 100644
--- a/lib/sigsegv.c
+++ b/lib/sigsegv.c
@@ -361,7 +361,7 @@ int libsigsegv_version = LIBSIGSEGV_VERSION;
#if defined __GNU__ /* Hurd */
-# define SIGSEGV_FAULT_HANDLER_ARGLIST int sig, int code, struct sigcontext *scp
+# define SIGSEGV_FAULT_HANDLER_ARGLIST int sig, long code, struct sigcontext *scp
# define SIGSEGV_FAULT_ADDRESS (unsigned long) code
# define SIGSEGV_FAULT_CONTEXT scp
@@ -370,11 +370,29 @@ int libsigsegv_version = LIBSIGSEGV_VERSION;
/* scp points to a 'struct sigcontext' (defined in
glibc/sysdeps/mach/hurd/x86_64/bits/sigcontext.h).
- The registers, at the moment the signal occurred, get pushed on the stack
- through gnumach/x86_64/locore.S:alltraps and then copied into the struct
- through glibc/sysdeps/mach/hurd/x86/trampoline.c. */
-/* sc_rsp is unused (not set by gnumach/x86_64/locore.S:alltraps). We need
- to use sc_ursp. */
+ The registers, at the moment the signal occurred, get pushed on the kernel
+ stack through gnumach/x86_64/locore.S:alltraps. They are denoted by a
+ 'struct i386_saved_state' (defined in gnumach/i386/i386/thread.h).
+ Upon invocation of the Mach interface function thread_get_state
+ <https://www.gnu.org/software/hurd/gnumach-doc/Thread-Execution.html>
+ (= __thread_get_state in glibc), defined in gnumach/kern/thread.c,
+ the function thread_getstatus, defined in gnumach/i386/i386/pcb.c, copies the
+ register values in a different arrangement into a 'struct i386_thread_state',
+ defined in gnumach/i386/include/mach/i386/thread_status.h. (Different
+ arrangement: trapno, err get dropped; different order of r8...r15; also rsp
+ gets set to 0.)
+ This 'struct i386_thread_state' is actually the 'basic' part of a
+ 'struct machine_thread_all_state', defined in
+ glibc/sysdeps/mach/x86/thread_state.h.
+ From there, the function _hurd_setup_sighandler, defined in
+ glibc/sysdeps/mach/hurd/x86/trampoline.c,
+ 1. sets rsp to the same value as ursp,
+ 2. copies the 'struct i386_thread_state' into the appropriate part of a
+ 'struct sigcontext', defined in
+ glibc/sysdeps/mach/hurd/x86_64/bits/sigcontext.h. */
+/* Both sc_rsp and sc_ursp have the same value.
+ It appears more reliable to use sc_ursp because sc_rsp is marked as
+ "not used". */
# define SIGSEGV_FAULT_STACKPOINTER scp->sc_ursp
# elif defined __i386__
@@ -382,12 +400,28 @@ int libsigsegv_version = LIBSIGSEGV_VERSION;
/* scp points to a 'struct sigcontext' (defined in
glibc/sysdeps/mach/hurd/i386/bits/sigcontext.h).
- The registers, at the moment the signal occurred, get pushed on the stack
- through gnumach/i386/i386/locore.S:alltraps and then copied into the struct
- through glibc/sysdeps/mach/hurd/x86/trampoline.c. */
-/* Both sc_esp and sc_uesp appear to have the same value.
- It appears more reliable to use sc_uesp because it is labelled as
- "old esp, if trapped from user". */
+ The registers, at the moment the signal occurred, get pushed on the kernel
+ stack through gnumach/i386/i386/locore.S:alltraps. They are denoted by a
+ 'struct i386_saved_state' (defined in gnumach/i386/i386/thread.h).
+ Upon invocation of the Mach interface function thread_get_state
+ <https://www.gnu.org/software/hurd/gnumach-doc/Thread-Execution.html>
+ (= __thread_get_state in glibc), defined in gnumach/kern/thread.c,
+ the function thread_getstatus, defined in gnumach/i386/i386/pcb.c, copies the
+ register values in a different arrangement into a 'struct i386_thread_state',
+ defined in gnumach/i386/include/mach/i386/thread_status.h. (Different
+ arrangement: trapno, err get dropped; also esp gets set to 0.)
+ This 'struct i386_thread_state' is actually the 'basic' part of a
+ 'struct machine_thread_all_state', defined in
+ glibc/sysdeps/mach/x86/thread_state.h.
+ From there, the function _hurd_setup_sighandler, defined in
+ glibc/sysdeps/mach/hurd/x86/trampoline.c,
+ 1. sets esp to the same value as uesp,
+ 2. copies the 'struct i386_thread_state' into the appropriate part of a
+ 'struct sigcontext', defined in
+ glibc/sysdeps/mach/hurd/i386/bits/sigcontext.h. */
+/* Both sc_esp and sc_uesp have the same value.
+ It appears more reliable to use sc_uesp because sc_esp is marked as
+ "not used". */
# define SIGSEGV_FAULT_STACKPOINTER scp->sc_uesp
# endif
Information forwarded
to
bug-diffutils <at> gnu.org
:
bug#63333
; Package
diffutils
.
(Mon, 15 May 2023 17:03:02 GMT)
Full text and
rfc822 format available.
This bug report was last modified 1 year and 228 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.