diff options
Diffstat (limited to 'src/pal/src/arch')
-rw-r--r-- | src/pal/src/arch/amd64/processor.cpp | 16 | ||||
-rw-r--r-- | src/pal/src/arch/i386/context2.S | 47 |
2 files changed, 27 insertions, 36 deletions
diff --git a/src/pal/src/arch/amd64/processor.cpp b/src/pal/src/arch/amd64/processor.cpp index ac3d448a81..298d685c98 100644 --- a/src/pal/src/arch/amd64/processor.cpp +++ b/src/pal/src/arch/amd64/processor.cpp @@ -54,10 +54,18 @@ Return value: extern "C" unsigned int XmmYmmStateSupport() { unsigned int eax; - __asm(" xgetbv\n" \ - : "=a"(eax) /*output in eax*/\ - : "c"(0) /*inputs - 0 in ecx*/\ - : "eax", "edx" /* registers that are clobbered*/ + __asm(" mov $1, %%eax\n" \ + " cpuid\n" \ + " xor %%eax, %%eax\n" \ + " and $0x18000000, %%ecx\n" /* check for xsave feature set and that it is enabled by the OS */ \ + " cmp $0x18000000, %%ecx\n" \ + " jne end\n" \ + " xor %%ecx, %%ecx\n" \ + " xgetbv\n" \ + "end:\n" \ + : "=a"(eax) /* output in eax */ \ + : /* no inputs */ \ + : "eax", "ebx", "ecx", "edx" /* registers that are clobbered */ ); // Check OS has enabled both XMM and YMM state support return ((eax & 0x06) == 0x06) ? 1 : 0; diff --git a/src/pal/src/arch/i386/context2.S b/src/pal/src/arch/i386/context2.S index 16cbcc855c..11aba5e647 100644 --- a/src/pal/src/arch/i386/context2.S +++ b/src/pal/src/arch/i386/context2.S @@ -113,39 +113,22 @@ LOCAL_LABEL(Done_Restore_CONTEXT_FLOATING_POINT): movdqu xmm7, [eax + CONTEXT_Xmm7] LOCAL_LABEL(Done_Restore_CONTEXT_EXTENDED_REGISTERS): - // Restore CONTROL register(s) - mov ecx, [eax + CONTEXT_Eip] - mov [esp], ecx - - mov ecx, [eax + CONTEXT_Esp] - push ecx - mov ecx, [eax + CONTEXT_Ebp] - push ecx - - pop ebp - pop esp - - // Restore INTEGER register(s) - mov ecx, [eax + CONTEXT_Edi] - push ecx - mov ecx, [eax + CONTEXT_Esi] - push ecx - mov ecx, [eax + CONTEXT_Edx] - push ecx - mov ecx, [eax + CONTEXT_Ecx] - push ecx - mov ecx, [eax + CONTEXT_Ebx] - push ecx - mov ecx, [eax + CONTEXT_Eax] - push ecx + // Restore Stack + mov esp, [eax + CONTEXT_Esp] - pop eax - pop ebx - pop ecx - pop edx - pop esi - pop edi + // Create a minimal frame + push DWORD PTR [eax + CONTEXT_Eip] + + // Restore register(s) + mov ebp, [eax + CONTEXT_Ebp] + mov edi, [eax + CONTEXT_Edi] + mov esi, [eax + CONTEXT_Esi] + mov edx, [eax + CONTEXT_Edx] + mov ecx, [eax + CONTEXT_Ecx] + mov ebx, [eax + CONTEXT_Ebx] + mov eax, [eax + CONTEXT_Eax] - ret 8 + // Resume + ret LEAF_END RtlRestoreContext, _TEXT |