Skip to content

[hyperlight_guest_bin] Add page fault and undefined instruction hooks - #1877

Open
syntactically wants to merge 1 commit into
mainfrom
lm/exn-hooks-mini
Open

syntactically wants to merge 1 commit into
mainfrom
lm/exn-hooks-mini

Conversation

@syntactically

Copy link
Copy Markdown
Member

No description provided.

@syntactically
syntactically added this pull request to stack #1875 October 2, 2026 10:52
@syntactically syntactically added kind/enhancement For PRs adding features, improving functionality, docs, tests, etc. ready-for-review PR is ready for (re-)review labels Oct 2, 2026
@hyperlight-gh-bot

This comment has been minimized.

Copilot AI balanced review requested due to automatic review settings October 2, 2026 12:29

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.

Copilot review overview

🟡 Changes recommended

AMD64 hooks fall through to abort handling and enter handlers with incorrect stack alignment.

Review effort: Balanced
Findings: 2 High severity · 5 Low severity

Open (7)
What changed in this PR

Adds architecture-independent page-fault and undefined-instruction hooks for guest binaries.

Changes:

  • Adds public hook registration APIs.
  • Redirects AMD64 and AArch64 exception contexts to registered handlers.
  • Extends AArch64 syndrome decoding for instruction faults.
File Description
src/​hyperlight_guest_bin/​src/​lib.rs Exposes the cross-platform exception module.
src/​hyperlight_guest_bin/​src/​exception.rs Defines and registers exception hooks.
src/​hyperlight_guest_bin/​src/​arch/​amd64/​exception/​handle.rs Adds AMD64 hook dispatch.
src/​hyperlight_guest_bin/​src/​arch/​aarch64/​exception/​handle.rs Adds AArch64 hook dispatch.
src/​hyperlight_common/​src/​arch/​aarch64/​exn.rs Decodes unknown and instruction-abort syndromes.

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

Comment thread src/hyperlight_guest_bin/src/arch/amd64/exception/handle.rs Outdated
Comment thread src/hyperlight_guest_bin/src/arch/amd64/exception/handle.rs
Comment thread src/hyperlight_guest_bin/src/arch/aarch64/exception/handle.rs
Comment thread src/hyperlight_guest_bin/src/arch/amd64/exception/handle.rs
Comment thread src/hyperlight_guest_bin/src/exception.rs
Comment thread src/hyperlight_guest_bin/src/exception.rs
Comment thread src/hyperlight_guest_bin/src/exception.rs Outdated
@hyperlight-gh-bot

This comment has been minimized.

@hyperlight-gh-bot

This comment has been minimized.

ludfjig
ludfjig previously approved these changes Oct 2, 2026
Comment thread src/hyperlight_guest_bin/src/arch/aarch64/exception/handle.rs Outdated
@syntactically
syntactically force-pushed the lm/exn-hooks-mini branch 2 times, most recently from 53f0463 to 8f998bc Compare October 2, 2026 20:28
Base automatically changed from lm/extra-tlbi to main October 3, 2026 00:24
Signed-off-by: Lucy Menon <168595099+syntactically@users.noreply.github.com>
@hyperlight-gh-bot

Copy link
Copy Markdown

Benchmark Results

Measured commit: 08d8f5a5a8c4
Baseline commit: 66d5dd3ed585

kvm / amd (Linux) (➖ stable)

No benchmark improved or regressed.

Benchmark Results

function_call_codec

encode_control decode_vec_bytes_copy
byte_chunks 772.92 ns (➖ 1.03x faster)
vec_bytes 593.64 ns (➖ 1.02x slower)
374.08 µs (➖ 1.00x slower)

payload_allocation

slot_pool_segmented
262144 538.19 ns (➖ 1.01x slower)
65536 143.10 ns (➖ 1.02x slower)

sandboxes

create_initialized_and_drop
medium 77.37 ms (➖ 1.02x slower)

slot_pool

alloc_dealloc_1500 alloc_dealloc_4096 alloc_dealloc_128
7.75 ns (➖ 1.01x slower) 8.17 ns (➖ 1.03x slower) 7.73 ns (➖ 1.01x faster)

snapshot_files

load_snapshot_unverified
small 92.38 µs (➖ 1.00x slower)

virtq_readonly

