[release/8.0-staging] Fix hardware exception context extraction on Rosetta #107199
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Backport of #107188 to release/8.0-staging
/cc @janvorli
Customer Impact
The recently added AVX support in hardware exception handling path on macOS x64 that was also backported to .NET 8 has introduced a problem when running under Rosetta. Hardware exception handling always crashes when running as x64 under Rosetta emulation on arm64 macOS. The reason is that we try to set YMM registers and AVX instructions are not emulated by Rosetta.
Regression
Introduced in 8.0.8 by #104818
Testing
Directed test of a testing application where the issue got revealed and also running all coreclr tests under Rosetta.
Risk
Low, the change just removes CONTEXT_XSTATE flag from the captured context of the hardware exception location when the OS returns context without AVX.