Commit 014f249a authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

ntdll: Don't use FeatureSet for XSAVE compaction support flag.

parent 43900dd6
......@@ -716,7 +716,7 @@ static inline NTSTATUS save_xstate( CONTEXT *context )
|| context_ex->XState.Length > sizeof(XSTATE))
return STATUS_INVALID_PARAMETER;
if (user_shared_data->XState.CompactionEnabled)
if (xstate_compaction_enabled)
{
/* xsavec doesn't use anything from the save area. */
__asm__ volatile( "xsavec %0" : "=m"(xsave_area)
......@@ -1650,7 +1650,7 @@ C_ASSERT( (offsetof(struct stack_layout, xstate) == sizeof(struct stack_layout))
assert(!((ULONG_PTR)dst_xs & 63));
context_init_xstate( &stack->context, stack->xstate );
memset( dst_xs, 0, offsetof(XSTATE, YmmContext) );
dst_xs->CompactionMask = user_shared_data->XState.CompactionEnabled ? 0x8000000000000004 : 0;
dst_xs->CompactionMask = xstate_compaction_enabled ? 0x8000000000000004 : 0;
if (src_xs->Mask & 4)
{
dst_xs->Mask = 4;
......
......@@ -1959,16 +1959,15 @@ NTSTATUS WINAPI NtGetContextThread( HANDLE handle, CONTEXT *context )
{
struct syscall_xsave *xsave = get_syscall_xsave( frame );
CONTEXT_EX *context_ex = (CONTEXT_EX *)(context + 1);
const BOOL compaction_enabled = user_shared_data->XState.CompactionEnabled;
unsigned int mask;
if (context_ex->XState.Length < offsetof(XSTATE, YmmContext)
|| context_ex->XState.Length > sizeof(XSTATE))
return STATUS_INVALID_PARAMETER;
mask = (compaction_enabled ? xstate->CompactionMask : xstate->Mask) & XSTATE_MASK_GSSE;
mask = (xstate_compaction_enabled ? xstate->CompactionMask : xstate->Mask) & XSTATE_MASK_GSSE;
xstate->Mask = xsave->xstate.Mask & mask;
xstate->CompactionMask = compaction_enabled ? (0x8000000000000000 | mask) : 0;
xstate->CompactionMask = xstate_compaction_enabled ? (0x8000000000000000 | mask) : 0;
memset( xstate->Reserved, 0, sizeof(xstate->Reserved) );
if (xstate->Mask)
{
......@@ -2044,7 +2043,7 @@ static void setup_raise_exception( ucontext_t *sigcontext, EXCEPTION_RECORD *rec
assert( !((ULONG_PTR)dst_xs & 63) );
context_init_xstate( &stack->context, stack->xstate );
memset( dst_xs, 0, offsetof(XSTATE, YmmContext) );
dst_xs->CompactionMask = user_shared_data->XState.CompactionEnabled ? 0x8000000000000004 : 0;
dst_xs->CompactionMask = xstate_compaction_enabled ? 0x8000000000000004 : 0;
if (src_xs->Mask & 4)
{
dst_xs->Mask = 4;
......@@ -2807,7 +2806,7 @@ void *signal_init_syscalls(void)
extern void __wine_syscall_dispatcher_xsavec(void) DECLSPEC_HIDDEN;
NtQuerySystemInformation( SystemCpuInformation, &cpu_info, sizeof(cpu_info), NULL );
if (cpu_info.FeatureSet & CPU_FEATURE_XSAVEC)
if (xstate_compaction_enabled)
syscall_dispatcher = __wine_syscall_dispatcher_xsavec;
else if (cpu_info.FeatureSet & CPU_FEATURE_XSAVE)
syscall_dispatcher = __wine_syscall_dispatcher_xsave;
......
......@@ -178,6 +178,8 @@ static SYSTEM_CPU_INFORMATION cpu_info;
*/
#if defined(__i386__) || defined(__x86_64__)
BOOL xstate_compaction_enabled = FALSE;
#define AUTH 0x68747541 /* "Auth" */
#define ENTI 0x69746e65 /* "enti" */
#define CAMD 0x444d4163 /* "cAMD" */
......@@ -308,7 +310,7 @@ static void get_cpuinfo( SYSTEM_CPU_INFORMATION *info )
if (info->FeatureSet & CPU_FEATURE_XSAVE)
{
do_cpuid( 0x0000000d, regs3 ); /* get XSAVE details */
if (regs3[0] & 2) info->FeatureSet |= CPU_FEATURE_XSAVEC;
if (regs3[0] & 2) xstate_compaction_enabled = TRUE;
}
if (regs[1] == AUTH && regs[3] == ENTI && regs[2] == CAMD)
......
......@@ -307,6 +307,8 @@ struct xcontext
};
#if defined(__i386__) || defined(__x86_64__)
extern BOOL xstate_compaction_enabled DECLSPEC_HIDDEN;
static inline XSTATE *xstate_from_context( const CONTEXT *context )
{
CONTEXT_EX *xctx = (CONTEXT_EX *)(context + 1);
......
......@@ -1754,14 +1754,13 @@ typedef struct _SYSTEM_CPU_INFORMATION {
/* FIXME: following values are made up, actual flags are unknown */
#define CPU_FEATURE_SSSE3 0x00008000 /* SSSE3 instructions */
#define CPU_FEATURE_XSAVEC 0x00400000 /* XSAVEC instructions */
#define CPU_FEATURE_SSE41 0x01000000 /* SSE41 instructions */
#define CPU_FEATURE_SSE42 0x02000000 /* SSE42 instructions */
#define CPU_FEATURE_AVX 0x40000000 /* AVX instructions */
#define CPU_FEATURE_AVX2 0x80000000 /* AVX2 instructions */
#define CPU_FEATURE_PAE 0x00200000
#define CPU_FEATURE_DAZ 0x00400000
#define CPU_FEATURE_ARM_VFP_32 0x00000001
#define CPU_FEATURE_ARM_NEON 0x00000002
#define CPU_FEATURE_ARM_V8_CRC32 0x00000004
......
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