Module: wine Branch: master Commit: 0fde203cac0ada6439f180ac9c0456f2e85bb786 URL: https://source.winehq.org/git/wine.git/?a=commit;h=0fde203cac0ada6439f180ac9...
Author: Paul Gofman pgofman@codeweavers.com Date: Fri Dec 11 16:06:37 2020 +0300
ntdll: Don't set xstate in context if xstate features are not supported.
Fixes a regression reproducible on CPUs without XSAVE support introduced by 419abd49a1f816e5a869dbf4cc81114cd516138b.
The regression commit erroneously assumes that if XSAVE is not supported then the host signal context won't have xsave data set up.
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=50271 Signed-off-by: Paul Gofman pgofman@codeweavers.com Signed-off-by: Alexandre Julliard julliard@winehq.org
---
dlls/ntdll/unix/signal_i386.c | 4 ++-- dlls/ntdll/unix/signal_x86_64.c | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/dlls/ntdll/unix/signal_i386.c b/dlls/ntdll/unix/signal_i386.c index eb4a6653f5e..11fa61232fa 100644 --- a/dlls/ntdll/unix/signal_i386.c +++ b/dlls/ntdll/unix/signal_i386.c @@ -774,7 +774,7 @@ static inline void restore_xstate( const CONTEXT *context ) XSAVE_FORMAT *xrstor_base; XSTATE *xs;
- if (!(xs = xstate_from_context( context ))) + if (!(user_shared_data->XState.EnabledFeatures && (xs = xstate_from_context( context )))) return;
xrstor_base = (XSAVE_FORMAT *)xs - 1; @@ -891,7 +891,7 @@ static inline void save_context( struct xcontext *xcontext, const ucontext_t *si context->ContextFlags |= CONTEXT_FLOATING_POINT | CONTEXT_EXTENDED_REGISTERS; memcpy( context->ExtendedRegisters, fpux, sizeof(*fpux) ); if (!fpu) fpux_to_fpu( &context->FloatSave, fpux ); - if ((xs = XState_sig(fpux))) + if (user_shared_data->XState.EnabledFeatures && (xs = XState_sig(fpux))) { context_init_xstate( context, xs ); xcontext->host_compaction_mask = xs->CompactionMask; diff --git a/dlls/ntdll/unix/signal_x86_64.c b/dlls/ntdll/unix/signal_x86_64.c index d789cecb679..359f2d7c361 100644 --- a/dlls/ntdll/unix/signal_x86_64.c +++ b/dlls/ntdll/unix/signal_x86_64.c @@ -1466,7 +1466,7 @@ static void save_context( struct xcontext *xcontext, const ucontext_t *sigcontex context->ContextFlags |= CONTEXT_FLOATING_POINT; context->u.FltSave = *FPU_sig(sigcontext); context->MxCsr = context->u.FltSave.MxCsr; - if ((xs = XState_sig(FPU_sig(sigcontext)))) + if (user_shared_data->XState.EnabledFeatures && (xs = XState_sig(FPU_sig(sigcontext)))) { /* xcontext and sigcontext are both on the signal stack, so we can * just reference sigcontext without overflowing 32 bit XState.Offset */ @@ -1546,7 +1546,7 @@ static void restore_context( const struct xcontext *xcontext, ucontext_t *sigcon amd64_thread_data()->dr7 = context->Dr7; set_sigcontext( context, sigcontext ); if (FPU_sig(sigcontext)) *FPU_sig(sigcontext) = context->u.FltSave; - if ((xs = XState_sig(FPU_sig(sigcontext)))) + if (user_shared_data->XState.EnabledFeatures && (xs = XState_sig(FPU_sig(sigcontext)))) xs->CompactionMask = xcontext->host_compaction_mask; }
@@ -1603,7 +1603,7 @@ static void restore_xstate( const CONTEXT *context ) XSAVE_FORMAT *xrstor_base; XSTATE *xs;
- if (!(xs = xstate_from_context( context ))) + if (!(user_shared_data->XState.EnabledFeatures && (xs = xstate_from_context( context )))) return;
xrstor_base = (XSAVE_FORMAT *)xs - 1;