Skip to content

Commit c7a22f1

Browse files
agockeVSadovdanmoseley
authored
[release/5.0] Backport AVX context fix #66120 (#66356)
* Use CopyContext to restore saved context on X86 (#65490) * Use CopyContext to restore saved context on X86 * PR feedback * more PR feedback * Do not copy XState other than AVX when redirecting for GC stress (#65825) * Do not copy XState other than AVX * #if defined(TARGET_X86) || defined(TARGET_AMD64) * mask XState unconditionally * Ensure XSTATE_MASK_AVX is set before calling EEGetThreadContext * redundant supportsAVX, more clear comment * PR feedback * null-check the redirect context before using. (#65910) * null-check the redirect context before using. * tweak the comment * do not allocate context if InitializeContext has unexpected results. * EE Suspension on x86 should use RtlRestoreContext when available (#65878) * RestoreContextSimulated * probe for RtlRestoreContext * ntdll.dll * restore self-trap sequence * PR feedback * Clarify CopyContext in RedirectedHandledJITCaseExceptionFilter * simpler indentation. * restore last error on the legacy path. * Update src/coreclr/vm/threads.h Co-authored-by: Dan Moseley <danmose@microsoft.com> Co-authored-by: Vladimir Sadov <vsadov@microsoft.com> Co-authored-by: Dan Moseley <danmose@microsoft.com>
1 parent 5883f75 commit c7a22f1

File tree

2 files changed

+200
-160
lines changed

2 files changed

+200
-160
lines changed

src/coreclr/src/vm/threads.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3343,6 +3343,14 @@ class Thread
33433343
static void __stdcall RedirectedHandledJITCaseForGCStress();
33443344
#endif // defined(HAVE_GCCOVER) && USE_REDIRECT_FOR_GCSTRESS
33453345

3346+
#ifdef TARGET_X86
3347+
// RtlRestoreContext is available on x86, but relatively recently.
3348+
// RestoreContextSimulated uses SEH machinery for a similar result on legacy OS-es.
3349+
// This function should not be used on new OS-es as the pattern is not
3350+
// guaranteed to continue working in the future.
3351+
static void RestoreContextSimulated(Thread* pThread, CONTEXT* pCtx, void* pFrame, DWORD dwLastError);
3352+
#endif
3353+
33463354
friend void CPFH_AdjustContextForThreadSuspensionRace(T_CONTEXT *pContext, Thread *pThread);
33473355
#endif // FEATURE_HIJACK && !TARGET_UNIX
33483356

0 commit comments

Comments
 (0)