Skip to content

Commit

Permalink
[release/5.0] Backport AVX context fix #66120 (#66356)
Browse files Browse the repository at this point in the history
* 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>
  • Loading branch information
3 people authored Mar 15, 2022
1 parent 5883f75 commit c7a22f1
Show file tree
Hide file tree
Showing 2 changed files with 200 additions and 160 deletions.
8 changes: 8 additions & 0 deletions src/coreclr/src/vm/threads.h
Original file line number Diff line number Diff line change
Expand Up @@ -3343,6 +3343,14 @@ class Thread
static void __stdcall RedirectedHandledJITCaseForGCStress();
#endif // defined(HAVE_GCCOVER) && USE_REDIRECT_FOR_GCSTRESS

#ifdef TARGET_X86
// RtlRestoreContext is available on x86, but relatively recently.
// RestoreContextSimulated uses SEH machinery for a similar result on legacy OS-es.
// This function should not be used on new OS-es as the pattern is not
// guaranteed to continue working in the future.
static void RestoreContextSimulated(Thread* pThread, CONTEXT* pCtx, void* pFrame, DWORD dwLastError);
#endif

friend void CPFH_AdjustContextForThreadSuspensionRace(T_CONTEXT *pContext, Thread *pThread);
#endif // FEATURE_HIJACK && !TARGET_UNIX

Expand Down
Loading

0 comments on commit c7a22f1

Please sign in to comment.