Alexandre Julliard : ntdll: Fix exception information for SSE floating point faults.

Alexandre Julliard julliard at winehq.org
Fri Aug 20 16:12:54 CDT 2021


Module: wine
Branch: master
Commit: 8a8889340fbe6553e1a339efb980ff7bd800bad4
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=8a8889340fbe6553e1a339efb980ff7bd800bad4

Author: Alexandre Julliard <julliard at winehq.org>
Date:   Fri Aug 20 11:18:36 2021 +0200

ntdll: Fix exception information for SSE floating point faults.

Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/ntdll/tests/exception.c    | 17 ++++++++---------
 dlls/ntdll/unix/signal_i386.c   |  5 ++---
 dlls/ntdll/unix/signal_x86_64.c |  8 ++++++++
 3 files changed, 18 insertions(+), 12 deletions(-)

diff --git a/dlls/ntdll/tests/exception.c b/dlls/ntdll/tests/exception.c
index 8140a3aefb6..6af68317732 100644
--- a/dlls/ntdll/tests/exception.c
+++ b/dlls/ntdll/tests/exception.c
@@ -1332,8 +1332,11 @@ static DWORD simd_fault_handler( EXCEPTION_RECORD *rec, EXCEPTION_REGISTRATION_R
                 "exception code: %#x, should be %#x\n",
                 rec->ExceptionCode,  STATUS_FLOAT_MULTIPLE_TRAPS);
             ok( rec->NumberParameters == is_wow64 ? 2 : 1, "# of params: %i\n", rec->NumberParameters);
-            if (rec->NumberParameters >= 1)
-                ok( rec->ExceptionInformation[0] == 0, "param #1: %lx, should be 0\n", rec->ExceptionInformation[0]);
+            ok( rec->ExceptionInformation[0] == 0, "param #1: %lx, should be 0\n", rec->ExceptionInformation[0]);
+            if (rec->NumberParameters == 2)
+                ok( rec->ExceptionInformation[1] == ((XSAVE_FORMAT *)context->ExtendedRegisters)->MxCsr,
+                    "param #1: %lx / %x\n", rec->ExceptionInformation[1],
+                    ((XSAVE_FORMAT *)context->ExtendedRegisters)->MxCsr);
         }
         context->Eip += 3; /* skip divps */
     }
@@ -3413,14 +3416,10 @@ static DWORD WINAPI simd_fault_handler( EXCEPTION_RECORD *rec, ULONG64 frame,
             ULONG expect = *stage == 2 ? EXCEPTION_FLT_DIVIDE_BY_ZERO : EXCEPTION_FLT_INVALID_OPERATION;
             ok( rec->ExceptionCode == expect, "exception code: %#x, should be %#x\n",
                 rec->ExceptionCode, expect );
-            todo_wine
             ok( rec->NumberParameters == 2, "# of params: %i, should be 2\n", rec->NumberParameters);
-            if (rec->NumberParameters == 2)
-            {
-                /* no idea what these mean */
-                ok( rec->ExceptionInformation[0] == 0, "param #0: %lx\n", rec->ExceptionInformation[0]);
-                ok( rec->ExceptionInformation[1] != 0, "param #1: %lx\n", rec->ExceptionInformation[1]);
-            }
+            ok( rec->ExceptionInformation[0] == 0, "param #0: %lx\n", rec->ExceptionInformation[0]);
+            ok( rec->ExceptionInformation[1] == context->MxCsr, "param #1: %lx / %lx\n",
+                rec->ExceptionInformation[1], context->MxCsr);
         }
         context->Rip += 3; /* skip divps */
     }
diff --git a/dlls/ntdll/unix/signal_i386.c b/dlls/ntdll/unix/signal_i386.c
index 0b120ad95be..1cd6ef7bb39 100644
--- a/dlls/ntdll/unix/signal_i386.c
+++ b/dlls/ntdll/unix/signal_i386.c
@@ -1956,9 +1956,8 @@ static void fpe_handler( int signal, siginfo_t *siginfo, void *sigcontext )
                   siginfo->si_code);
 
         rec.ExceptionCode = STATUS_FLOAT_MULTIPLE_TRAPS;
-        rec.NumberParameters = 1;
-        /* no idea what meaning is actually behind this but that's what native does */
-        rec.ExceptionInformation[0] = 0;
+        rec.ExceptionInformation[rec.NumberParameters++] = 0;
+        if (is_wow64) rec.ExceptionInformation[rec.NumberParameters++] = ((XSAVE_FORMAT *)xcontext.c.ExtendedRegisters)->MxCsr;
         break;
     default:
         WINE_ERR( "Got unexpected trap %d\n", TRAP_sig(ucontext) );
diff --git a/dlls/ntdll/unix/signal_x86_64.c b/dlls/ntdll/unix/signal_x86_64.c
index 471ab8f8f90..2d55bd006c7 100644
--- a/dlls/ntdll/unix/signal_x86_64.c
+++ b/dlls/ntdll/unix/signal_x86_64.c
@@ -2664,6 +2664,7 @@ static void trap_handler( int signal, siginfo_t *siginfo, void *sigcontext )
 static void fpe_handler( int signal, siginfo_t *siginfo, void *sigcontext )
 {
     EXCEPTION_RECORD rec = { 0 };
+    ucontext_t *ucontext = sigcontext;
 
     switch (siginfo->si_code)
     {
@@ -2693,6 +2694,13 @@ static void fpe_handler( int signal, siginfo_t *siginfo, void *sigcontext )
         rec.ExceptionCode = EXCEPTION_FLT_INVALID_OPERATION;
         break;
     }
+
+    if (TRAP_sig(ucontext) == TRAP_x86_CACHEFLT)
+    {
+        rec.NumberParameters = 2;
+        rec.ExceptionInformation[0] = 0;
+        rec.ExceptionInformation[1] = FPU_sig(ucontext) ? FPU_sig(ucontext)->MxCsr : 0;
+    }
     setup_exception( sigcontext, &rec );
 }
 




More information about the wine-cvs mailing list