Skip to content

Add AArch64 guest exception callback - #1771

Closed
jsturtevant wants to merge 1 commit into
mainfrom
jsturtevant-aarch64-exception-hook
Closed

Add AArch64 guest exception callback#1771
jsturtevant wants to merge 1 commit into
mainfrom
jsturtevant-aarch64-exception-hook

Conversation

@jsturtevant

Copy link
Copy Markdown
Contributor

Adds an AArch64-specific guest exception callback before Hyperlight's default abort. This enables guest runtimes such as Wasmtime to resolve lazy translation faults or redirect hardware traps while preserving Hyperlight's stack and CoW fault handling.

The callback receives the decoded exception, raw ESR and FAR, mutable ELR, and saved x0 through x30 registers.

Signed-off-by: James Sturtevant <jsturtevant@gmail.com>
Copilot AI lite review requested due to automatic review settings August 26, 2026 13:25
@jsturtevant jsturtevant added kind/enhancement For PRs adding features, improving functionality, docs, tests, etc. area/API Related to the API or public interface ready-for-review PR is ready for (re-)review labels Aug 26, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds an AArch64-specific guest exception callback hook in hyperlight_guest_bin so guest runtimes can intercept synchronous exceptions, adjust ELR and saved GPRs, and resume execution before Hyperlight falls back to its default abort path. This preserves Hyperlight’s existing stack-growth and CoW fault handling while enabling runtime-specific trap and fault recovery.

Changes:

  • Expose a public, arch-specific exception interface module and add AArch64 exports for registering an exception callback.
  • Make the AArch64 exception module visible within the crate so the new public re-exports can reach the handler registration functions.
  • Invoke the registered AArch64 callback from the synchronous exception handler after Hyperlight internal fault handling and before abort.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/hyperlight_guest_bin/src/lib.rs Makes the arch-specific exception interface available via a stable exception module.
src/hyperlight_guest_bin/src/exception.rs Adds AArch64-specific public exports for the exception callback registration API.
src/hyperlight_guest_bin/src/arch/aarch64/mod.rs Adjusts module visibility so the crate can re-export AArch64 exception handler registration.
src/hyperlight_guest_bin/src/arch/aarch64/exception/handle.rs Implements callback registration and calls it from the synchronous exception path, allowing ELR and register edits before eret.
CHANGELOG.md Documents the new AArch64 guest exception callback capability.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +18 to +23
/// Callback for synchronous AArch64 exceptions not handled by Hyperlight.
///
/// The arguments are the decoded exception, raw ESR_EL1, FAR_EL1, mutable
/// ELR_EL1, and saved x0 through x30. Return `true` to resume execution.
/// Call [`crate::paging::barrier::first_valid_same_ctx`] after mapping a page
/// for a translation fault.
Comment on lines +28 to +32
/// Register the callback for synchronous AArch64 exceptions.
///
/// A new callback replaces any existing callback.
pub fn register_exception_handler(handler: ExceptionHandler) {
HANDLER.store(handler as usize as u64, Ordering::Release);
@syntactically

Copy link
Copy Markdown
Member

Actually, this was purposefully left out in favour of #1690

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/API Related to the API or public interface kind/enhancement For PRs adding features, improving functionality, docs, tests, etc.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants