Commit c88b2ed3 authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

ntdll: Use cpu_info to check for AVX availability.

parent 894dbe83
......@@ -721,7 +721,7 @@ static inline NTSTATUS save_xstate( CONTEXT *context )
xsave_area;
XSTATE *xs;
if (!(user_shared_data->XState.EnabledFeatures && (xs = xstate_from_context( context ))))
if (!(cpu_info.FeatureSet & CPU_FEATURE_AVX) || !(xs = xstate_from_context( context )))
return STATUS_SUCCESS;
if (context_ex->XState.Length < offsetof(XSTATE, YmmContext)
......@@ -796,7 +796,7 @@ static inline void restore_xstate( const CONTEXT *context )
XSAVE_FORMAT *xrstor_base;
XSTATE *xs;
if (!(user_shared_data->XState.EnabledFeatures && (xs = xstate_from_context( context ))))
if (!(cpu_info.FeatureSet & CPU_FEATURE_AVX) || !(xs = xstate_from_context( context )))
return;
xrstor_base = (XSAVE_FORMAT *)xs - 1;
......@@ -914,7 +914,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 (user_shared_data->XState.EnabledFeatures && (xs = XState_sig(fpux)))
if ((cpu_info.FeatureSet & CPU_FEATURE_AVX) && (xs = XState_sig(fpux)))
{
context_init_xstate( context, xs );
xcontext->host_compaction_mask = xs->CompactionMask;
......
......@@ -1528,7 +1528,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 (user_shared_data->XState.EnabledFeatures && (xs = XState_sig(FPU_sig(sigcontext))))
if ((cpu_info.FeatureSet & CPU_FEATURE_AVX) && (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 */
......@@ -1558,7 +1558,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 (user_shared_data->XState.EnabledFeatures && (xs = XState_sig(FPU_sig(sigcontext))))
if ((cpu_info.FeatureSet & CPU_FEATURE_AVX) && (xs = XState_sig(FPU_sig(sigcontext))))
xs->CompactionMask = xcontext->host_compaction_mask;
}
......@@ -1599,9 +1599,7 @@ __ASM_GLOBAL_FUNC( set_full_cpu_context,
void signal_restore_full_cpu_context(void)
{
struct syscall_xsave *xsave = get_syscall_xsave( get_syscall_frame() );
SYSTEM_CPU_INFORMATION cpu_info;
NtQuerySystemInformation( SystemCpuInformation, &cpu_info, sizeof(cpu_info), NULL );
if (cpu_info.FeatureSet & CPU_FEATURE_XSAVE)
{
__asm__ volatile( "xrstor64 %0" : : "m"(xsave->xsave), "a" (7), "d" (0) );
......@@ -1850,7 +1848,7 @@ NTSTATUS WINAPI NtSetContextThread( HANDLE handle, const CONTEXT *context )
xsave->xsave = context->u.FltSave;
xsave->xstate.Mask |= XSTATE_MASK_LEGACY;
}
if (user_shared_data->XState.EnabledFeatures && (xs = xstate_from_context( context )))
if ((cpu_info.FeatureSet & CPU_FEATURE_AVX) && (xs = xstate_from_context( context )))
{
CONTEXT_EX *context_ex = (CONTEXT_EX *)(context + 1);
......@@ -1987,7 +1985,7 @@ NTSTATUS WINAPI NtGetContextThread( HANDLE handle, CONTEXT *context )
amd64_thread_data()->dr6 = context->Dr6;
amd64_thread_data()->dr7 = context->Dr7;
}
if (user_shared_data->XState.EnabledFeatures && (xstate = xstate_from_context( context )))
if ((cpu_info.FeatureSet & CPU_FEATURE_AVX) && (xstate = xstate_from_context( context )))
{
struct syscall_xsave *xsave = get_syscall_xsave( frame );
CONTEXT_EX *context_ex = (CONTEXT_EX *)(context + 1);
......@@ -2831,13 +2829,11 @@ void signal_init_process(void)
*/
void *signal_init_syscalls(void)
{
SYSTEM_CPU_INFORMATION cpu_info;
void *ptr, *syscall_dispatcher;
extern void __wine_syscall_dispatcher_xsave(void) DECLSPEC_HIDDEN;
extern void __wine_syscall_dispatcher_xsavec(void) DECLSPEC_HIDDEN;
NtQuerySystemInformation( SystemCpuInformation, &cpu_info, sizeof(cpu_info), NULL );
if (xstate_compaction_enabled)
syscall_dispatcher = __wine_syscall_dispatcher_xsavec;
else if (cpu_info.FeatureSet & CPU_FEATURE_XSAVE)
......
......@@ -168,7 +168,7 @@ struct smbios_boot_info
#define FIRM 0x4649524D
#define RSMB 0x52534D42
static SYSTEM_CPU_INFORMATION cpu_info;
SYSTEM_CPU_INFORMATION cpu_info = { 0 };
/*******************************************************************************
* Architecture specific feature detection for CPUs
......
......@@ -129,6 +129,7 @@ extern HANDLE keyed_event DECLSPEC_HIDDEN;
extern timeout_t server_start_time DECLSPEC_HIDDEN;
extern sigset_t server_block_set DECLSPEC_HIDDEN;
extern struct _KUSER_SHARED_DATA *user_shared_data DECLSPEC_HIDDEN;
extern SYSTEM_CPU_INFORMATION cpu_info DECLSPEC_HIDDEN;
#ifdef __i386__
extern struct ldt_copy __wine_ldt_copy DECLSPEC_HIDDEN;
#endif
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment