ntdll: Restore AVX registers in NtSetContextThread() on x86_64.
Signed-off-by: Paul Gofman <pgofman@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
16ed88a952
commit
2c3719c7a9
|
@ -5562,7 +5562,7 @@ static void test_extended_context(void)
|
|||
for (i = 0; i < 8; ++i)
|
||||
{
|
||||
/* Older Windows version do not reset AVX context to INIT_STATE on x86. */
|
||||
todo_wine_if(i >= 4)
|
||||
todo_wine_if(i >= 4 && sizeof(void *) == 4)
|
||||
ok(!data[i] || broken(i >= 4 && sizeof(void *) == 4 && data[i] == test_extended_context_spoil_data2[i]),
|
||||
"Got unexpected data %#x, i %u.\n", data[i], i);
|
||||
}
|
||||
|
@ -5573,7 +5573,7 @@ static void test_extended_context(void)
|
|||
ARRAY_SIZE(except_code_set_ymm0), PAGE_EXECUTE_READ);
|
||||
|
||||
for (i = 0; i < 8; ++i)
|
||||
todo_wine_if(i >= 4)
|
||||
todo_wine_if(i >= 4 && sizeof(void *) == 4)
|
||||
ok(data[i] == test_extended_context_data[i], "Got unexpected data %#x, i %u.\n", data[i], i);
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -1535,6 +1535,34 @@ __ASM_GLOBAL_FUNC( set_full_cpu_context,
|
|||
"iretq" );
|
||||
|
||||
|
||||
/***********************************************************************
|
||||
* restore_xstate
|
||||
*
|
||||
* Restore the XState context.
|
||||
*/
|
||||
static void restore_xstate( const CONTEXT *context )
|
||||
{
|
||||
XSAVE_FORMAT *xrstor_base;
|
||||
XSTATE *xs;
|
||||
|
||||
if (!(xs = xstate_from_context( context )))
|
||||
return;
|
||||
|
||||
xrstor_base = (XSAVE_FORMAT *)xs - 1;
|
||||
|
||||
if (!(xs->CompactionMask & ((ULONG64)1 << 63)))
|
||||
{
|
||||
/* Non-compacted xrstor will load Mxcsr regardless of the specified mask. Loading garbage there
|
||||
* may lead to fault. We have only padding, no more used EXCEPTION_RECORD or unused context fields
|
||||
* at the MxCsr restore location, so just put it there. */
|
||||
assert( (void *)&xrstor_base->MxCsr > (void *)context->VectorRegister );
|
||||
xrstor_base->MxCsr = context->u.FltSave.MxCsr;
|
||||
xrstor_base->MxCsr_Mask = context->u.FltSave.MxCsr_Mask;
|
||||
}
|
||||
|
||||
__asm__ volatile( "xrstor64 %0" : : "m"(*xrstor_base), "a" (4), "d" (0) );
|
||||
}
|
||||
|
||||
/***********************************************************************
|
||||
* get_server_context_flags
|
||||
*
|
||||
|
@ -1725,6 +1753,8 @@ NTSTATUS WINAPI NtSetContextThread( HANDLE handle, const CONTEXT *context )
|
|||
}
|
||||
}
|
||||
|
||||
restore_xstate( context );
|
||||
|
||||
if (flags & CONTEXT_FULL)
|
||||
{
|
||||
if (!(flags & CONTEXT_CONTROL))
|
||||
|
|
Loading…
Reference in New Issue