Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Arm fault handler: add emulation of MRS instruction #2088

Merged
merged 3 commits into from
Jan 10, 2025

Conversation

francescolavra
Copy link
Member

Starting with Go version 1.23, the Golang runtime for Arm64 during initialization tries to retrieve the values of some system registers (via the MRS instruction) in order to evaluate the features implemented by the processor. This instruction causes a CPU exception, which is not properly handled by the kernel; as a result, Go programs built with Go version 1.23 do to not work on Arm.
This change set adds emulation of the MRS instruction to retrieve the values of the system registers used by the Go runtime, so that Go 1.23 works properly on Arm.

When the user process executes MSR, MRS or System instructions, the
processor raises an exception, with the exception code (EC) in the
Exception Syndrome Register (ESR_EL1) set to 0x18 (trapped MSR,
MRS or System instruction execution in AArch64 state), which should
be treated as an illegal instruction and cause the kernel to send
a SIGILL signal to the process.
Amend the Arm implementation of is_illegal_instruction() so that it
recognizes this type of exceptions.
This avoids multiple dereferences to the context pointer.
No functional change.
Starting with Go version 1.23, the Golang runtime for Arm64 during
initialization tries to retrieve the values of some system
registers (via the MRS instruction) in order to evaluate the
features implemented by the processor. This instruction causes a
CPU exception, which the kernel handles by sending SIGILL to the
user process; as a result, Go programs built with Go version 1.23
do to not work on Arm.
Add emulation of the MRS instruction to retrieve the values of the
system registers used by the Go runtime, so that Go 1.23 works
properly on Arm.
@francescolavra francescolavra merged commit 92df866 into master Jan 10, 2025
7 checks passed
@francescolavra francescolavra deleted the feature/arm-insn-emulate branch January 10, 2025 10:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant