ntdll: Don't set xstate in context if xstate features are not supported.

Fixes a regression reproducible on CPUs without XSAVE support introduced
by 419abd49a1.

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>
This commit is contained in:
Paul Gofman 2020-12-11 16:06:37 +03:00 committed by Alexandre Julliard
parent 1647524ba0
commit 0fde203cac
2 changed files with 5 additions and 5 deletions

View File

@ -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;

View File

@ -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;