slot_pool_segmented_fragmented slot_pool_segmented
262144 7.37 µs (➖ 1.00x slower) 7.96 µs (➖ 1.08x slower)
65536 2.09 µs (➖ 1.00x faster) 1.95 µs (➖ 1.06x faster)

virtq_readwrite

slot_pool_segmented_fragmented slot_pool_segmented
65536 6.69 µs (➖ 1.07x slower) 6.27 µs (➖ 1.09x faster)
8192 1.05 µs (➖ 1.03x faster) 1.06 µs (➖ 1.01x slower)
262144 26.99 µs (➖ 1.01x slower)
kvm / intel (Linux) (➖ stable)

No benchmark improved or regressed.

Benchmark Results

function_call_codec

encode_control decode_vec_bytes_copy
byte_chunks 694.42 ns (➖ 1.02x slower)
vec_bytes 511.40 ns (➖ 1.03x faster)
659.12 µs (➖ 1.00x faster)

payload_allocation

slot_pool_segmented
262144 507.50 ns (➖ 1.05x faster)
65536 136.56 ns (➖ 1.03x faster)

sandboxes

create_initialized_and_drop
medium 72.43 ms (➖ 1.07x faster)

slot_pool

alloc_dealloc_1500 alloc_dealloc_4096 alloc_dealloc_128
6.95 ns (➖ 1.00x faster) 6.92 ns (➖ 1.00x faster) 6.97 ns (➖ 1.00x faster)

snapshot_files

load_snapshot_unverified
small 45.78 µs (➖ 1.01x slower)

virtq_readonly

slot_pool_segmented_fragmented slot_pool_segmented
262144 7.56 µs (➖ 1.00x faster) 7.64 µs (➖ 1.00x slower)
65536 2.13 µs (➖ 1.00x slower) 2.15 µs (➖ 1.00x slower)

virtq_readwrite

slot_pool_segmented_fragmented slot_pool_segmented
65536 7.13 µs (➖ 1.02x slower) 7.09 µs (➖ 1.00x slower)
8192 717.97 ns (➖ 1.04x faster) 721.39 ns (➖ 1.00x slower)
262144 30.81 µs (➖ 1.06x slower)
mshv3 / amd (Linux) (❌ 1.65x)

Top regressions

  • virtq_readonly/slot_pool_segmented/262144 — ❌ 1.65x slower

Benchmark Results

function_call_codec

encode_control decode_vec_bytes_copy
byte_chunks 952.78 ns (➖ 1.00x faster)
vec_bytes 778.99 ns (➖ 1.10x slower)
370.45 µs (➖ 1.20x slower)

payload_allocation

slot_pool_segmented
262144 730.67 ns (➖ 1.00x slower)
65536 193.71 ns (➖ 1.00x slower)

sandboxes

create_initialized_and_drop
medium 56.32 ms (➖ 1.02x faster)

slot_pool

alloc_dealloc_1500 alloc_dealloc_4096 alloc_dealloc_128
9.73 ns (➖ 1.04x faster) 9.73 ns (➖ 1.00x faster) 9.69 ns (➖ 1.01x faster)

snapshot_files

load_snapshot_unverified
small 86.00 µs (➖ 1.01x slower)

virtq_readonly

slot_pool_segmented_fragmented slot_pool_segmented
262144 9.73 µs (➖ 1.07x slower) 15.18 µs (❌ 1.65x slower)
65536 2.34 µs (➖ 1.04x slower) 2.32 µs (➖ 1.05x faster)

virtq_readwrite

slot_pool_segmented_fragmented slot_pool_segmented
65536 8.27 µs (➖ 1.03x slower) 8.35 µs (➖ 1.02x slower)
8192 1.27 µs (➖ 1.00x faster) 1.36 µs (➖ 1.02x slower)
262144 37.00 µs (➖ 1.05x slower)
mshv3 / intel (Linux) (➖ stable)

No benchmark improved or regressed.

Benchmark Results

function_call_codec

encode_control decode_vec_bytes_copy
byte_chunks 829.83 ns (➖ 1.22x faster)
vec_bytes 616.56 ns (➖ 1.07x faster)
748.66 µs (➖ 1.18x slower)

payload_allocation

slot_pool_segmented
262144 612.03 ns (➖ 1.04x faster)
65536 162.08 ns (➖ 1.01x faster)

sandboxes

create_initialized_and_drop
medium 64.88 ms (➖ 1.03x slower)

slot_pool

