Repository navigation
Fix SIGILL crash on ARM64 platforms with SME but no SVE - #127398
Conversation
Replace CONTEXT_GetSveLengthFromOS() calls in signal context handling with direct reads of sve->vl from the kernel-provided signal frame. The CONTEXT_GetSveLengthFromOS function executes the SVE 'rdvl' instruction, which causes SIGILL on platforms that have SME (streaming SVE) but not standalone SVE — such as Apple M4 under macOS Virtualization.Framework with Podman/Colima. On these platforms, the Linux kernel includes an SVE_MAGIC record in signal frames (with vl=0 and minimal size) due to SME's streaming SVE mode, but the CPU does not support SVE instructions. When a signal fires (e.g. SIGUSR1 for activation injection), CONTEXTFromNativeContext sees the SVE record and calls rdvl, which triggers SIGILL. The SIGILL handler then tries to capture context again, hitting rdvl recursively. The fix uses sve->vl from the signal frame directly, which is always available when an SVE context record is present. On real SVE hardware, sve->vl equals what rdvl would return. On SME-only platforms, sve->vl is 0, so the SVE register save/restore is correctly skipped. Co-authored-by: Copilot <[email protected]>
|
@janvorli PTAL Pre-fix, |
There was a problem hiding this comment.
Pull request overview
This PR fixes an ARM64 SIGILL crash in CoreCLR PAL signal-context handling on platforms that provide an SVE signal-frame record but don’t support executing SVE instructions (e.g., SME-only environments). It does so by avoiding the SVE rdvl instruction and instead using the kernel-provided sve_context::vl value from the signal frame.
Changes:
- Replace
CONTEXT_GetSveLengthFromOS()(usesrdvl) with direct reads ofsve->vlwhen handling SVE state in signal contexts. - Add explanatory comments documenting the SME-without-SVE scenario and why
rdvlmust be avoided in this path.
- Remove the now-tautological _ASSERTE((sve->vl > 0) && (sve->vl % 16 == 0)) inside the 'if (sve->vl == 16)' block (janvorli). - In CONTEXTToNativeContext, derive vq from sve->vl (the signal frame's authoritative layout) instead of lpContext->Vl (copilot-reviewer). Co-authored-by: Copilot <[email protected]>
|
These are the only two usages, we can delete its definition: Also, the comment can be reworded to avoid mentions of |
|
Other places using rdvl: |
- Remove unused CONTEXT_GetSveLengthFromOS definition (context2.S) and declaration (context.h) since all callers now use sve->vl (am11). - Reword comments to not reference the deleted function (am11). - Replace redundant assert with meaningful size check (janvorli/AndyAyersMS): _ASSERTE(sve->head.size >= SVE_SIG_CONTEXT_SIZE(sve_vq_from_vl(16))) Co-authored-by: Copilot <[email protected]>
JIT usage should be ok. Let me check the helpers. Looks like they're only invoked after we have verified SVE support. So they seem ok too. |
|
/backport to release/10.0 |
|
Started backporting to |
#127518) Backport of #127398 to release/10.0 /cc @AndyAyersMS ## Customer Impact - [x] Customer reported - [ ] Found internally When building .NET 10 applications in Docker on Apple M4 hardware, the .NET 10 SDK (version 10.0.101) crashes with "Illegal instruction (core dumped)" on ARM64 images. The crash occurs intermittently during various .NET CLI operations including dotnet new, dotnet add package, and dotnet build. #122608 ## Regression - [x] Yes - [ ] No Regression over 9.0 ## Testing Verified creating new dotnet console projects in an Ubuntu container on an M4 works reliably (previously it would fail 5-10% of the time). ## Risk Low, handles a situation unique to running in a Linux container on a Mac M4. --------- Co-authored-by: Andrew Ayers <[email protected]> Co-authored-by: Copilot <[email protected]>
Replace CONTEXT_GetSveLengthFromOS() calls in signal context handling with direct reads of sve->vl from the kernel-provided signal frame. The CONTEXT_GetSveLengthFromOS function executes the SVE 'rdvl' instruction, which causes SIGILL on platforms that have SME (streaming SVE) but not standalone SVE — such as Apple M4 under macOS Virtualization.Framework with Podman/Colima.
On these platforms, the Linux kernel includes an SVE_MAGIC record in signal frames (with vl=0 and minimal size) due to SME's streaming SVE mode, but the CPU does not support SVE instructions. When a signal fires (e.g. SIGUSR1 for activation injection), CONTEXTFromNativeContext sees the SVE record and calls rdvl, which triggers SIGILL. The SIGILL handler then tries to capture context again, hitting rdvl recursively.
The fix uses sve->vl from the signal frame directly, which is always available when an SVE context record is present. On real SVE hardware, sve->vl equals what rdvl would return. On SME-only platforms, sve->vl is 0, so the SVE register save/restore is correctly skipped.
Fixes #122608