If not found, use the old codepath from before 85c01202ac70af0c83f894d7a8986adf66983459.
Signed-off-by: Martin Storsjo martin@martin.st --- configure.ac | 3 +++ dlls/ntdll/signal_arm64.c | 27 ++++++++++++++++++++++++++- 2 files changed, 29 insertions(+), 1 deletion(-)
diff --git a/configure.ac b/configure.ac index f30e8b92b0..199139697e 100644 --- a/configure.ac +++ b/configure.ac @@ -2448,6 +2448,9 @@ AC_CHECK_MEMBERS([scsireq_t.cmd, sg_io_hdr_t.interface_id],,, dnl Check for siginfo_t members AC_CHECK_MEMBERS([siginfo_t.si_fd],,,[#include <signal.h>])
+dnl Check for esr_context members +AC_CHECK_MEMBERS([struct esr_context.esr],,,[#include <signal.h>]) + dnl Check for struct mtget members AC_CHECK_MEMBERS([struct mtget.mt_blksiz, struct mtget.mt_gstat, struct mtget.mt_blkno],,, [#include <sys/types.h> diff --git a/dlls/ntdll/signal_arm64.c b/dlls/ntdll/signal_arm64.c index 5fffd45f7b..f6157ba04f 100644 --- a/dlls/ntdll/signal_arm64.c +++ b/dlls/ntdll/signal_arm64.c @@ -101,12 +101,14 @@ static struct fpsimd_context *get_fpsimd_context( ucontext_t *sigcontext ) return (struct fpsimd_context *)get_extended_sigcontext( sigcontext, FPSIMD_MAGIC ); }
+#ifdef HAVE_STRUCT_ESR_CONTEXT_ESR static DWORD64 get_fault_esr( ucontext_t *sigcontext ) { struct esr_context *esr = (struct esr_context *)get_extended_sigcontext( sigcontext, ESR_MAGIC ); if (esr) return esr->esr; return 0; } +#endif
#endif /* linux */
@@ -1027,6 +1029,28 @@ static void setup_raise_exception( ucontext_t *sigcontext, struct stack_layout * REGn_sig(18, sigcontext) = (ULONG_PTR)NtCurrentTeb(); }
+static inline DWORD is_write_fault( DWORD *pc, ucontext_t *sigcontext ) +{ +#ifdef HAVE_STRUCT_ESR_CONTEXT_ESR + return (get_fault_esr( sigcontext ) & 0x40) != 0 ? + EXCEPTION_WRITE_FAULT : EXCEPTION_READ_FAULT; +#else + DWORD inst = *pc; + if ((inst & 0xbfff0000) == 0x0c000000 /* C3.3.1 */ || + (inst & 0xbfe00000) == 0x0c800000 /* C3.3.2 */ || + (inst & 0xbfdf0000) == 0x0d000000 /* C3.3.3 */ || + (inst & 0xbfc00000) == 0x0d800000 /* C3.3.4 */ || + (inst & 0x3f400000) == 0x08000000 /* C3.3.6 */ || + (inst & 0x3bc00000) == 0x38000000 /* C3.3.8-12 */ || + (inst & 0x3fe00000) == 0x3c800000 /* C3.3.8-12 128bit */ || + (inst & 0x3bc00000) == 0x39000000 /* C3.3.13 */ || + (inst & 0x3fc00000) == 0x3d800000 /* C3.3.13 128bit */ || + (inst & 0x3a400000) == 0x28000000) /* C3.3.7,14-16 */ + return EXCEPTION_WRITE_FAULT; + return EXCEPTION_READ_FAULT; +#endif +} + /********************************************************************** * segv_handler * @@ -1036,6 +1060,7 @@ static void segv_handler( int signal, siginfo_t *info, void *ucontext ) { struct stack_layout *stack; ucontext_t *context = ucontext; + DWORD *orig_pc = (DWORD *)PC_sig(context);
/* check for page fault inside the thread stack */ if (signal == SIGSEGV) @@ -1061,7 +1086,7 @@ static void segv_handler( int signal, siginfo_t *info, void *ucontext ) break; case SIGSEGV: /* Segmentation fault */ stack->rec.NumberParameters = 2; - stack->rec.ExceptionInformation[0] = (get_fault_esr( context ) & 0x40) != 0; + stack->rec.ExceptionInformation[0] = is_write_fault( orig_pc, context ); stack->rec.ExceptionInformation[1] = (ULONG_PTR)info->si_addr; if (!(stack->rec.ExceptionCode = virtual_handle_fault( (void *)stack->rec.ExceptionInformation[1], stack->rec.ExceptionInformation[0], FALSE )))
Am 09.04.20 um 23:42 schrieb Martin Storsjo:
If not found, use the old codepath from before 85c01202ac70af0c83f894d7a8986adf66983459.
Signed-off-by: Martin Storsjo martin@martin.st
configure.ac | 3 +++ dlls/ntdll/signal_arm64.c | 27 ++++++++++++++++++++++++++- 2 files changed, 29 insertions(+), 1 deletion(-)
diff --git a/configure.ac b/configure.ac index f30e8b92b0..199139697e 100644 --- a/configure.ac +++ b/configure.ac @@ -2448,6 +2448,9 @@ AC_CHECK_MEMBERS([scsireq_t.cmd, sg_io_hdr_t.interface_id],,, dnl Check for siginfo_t members AC_CHECK_MEMBERS([siginfo_t.si_fd],,,[#include <signal.h>])
+dnl Check for esr_context members +AC_CHECK_MEMBERS([struct esr_context.esr],,,[#include <signal.h>])
dnl Check for struct mtget members AC_CHECK_MEMBERS([struct mtget.mt_blksiz, struct mtget.mt_gstat, struct mtget.mt_blkno],,, [#include <sys/types.h> diff --git a/dlls/ntdll/signal_arm64.c b/dlls/ntdll/signal_arm64.c index 5fffd45f7b..f6157ba04f 100644 --- a/dlls/ntdll/signal_arm64.c +++ b/dlls/ntdll/signal_arm64.c @@ -101,12 +101,14 @@ static struct fpsimd_context *get_fpsimd_context( ucontext_t *sigcontext ) return (struct fpsimd_context *)get_extended_sigcontext( sigcontext, FPSIMD_MAGIC ); }
+#ifdef HAVE_STRUCT_ESR_CONTEXT_ESR static DWORD64 get_fault_esr( ucontext_t *sigcontext ) { struct esr_context *esr = (struct esr_context *)get_extended_sigcontext( sigcontext, ESR_MAGIC ); if (esr) return esr->esr; return 0; } +#endif
#endif /* linux */
@@ -1027,6 +1029,28 @@ static void setup_raise_exception( ucontext_t *sigcontext, struct stack_layout * REGn_sig(18, sigcontext) = (ULONG_PTR)NtCurrentTeb(); }
+static inline DWORD is_write_fault( DWORD *pc, ucontext_t *sigcontext ) +{ +#ifdef HAVE_STRUCT_ESR_CONTEXT_ESR
- return (get_fault_esr( sigcontext ) & 0x40) != 0 ?
EXCEPTION_WRITE_FAULT : EXCEPTION_READ_FAULT;
+#else
- DWORD inst = *pc;
- if ((inst & 0xbfff0000) == 0x0c000000 /* C3.3.1 */ ||
(inst & 0xbfe00000) == 0x0c800000 /* C3.3.2 */ ||
(inst & 0xbfdf0000) == 0x0d000000 /* C3.3.3 */ ||
(inst & 0xbfc00000) == 0x0d800000 /* C3.3.4 */ ||
(inst & 0x3f400000) == 0x08000000 /* C3.3.6 */ ||
(inst & 0x3bc00000) == 0x38000000 /* C3.3.8-12 */ ||
(inst & 0x3fe00000) == 0x3c800000 /* C3.3.8-12 128bit */ ||
(inst & 0x3bc00000) == 0x39000000 /* C3.3.13 */ ||
(inst & 0x3fc00000) == 0x3d800000 /* C3.3.13 128bit */ ||
(inst & 0x3a400000) == 0x28000000) /* C3.3.7,14-16 */
return EXCEPTION_WRITE_FAULT;
- return EXCEPTION_READ_FAULT;
+#endif +}
/**********************************************************************
segv_handler
@@ -1036,6 +1060,7 @@ static void segv_handler( int signal, siginfo_t *info, void *ucontext ) { struct stack_layout *stack; ucontext_t *context = ucontext;
DWORD *orig_pc = (DWORD *)PC_sig(context);
/* check for page fault inside the thread stack */ if (signal == SIGSEGV)
@@ -1061,7 +1086,7 @@ static void segv_handler( int signal, siginfo_t *info, void *ucontext ) break; case SIGSEGV: /* Segmentation fault */ stack->rec.NumberParameters = 2;
stack->rec.ExceptionInformation[0] = (get_fault_esr( context ) & 0x40) != 0;
stack->rec.ExceptionInformation[0] = is_write_fault( orig_pc, context ); stack->rec.ExceptionInformation[1] = (ULONG_PTR)info->si_addr; if (!(stack->rec.ExceptionCode = virtual_handle_fault( (void *)stack->rec.ExceptionInformation[1], stack->rec.ExceptionInformation[0], FALSE )))
Signed-off-by: André Hentschel nerv@dawncrow.de
Martin Storsjo martin@martin.st writes:
If not found, use the old codepath from before 85c01202ac70af0c83f894d7a8986adf66983459.
Signed-off-by: Martin Storsjo martin@martin.st
configure.ac | 3 +++ dlls/ntdll/signal_arm64.c | 27 ++++++++++++++++++++++++++- 2 files changed, 29 insertions(+), 1 deletion(-)
What Linux version is missing this? If it's for another platform, it should provide its own definition instead of doing a configure check.
On Tue, 21 Apr 2020, Alexandre Julliard wrote:
Martin Storsjo martin@martin.st writes:
If not found, use the old codepath from before 85c01202ac70af0c83f894d7a8986adf66983459.
Signed-off-by: Martin Storsjo martin@martin.st
configure.ac | 3 +++ dlls/ntdll/signal_arm64.c | 27 ++++++++++++++++++++++++++- 2 files changed, 29 insertions(+), 1 deletion(-)
What Linux version is missing this? If it's for another platform, it should provide its own definition instead of doing a configure check.
I'm using an old Linaro GCC sysroot (gcc-linaro-aarch64-linux-gnu-4.9-2014.09_linux) for building things that runs on the devboard (which itself runs Debian Jessie). In this particular case, the Linaro sysroot lacks esr_context, while the real Debian Jessie headers do contain esr_context. Not really sure exactly which kernel version the asm/sigcontext.h header in this sysroot comes from though.
If you don't want this, I guess I could just patch the sigcontext.h header in the sysroot as well.
// Martin