alloc_dealloc_1500 alloc_dealloc_4096 alloc_dealloc_128
8.26 ns (➖ 1.06x faster) 8.25 ns (➖ 1.06x faster) 8.25 ns (➖ 1.08x faster)

snapshot_files

load_snapshot_unverified
small 46.16 µs (➖ 1.07x slower)

virtq_readonly

slot_pool_segmented_fragmented slot_pool_segmented
262144 9.04 µs (➖ 1.16x slower) 8.97 µs (➖ 1.16x slower)
65536 2.54 µs (➖ 1.14x slower) 2.52 µs (➖ 1.11x slower)

virtq_readwrite

slot_pool_segmented_fragmented slot_pool_segmented
65536 8.46 µs (➖ 1.12x slower) 8.43 µs (➖ 1.11x slower)
8192 868.45 ns (➖ 1.00x slower) 866.30 ns (➖ 1.05x faster)
262144 34.82 µs (➖ 1.04x faster)
hyperv-ws2025 / amd (Windows) (➖ stable)

No benchmark improved or regressed.

Benchmark Results

function_call_codec

encode_control decode_vec_bytes_copy
byte_chunks 1.21 µs (➖ 1.02x slower)
vec_bytes 775.20 ns (➖ 1.06x faster)
2.14 ms (➖ 1.01x slower)

payload_allocation

slot_pool_segmented
262144 785.85 ns (➖ 1.02x faster)
65536 233.61 ns (➖ 1.01x slower)

sandboxes

create_initialized_and_drop
medium 87.54 ms (➖ 1.03x slower)

slot_pool

alloc_dealloc_1500 alloc_dealloc_4096 alloc_dealloc_128
10.16 ns (➖ 1.00x faster) 11.02 ns (➖ 1.05x slower) 10.38 ns (➖ 1.02x slower)

snapshot_files

load_snapshot_unverified
small 738.82 µs (➖ 1.05x faster)

virtq_readonly

slot_pool_segmented_fragmented slot_pool_segmented
262144 9.12 µs (➖ 1.02x faster) 9.35 µs (➖ 1.16x faster)
65536 2.38 µs (➖ 1.02x faster) 2.38 µs (➖ 1.07x faster)

virtq_readwrite

slot_pool_segmented_fragmented slot_pool_segmented
65536 8.98 µs (➖ 1.01x faster) 9.09 µs (➖ 1.00x slower)
8192 1.38 µs (➖ 1.06x slower) 1.31 µs (➖ 1.02x slower)
262144 44.17 µs (➖ 1.03x slower)
hyperv-ws2025 / intel (Windows) (➖ stable)

No benchmark improved or regressed.

Benchmark Results

function_call_codec

encode_control decode_vec_bytes_copy
byte_chunks 1.23 µs (➖ 1.36x faster)
vec_bytes 828.72 ns (➖ 1.04x slower)
3.22 ms (➖ 1.02x slower)

payload_allocation

slot_pool_segmented
262144 734.04 ns (➖ 1.00x faster)
65536 211.51 ns (➖ 1.01x slower)

sandboxes

create_initialized_and_drop
medium 117.15 ms (➖ 1.13x slower)

slot_pool

alloc_dealloc_1500 alloc_dealloc_4096 alloc_dealloc_128
10.04 ns (➖ 1.01x slower) 10.16 ns (➖ 1.01x slower) 10.62 ns (➖ 1.01x slower)

snapshot_files

load_snapshot_unverified
small 671.37 µs (➖ 1.07x faster)

virtq_readonly

slot_pool_segmented_fragmented slot_pool_segmented
262144 7.61 µs (➖ 1.00x slower) 7.73 µs (➖ 1.01x faster)
65536 2.33 µs (➖ 1.01x slower) 2.38 µs (➖ 1.02x slower)

virtq_readwrite

slot_pool_segmented_fragmented slot_pool_segmented
65536 8.67 µs (➖ 1.02x slower) 8.63 µs (➖ 1.02x faster)
8192 1.13 µs (➖ 1.11x faster) 1.22 µs (➖ 1.10x slower)
262144 59.25 µs (➖ 1.39x slower)

Reported by cargo ci bench-report --candidate run:37082046581 --baseline run:37081579247 --config-file bench_report.toml.

This branch has not been deployed

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

Labels

kind/enhancement For PRs adding features, improving functionality, docs, tests, etc. ready-for-review PR is ready for (re-)review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants