Visitar URL original
[hyperlight_guest_bin] Add page fault and undefined instruction hooks by syntactically · Pull Request #1877 · hyperlight-dev/hyperlight · GitHub
Skip to content

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

Merged
syntactically merged 1 commit into
mainfrom
lm/exn-hooks-mini
Oct 9, 2026
Merged

syntactically merged 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
@hyperlight-gh-bot

This comment has been minimized.

andreiltd
andreiltd previously approved these changes Oct 5, 2026
@hyperlight-gh-bot

This comment has been minimized.

@hyperlight-gh-bot

This comment has been minimized.

Signed-off-by: Lucy Menon <168595099+syntactically@users.noreply.github.com>
@hyperlight-gh-bot

Copy link
Copy Markdown

Benchmark Results

Measured commit: 164728cf08d0
Baseline commit: a57d07e8780f

kvm / amd (Linux) (➖ stable)

No benchmark improved or regressed.

Benchmark Results

function_call_codec

encode_control decode_vec_bytes_copy
byte_chunks 797.91 ns (➖ 1.04x slower)
vec_bytes 589.21 ns (➖ 1.00x slower)
374.89 µs (➖ 1.01x slower)

payload_allocation

slot_pool_segmented
262144 523.83 ns (➖ 1.00x slower)
65536 148.87 ns (➖ 1.05x slower)

sandboxes

create_initialized_and_drop
medium 81.81 ms (➖ 1.02x faster)

slot_pool

alloc_dealloc_1500 alloc_dealloc_4096 alloc_dealloc_128
7.74 ns (➖ 1.00x slower) 7.72 ns (➖ 1.00x slower) 7.72 ns (➖ 1.00x faster)

snapshot_files

load_snapshot_unverified
small 92.82 µs (➖ 1.00x slower)

virtq_readonly

slot_pool_segmented_fragmented slot_pool_segmented
262144 7.19 µs (➖ 1.02x slower) 7.67 µs (➖ 1.07x slower)
65536 2.08 µs (➖ 1.08x slower) 1.92 µs (➖ 1.09x faster)

virtq_readwrite

slot_pool_segmented_fragmented slot_pool_segmented
65536 6.19 µs (➖ 1.03x faster) 6.20 µs (➖ 1.04x faster)
8192 1.04 µs (➖ 1.02x faster) 1.04 µs (➖ 1.00x faster)
262144 27.94 µs (➖ 1.03x slower)
kvm / intel (Linux) (➖ stable)

No benchmark improved or regressed.

Benchmark Results

function_call_codec

encode_control decode_vec_bytes_copy
byte_chunks 700.55 ns (➖ 1.13x faster)
vec_bytes 510.91 ns (➖ 1.16x faster)
677.77 µs (➖ 1.10x faster)

payload_allocation

slot_pool_segmented
262144 571.26 ns (➖ 1.00x slower)
65536 154.37 ns (➖ 1.00x faster)

sandboxes

create_initialized_and_drop
medium 82.77 ms (➖ 1.01x faster)

slot_pool

alloc_dealloc_1500 alloc_dealloc_4096 alloc_dealloc_128
7.90 ns (➖ 1.00x slower) 7.91 ns (➖ 1.00x slower) 7.92 ns (➖ 1.00x slower)

snapshot_files

load_snapshot_unverified
small 44.81 µs (➖ 1.13x faster)

virtq_readonly

slot_pool_segmented_fragmented slot_pool_segmented
262144 8.41 µs (➖ 1.02x faster) 8.42 µs (➖ 1.02x faster)
65536 2.38 µs (➖ 1.02x faster) 2.17 µs (➖ 1.11x faster)

virtq_readwrite

slot_pool_segmented_fragmented slot_pool_segmented
65536 7.08 µs (➖ 1.15x faster) 7.09 µs (➖ 1.14x faster)
8192 739.90 ns (➖ 1.15x faster) 740.40 ns (➖ 1.12x faster)
262144 31.55 µs (➖ 1.06x faster)
mshv3 / amd (Linux) (➖ stable)

No benchmark improved or regressed.

Benchmark Results

function_call_codec

encode_control decode_vec_bytes_copy
byte_chunks 969.13 ns (➖ 1.05x slower)
vec_bytes 691.49 ns (➖ 1.01x faster)
377.21 µs (➖ 1.40x slower)

payload_allocation

slot_pool_segmented
262144 726.26 ns (➖ 1.00x slower)
65536 192.63 ns (➖ 1.01x faster)

sandboxes

create_initialized_and_drop
medium 58.80 ms (➖ 1.04x faster)

slot_pool

alloc_dealloc_1500 alloc_dealloc_4096 alloc_dealloc_128
9.87 ns (➖ 1.01x slower) 9.77 ns (➖ 1.00x slower) 9.71 ns (➖ 1.01x faster)

snapshot_files

load_snapshot_unverified
small 83.31 µs (➖ 1.01x slower)

virtq_readonly

slot_pool_segmented_fragmented slot_pool_segmented
262144 10.60 µs (➖ 1.10x faster) 9.86 µs (➖ 1.01x slower)
65536 2.43 µs (➖ 1.01x faster) 2.25 µs (➖ 1.01x slower)

