=?UTF-8?Q?Andr=C3=A9=20Hentschel=20?=: ntdll: Determine write fault based on failed instruction on ARM64.
Alexandre Julliard
julliard at winehq.org
Mon Jan 22 15:34:54 CST 2018
Module: wine
Branch: master
Commit: dfe813e34fe5389dc1af024ca58ab8e0df87f480
URL: https://source.winehq.org/git/wine.git/?a=commit;h=dfe813e34fe5389dc1af024ca58ab8e0df87f480
Author: André Hentschel <nerv at dawncrow.de>
Date: Sun Jan 21 20:22:55 2018 +0100
ntdll: Determine write fault based on failed instruction on ARM64.
Based on code from Qemu. Reported by Stefan Dösinger.
Signed-off-by: André Hentschel <nerv at dawncrow.de>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/ntdll/signal_arm64.c | 20 ++++++++++++++++++--
1 file changed, 18 insertions(+), 2 deletions(-)
diff --git a/dlls/ntdll/signal_arm64.c b/dlls/ntdll/signal_arm64.c
index a04fe93..57ec13a 100644
--- a/dlls/ntdll/signal_arm64.c
+++ b/dlls/ntdll/signal_arm64.c
@@ -568,6 +568,23 @@ static NTSTATUS raise_exception( EXCEPTION_RECORD *rec, CONTEXT *context, BOOL f
return STATUS_SUCCESS;
}
+static inline DWORD is_write_fault( ucontext_t *context )
+{
+ DWORD inst = *(DWORD *)PC_sig(context);
+ 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;
+}
+
/**********************************************************************
* segv_handler
*
@@ -604,8 +621,7 @@ static void segv_handler( int signal, siginfo_t *info, void *ucontext )
case SIGSEGV: /* Segmentation fault */
rec->ExceptionCode = EXCEPTION_ACCESS_VIOLATION;
rec->NumberParameters = 2;
- /* FIXME: Currently the kernel provides no way to determine if it's read or write */
- rec->ExceptionInformation[0] = 0;
+ rec->ExceptionInformation[0] = is_write_fault(context);
rec->ExceptionInformation[1] = (ULONG_PTR)info->si_addr;
break;
case SIGBUS: /* Alignment check exception */
More information about the wine-cvs
mailing list