virtq_readwrite

slot_pool_segmented_fragmented slot_pool_segmented
65536 8.67 µs (➖ 1.12x faster) 8.31 µs (➖ 1.16x faster)
8192 1.24 µs (➖ 1.11x faster) 1.24 µs (➖ 1.01x faster)
262144 35.39 µs (➖ 1.07x faster)
mshv3 / intel (Linux) (➖ stable)

No benchmark improved or regressed.

Benchmark Results

function_call_codec

encode_control decode_vec_bytes_copy
byte_chunks 946.56 ns (➖ 1.02x slower)
vec_bytes 656.28 ns (➖ 1.01x slower)
705.04 µs (➖ 1.06x slower)

payload_allocation

slot_pool_segmented
262144 617.84 ns (➖ 1.00x faster)
65536 165.85 ns (➖ 1.01x slower)

sandboxes

create_initialized_and_drop
medium 64.84 ms (➖ 1.03x slower)

slot_pool

alloc_dealloc_1500 alloc_dealloc_4096 alloc_dealloc_128
9.64 ns (➖ 1.01x faster) 8.76 ns (➖ 1.07x faster) 8.82 ns (➖ 1.00x slower)

snapshot_files

load_snapshot_unverified
small 44.69 µs (➖ 1.01x faster)

virtq_readonly

slot_pool_segmented_fragmented slot_pool_segmented
262144 7.94 µs (➖ 1.00x slower) 7.95 µs (➖ 1.01x slower)
65536 2.28 µs (➖ 1.00x slower) 2.30 µs (➖ 1.01x slower)

virtq_readwrite

slot_pool_segmented_fragmented slot_pool_segmented
65536 7.56 µs (➖ 1.01x slower) 7.45 µs (➖ 1.01x faster)
8192 919.78 ns (➖ 1.01x faster) 914.09 ns (➖ 1.02x slower)
262144 38.34 µs (➖ 1.10x 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.66 µs (➖ 1.36x slower)
vec_bytes 785.87 ns (➖ 1.01x faster)
2.07 ms (➖ 1.01x slower)

payload_allocation

slot_pool_segmented
262144 814.17 ns (➖ 1.03x slower)
65536 236.04 ns (➖ 1.01x slower)

sandboxes

create_initialized_and_drop
medium 78.10 ms (➖ 1.01x faster)

slot_pool

alloc_dealloc_1500 alloc_dealloc_4096 alloc_dealloc_128
10.72 ns (➖ 1.08x slower) 10.08 ns (➖ 1.00x slower) 10.12 ns (➖ 1.00x slower)

snapshot_files

load_snapshot_unverified
small 676.72 µs (➖ 1.12x faster)

virtq_readonly

slot_pool_segmented_fragmented slot_pool_segmented
262144 9.41 µs (➖ 1.01x slower) 9.28 µs (➖ 1.04x slower)
65536 2.46 µs (➖ 1.05x slower) 2.42 µs (➖ 1.03x slower)

virtq_readwrite

slot_pool_segmented_fragmented slot_pool_segmented
65536 9.23 µs (➖ 1.03x slower) 8.72 µs (➖ 1.01x faster)
8192 1.30 µs (➖ 1.01x slower) 1.28 µs (➖ 1.01x slower)
262144 43.64 µs (➖ 1.12x 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.03x slower)
vec_bytes 795.33 ns (➖ 1.03x faster)
3.06 ms (➖ 1.02x slower)

payload_allocation

slot_pool_segmented
262144 791.55 ns (➖ 1.03x slower)
65536 211.00 ns (➖ 1.06x faster)

sandboxes

create_initialized_and_drop
medium 101.57 ms (➖ 1.02x faster)

slot_pool

alloc_dealloc_1500 alloc_dealloc_4096 alloc_dealloc_128
10.28 ns (➖ 1.04x faster) 9.98 ns (➖ 1.03x faster) 10.35 ns (➖ 1.04x faster)

snapshot_files

load_snapshot_unverified
small 537.32 µs (➖ 1.01x slower)

virtq_readonly

slot_pool_segmented_fragmented slot_pool_segmented
262144 7.96 µs (➖ 1.03x slower) 7.96 µs (➖ 1.02x slower)
65536 2.38 µs (➖ 1.02x slower) 2.37 µs (➖ 1.01x slower)

virtq_readwrite

slot_pool_segmented_fragmented slot_pool_segmented
65536 8.88 µs (➖ 1.02x slower) 8.66 µs (➖ 1.01x slower)
8192 1.11 µs (➖ 1.13x faster) 1.07 µs (➖ 1.03x faster)
262144 40.70 µs (➖ 1.06x faster)

Reported by cargo ci bench-report --candidate run:37857646484 --config-file bench_report.toml.

@syntactically
syntactically merged commit 164728c into main Oct 9, 2026
65 checks passed
@syntactically
syntactically deleted the lm/exn-hooks-mini branch October 9, 2026 00:03
@github-actions github-actions Bot removed the ready-for-review PR is ready for (re-)review label Oct 9, 2026
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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants