Skip to content

feat(aarch64): add GDB debugging for Linux MSHV - #2052

Open
cshung wants to merge 8 commits into
hyperlight-dev:mainfrom
cshung:cshung/mshv-aarch64-gdb
Open

cshung wants to merge 8 commits into
hyperlight-dev:mainfrom
cshung:cshung/mshv-aarch64-gdb

Conversation

@cshung

@cshung cshung commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

ARM64 Linux MSHV GDB

MSHV guests support register and memory access, two hardware breakpoints,
BRK software breakpoints, and hardware single-step.
Guest exception vectors forward debug stops through HVC.
Debugger register access uses the saved exception context and active stack pointer.
Replacement-VM reset preserves debugger configuration.

The hypercall parser validates message type and payload length.
Native ARM64 MSHV GDB tests run in debug CI.
The default-driver build retains non-debug KVM use and rejects KVM debugging.
KVM debugger support is independent in #2016.

Dependencies

Requires shared debugger support in #2050. The MSHV backend is part of
main through #1626. The full diff includes the shared prerequisite.

MSHV GDB-only comparison.

Validation

November 23, base f297a914:

  • Formatting and ARM64 cross-Clippy pass with default and MSHV-only GDB features.
  • Windows x64 Clippy and focused debugger tests pass.
  • The shared prerequisite passes fresh guests, build, and the full Windows just test recipe.

November 19 native Azure ARM64 Linux/MSHV validation, base 5fe5c8f8:

  • Formatting, Clippy, and fresh debug/release Rust and C guest builds passed.
  • All 481 library tests passed with MSHV-only GDB features. Thirteen tests were ignored.
  • Three interrupt stress tests and two parallel sandbox tests passed with default driver features.
  • Seven real GDB client tests passed with MSHV-only features.
  • Backend GPR and FPU round trips passed with default and MSHV-only features.

Native ARM64 runtime tests have not been repeated on this base.

@cshung cshung added the C-enhancement For PRs adding features, improving functionality, docs, tests, etc. label Nov 11, 2026
Copilot AI balanced review requested due to automatic review settings November 11, 2026 20:15
@cshung cshung added the S-needs-review PR is ready for (re-)review label Nov 11, 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.

🟡 Changes recommended

Unresolved critical debugging defects can strand the GDB listener, expose or modify the wrong ARM64 register context, and corrupt live bootstrap stack data.

6 open issues
What changed in this PR

This PR adds ARM64 Linux/MSHV guest debugging to Hyperlight. Its full scope includes the MSHV backend and shared debugger prerequisites from #1626 and #2050.

Changes:

  • Implements MSHV register access, breakpoints, single-step, exception forwarding, and debugger state preservation across VM reset.
  • Shares debugger handling across architectures, including page-sized memory access and snapshot recovery.
  • Adds native ARM64 MSHV CI, bounded test concurrency, debugger tests, and documentation.
File Description
typos.toml Allows an upstream MSHV identifier spelling.
src/​hyperlight_host/​tests/​sandbox_host_tests.rs Bounds ARM64 MSHV test concurrency.
src/​hyperlight_host/​tests/​integration_test.rs Reduces concurrent MSHV partitions in stress tests.
src/​hyperlight_host/​src/​sandbox/​uninitialized_evolve.rs Initializes guest debug vectors during setup.
src/​hyperlight_host/​src/​sandbox/​snapshot/​memory/​backing.rs Exposes backing ranges for debugger cache flushing.
src/​hyperlight_host/​src/​sandbox/​snapshot/​file/​config.rs Accepts Arm CPU implementers in Linux tests.
src/​hyperlight_host/​src/​sandbox/​initialized.rs Guards snapshots against breakpoints and tests recovery.
src/​hyperlight_host/​src/​mem/​mgr.rs Exposes host memory ranges to ARM64 debugging.
src/​hyperlight_host/​src/​mem/​memory_region.rs Decodes ARM64 MSHV memory access flags.
src/​hyperlight_host/​src/​mem/​exe.rs Carries debug-vector metadata.
src/​hyperlight_host/​src/​mem/​elf.rs Locates and relocates guest debug vectors.
src/​hyperlight_host/​src/​hypervisor/​virtual_machine/​whp/​x86_64.rs Adapts the debugger translation interface.
src/​hyperlight_host/​src/​hypervisor/​virtual_machine/​mshv/​x86_64.rs Adapts the debugger translation interface.
src/​hyperlight_host/​src/​hypervisor/​virtual_machine/​mshv/​aarch64.rs Implements the ARM64 MSHV backend and debugger.
src/​hyperlight_host/​src/​hypervisor/​virtual_machine/​mod.rs Adds ARM64 debug exit and setup error support.
src/​hyperlight_host/​src/​hypervisor/​virtual_machine/​kvm/​x86_64.rs Adapts the debugger translation interface.
src/​hyperlight_host/​src/​hypervisor/​virtual_machine/​kvm/​aarch64.rs Explicitly rejects unsupported KVM debugging.
src/​hyperlight_host/​src/​hypervisor/​hyperlight_vm/​x86_64.rs Uses shared debugger handling and breakpoint storage.
src/​hyperlight_host/​src/​hypervisor/​hyperlight_vm/​mod.rs Integrates ARM64 debug stops and cancellation handling.
src/​hyperlight_host/​src/​hypervisor/​hyperlight_vm/​debug.rs Provides shared requests, memory access, and breakpoint handling.
src/​hyperlight_host/​src/​hypervisor/​hyperlight_vm/​aarch64.rs Connects MSHV, debug vectors, and initial stops.
src/​hyperlight_host/​src/​hypervisor/​gdb/​target.rs Supports ARM64 register packets and target operations.
src/​hyperlight_host/​src/​hypervisor/​gdb/​mod.rs Adds page-table translation and instruction-cache flushing.
src/​hyperlight_host/​src/​hypervisor/​gdb/​event_loop.rs Handles ARM64 initial-stop notifications.
src/​hyperlight_host/​src/​hypervisor/​gdb/​arch/​x86_64.rs Isolates x86 breakpoint and stop classification.
src/​hyperlight_host/​src/​hypervisor/​gdb/​arch/​aarch64.rs Defines ARM64 BRK encoding and alignment checks.
src/​hyperlight_host/​src/​hypervisor/​gdb/​arch.rs Selects architecture-specific debugger helpers.
src/​hyperlight_host/​examples/​guest-debugging/​main.rs Adds ARM64 real-client debugger tests.
src/​hyperlight_host/​build.rs Enables debug-build GDB support for ARM64 Linux/MSHV.
src/​hyperlight_guest_bin/​src/​arch/​aarch64/​exception/​entry.rs Forwards synchronous exceptions through HVC.
src/​hyperlight_common/​src/​arch/​aarch64/​exn.rs Defines the shared debug HVC immediate.
Justfile Supports nextest selection and broader debugger test filters.
docs/​how-to-debug-a-hyperlight-guest.md Documents MSHV debugging and snapshot constraints.
docs/​gdb-commit-layers.md Documents shared and backend-specific commit dependencies.
CHANGELOG.md Records backend, debugging, and recovery support.
.github/​workflows/​ValidatePullRequest.yml Adds ARM64 MSHV debug and release jobs.
.github/​workflows/​dep_build_test.yml Configures native MSHV runners and debugger validation.
.config/​nextest.toml Limits concurrent partition-heavy tests.

Review effort: Balanced

@cshung
cshung force-pushed the cshung/mshv-aarch64-gdb branch 2 times, most recently from d38fe01 to 46beba7 Compare November 12, 2026 00:12
@hyperlight-gh-bot

This comment has been minimized.

@cshung
cshung force-pushed the cshung/mshv-aarch64-gdb branch from 46beba7 to 19159c6 Compare November 12, 2026 18:15
@hyperlight-gh-bot

This comment has been minimized.

@yoshuawuyts yoshuawuyts added S-nominated Item nominated for the next triage meeting O-aarch64 Specific to 64-bit Arm processors O-linux Linux host support O-mshv Linux MSHV backend for Microsoft Hyper-V labels Nov 16, 2026
@cshung
cshung force-pushed the cshung/mshv-aarch64-gdb branch from 19159c6 to e1fef27 Compare November 16, 2026 18:16
@hyperlight-gh-bot

This comment has been minimized.

@cshung
cshung force-pushed the cshung/mshv-aarch64-gdb branch from e1fef27 to ced5079 Compare November 20, 2026 00:08
@hyperlight-gh-bot

This comment has been minimized.

@cshung
cshung force-pushed the cshung/mshv-aarch64-gdb branch from ced5079 to ab1ec3d Compare November 20, 2026 03:14
@hyperlight-gh-bot

This comment has been minimized.

cshung added a commit that referenced this pull request Nov 23, 2026
## ARM64 Linux MSHV

The backend provides partition creation, memory mappings, MMIO dispatch,
batched register access, and replacement-VM reset. MMIO PC advancement
wraps
at the address boundary. GIC addresses use the shared layout constants.

Native ARM64 MSHV CI uses hierarchical-virtualization runners and
bounded test
scheduling for the platform's partition budget. Test concurrency follows
the
selected hypervisor at runtime. Stress tests retain their iteration
counts.

Partition reuse is tracked in #2080. Guest debugging is in #2052.

## Validation

November 19, source `c51ec90f`, base `5fe5c8f8`:

* Windows x64 formatting, `just clippy`, `just build`, and the full
`just test` recipe pass.
* ARM64 Linux cross-Clippy passes with default, MSHV-only, and KVM-only
features.
* Native ARM64 Linux/MSHV passes all four backend tests with default and
MSHV-only features, including GPR and FPU round trips.
* With this backend, #2052 passes native formatting, Clippy, fresh
debug/release Rust and C guest builds, 481 library tests (13 ignored),
five concurrency tests, and seven real GDB client tests.

Signed-off-by: cshung <3410332+cshung@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@cshung
cshung force-pushed the cshung/mshv-aarch64-gdb branch from ab1ec3d to bc44203 Compare November 23, 2026 17:25
@hyperlight-gh-bot

This comment has been minimized.

@cshung
cshung force-pushed the cshung/mshv-aarch64-gdb branch from bc44203 to 6fe29f5 Compare November 24, 2026 19:30
@hyperlight-gh-bot

This comment has been minimized.

@cshung
cshung force-pushed the cshung/mshv-aarch64-gdb branch 3 times, most recently from bc2f595 to 553ee91 Compare November 25, 2026 17:22
@hyperlight-gh-bot

This comment has been minimized.

@cshung
cshung force-pushed the cshung/mshv-aarch64-gdb branch from 553ee91 to a05ef92 Compare November 25, 2026 18:40
cshung and others added 4 commits November 25, 2026 10:41
Architecture adapters, software breakpoints, page-sized memory access and recovery handling are shared by backend layers. Guest debug vectors and common tests support ARM64. Backend layers control platform enablement.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Signed-off-by: cshung <3410332+cshung@users.noreply.github.com>
ARM64 page-table translation lives with the architecture helpers. Software breakpoint storage stays behind its methods. Debug-exit bindings and cfg placement follow the surrounding style.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Signed-off-by: cshung <3410332+cshung@users.noreply.github.com>
Keep the initial stop in the run loop. Let GDB own software breakpoint step-over and use hardware single-step for step requests. Apply snapshot breakpoint guards to both architectures.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Signed-off-by: cshung <3410332+cshung@users.noreply.github.com>
Debugger register and memory edits can violate guest invariants. Reject snapshot creation for the lifetime of debug-configured sandboxes on x86_64 and ARM64, including after detach. Keep loading and restoring existing snapshots available with the existing breakpoint safeguards.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Signed-off-by: cshung <3410332+cshung@users.noreply.github.com>
@cshung
cshung force-pushed the cshung/mshv-aarch64-gdb branch from a05ef92 to bf86c7b Compare November 25, 2026 18:42
@hyperlight-gh-bot

This comment has been minimized.

Match the error directly so the regression test does not require Snapshot to implement Debug.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Signed-off-by: cshung <3410332+cshung@users.noreply.github.com>
@cshung
cshung force-pushed the cshung/mshv-aarch64-gdb branch from bf86c7b to 2ba8c77 Compare November 25, 2026 19:20
cshung and others added 3 commits November 25, 2026 11:46
The initialized-snapshot regression builds a memory manager inside the ARM64-only test.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Signed-off-by: cshung <3410332+cshung@users.noreply.github.com>
MSHV forwards guest debug exceptions through intercepted HVCs. Register access uses the saved exception context and active stack pointer. Two hardware breakpoints and single-step survive replacement-VM reset. Native ARM64 GDB tests run in debug CI. Non-debug KVM use is available with default features.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Signed-off-by: cshung <3410332+cshung@users.noreply.github.com>
Restore debug enablement and hardware breakpoints in the replacement VM without carrying single-step state. Handle unsupported KVM stepping explicitly.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Signed-off-by: cshung <3410332+cshung@users.noreply.github.com>
@cshung
cshung force-pushed the cshung/mshv-aarch64-gdb branch from 2ba8c77 to 150882e Compare November 25, 2026 19:46
@hyperlight-gh-bot

Copy link
Copy Markdown

Benchmark Results

Measured commit: 150882e2a0ff
Baseline commit: c46735cd076c

kvm / amd (Linux) (➖ stable)

No benchmark improved or regressed.

Benchmark Results

function_call_codec

encode_control decode_vec_bytes_copy
byte_chunks 284.28 ns (➖ 1.03x slower)
vec_bytes 79.23 ns (➖ 1.01x faster)
372.29 µs (➖ 1.00x faster)

payload_allocation

slot_pool_segmented
65536 141.48 ns (➖ 1.00x faster)
262144 527.31 ns (➖ 1.01x faster)

sandboxes

create_initialized_and_drop
medium 14.00 ms (➖ 1.01x faster)

slot_pool

alloc_dealloc_4096 alloc_dealloc_1500 alloc_dealloc_128
7.69 ns (➖ 1.00x slower) 7.68 ns (➖ 1.00x faster) 7.69 ns (➖ 1.00x slower)

snapshot_files

load_snapshot_unverified
small 112.51 µs (➖ 1.05x slower)

virtq_readonly

slot_pool_segmented slot_pool_segmented_fragmented
65536 1.91 µs (➖ 1.08x faster) 2.15 µs (➖ 1.11x slower)
262144 7.15 µs (➖ 1.37x faster) 7.15 µs (➖ 1.35x faster)

virtq_readwrite

slot_pool_segmented slot_pool_segmented_fragmented
65536 6.22 µs (➖ 1.03x faster) 6.15 µs (➖ 1.05x faster)
262144 27.00 µs (➖ 1.01x faster)
8192 1.03 µs (➖ 1.01x slower) 1.03 µs (➖ 1.01x faster)
kvm / intel (Linux) (➖ stable)

No benchmark improved or regressed.

Benchmark Results

function_call_codec

encode_control decode_vec_bytes_copy
byte_chunks 265.12 ns (➖ 1.05x faster)
vec_bytes 84.03 ns (➖ 1.00x slower)
677.53 µs (➖ 1.01x faster)

payload_allocation

slot_pool_segmented
65536 135.71 ns (➖ 1.01x faster)
262144 501.40 ns (➖ 1.01x faster)

sandboxes

create_initialized_and_drop
medium 14.97 ms (➖ 1.06x faster)

slot_pool

alloc_dealloc_4096 alloc_dealloc_1500 alloc_dealloc_128
7.85 ns (➖ 1.12x slower) 7.06 ns (➖ 1.00x faster) 8.29 ns (➖ 1.18x slower)

snapshot_files

load_snapshot_unverified
small 55.74 µs (➖ 1.04x slower)

virtq_readonly

slot_pool_segmented slot_pool_segmented_fragmented
65536 2.17 µs (➖ 1.01x slower) 2.15 µs (➖ 1.01x faster)
262144 7.62 µs (➖ 1.00x slower) 7.64 µs (➖ 1.01x slower)

virtq_readwrite

slot_pool_segmented slot_pool_segmented_fragmented
65536 7.03 µs (➖ 1.03x faster) 7.09 µs (➖ 1.01x faster)
262144 29.74 µs (➖ 1.07x faster)
8192 713.24 ns (➖ 1.00x faster) 722.77 ns (➖ 1.02x faster)
mshv3 / amd (Linux) (➖ stable)

No benchmark improved or regressed.

Benchmark Results

function_call_codec

encode_control decode_vec_bytes_copy
byte_chunks 358.79 ns (➖ 1.05x faster)
vec_bytes 97.85 ns (➖ 1.01x slower)
335.74 µs (➖ 1.25x slower)

payload_allocation

slot_pool_segmented
65536 192.14 ns (➖ 1.00x faster)
262144 728.72 ns (➖ 1.00x faster)

sandboxes

create_initialized_and_drop
medium 62.56 ms (➖ 1.02x faster)

slot_pool

alloc_dealloc_4096 alloc_dealloc_1500 alloc_dealloc_128
10.06 ns (➖ 1.01x slower) 9.87 ns (➖ 1.00x slower) 9.86 ns (➖ 1.05x faster)

snapshot_files

load_snapshot_unverified
small 106.89 µs (➖ 1.08x slower)

virtq_readonly

slot_pool_segmented slot_pool_segmented_fragmented
65536 2.22 µs (➖ 1.01x faster) 2.43 µs (➖ 1.02x faster)
262144 9.76 µs (➖ 1.01x faster) 10.04 µs (➖ 1.00x faster)

virtq_readwrite

slot_pool_segmented slot_pool_segmented_fragmented
65536 8.13 µs (➖ 1.19x faster) 8.57 µs (➖ 1.18x faster)
262144 36.29 µs (➖ 1.04x faster)
8192 1.20 µs (➖ 1.01x slower) 1.20 µs (➖ 1.05x faster)
mshv3 / intel (Linux) (➖ stable)

No benchmark improved or regressed.

Benchmark Results

function_call_codec

encode_control decode_vec_bytes_copy
byte_chunks 371.40 ns (➖ 1.05x faster)
vec_bytes 85.25 ns (➖ 1.01x slower)
737.24 µs (➖ 1.10x slower)

payload_allocation

slot_pool_segmented
65536 172.14 ns (➖ 1.02x slower)
262144 633.81 ns (➖ 1.01x faster)

sandboxes

create_initialized_and_drop
medium 79.96 ms (➖ 1.08x slower)

slot_pool

alloc_dealloc_4096 alloc_dealloc_1500 alloc_dealloc_128
8.67 ns (➖ 1.00x faster) 8.93 ns (➖ 1.01x faster) 8.73 ns (➖ 1.00x slower)

snapshot_files

load_snapshot_unverified
small 53.27 µs (➖ 1.03x slower)

virtq_readonly

slot_pool_segmented slot_pool_segmented_fragmented
65536 2.27 µs (➖ 1.01x slower) 2.27 µs (➖ 1.00x faster)
262144 7.88 µs (➖ 1.00x slower) 7.87 µs (➖ 1.00x faster)

virtq_readwrite

slot_pool_segmented slot_pool_segmented_fragmented
65536 7.38 µs (➖ 1.00x faster) 7.44 µs (➖ 1.01x faster)
262144 38.45 µs (➖ 1.04x faster)
8192 893.46 ns (➖ 1.01x faster) 889.21 ns (➖ 1.03x faster)
hyperv-ws2025 / amd (Windows) (➖ stable)

No benchmark improved or regressed.

Benchmark Results

function_call_codec

encode_control decode_vec_bytes_copy
byte_chunks 558.54 ns (➖ 1.01x faster)
vec_bytes 158.31 ns (➖ 1.03x faster)
2.04 ms (➖ 1.01x faster)

payload_allocation

slot_pool_segmented
65536 236.35 ns (➖ 1.03x slower)
262144 792.58 ns (➖ 1.00x faster)

sandboxes

create_initialized_and_drop
medium 13.00 ms (➖ 1.02x slower)

slot_pool

alloc_dealloc_4096 alloc_dealloc_1500 alloc_dealloc_128
11.22 ns (➖ 1.07x slower) 10.08 ns (➖ 1.00x faster) 10.36 ns (➖ 1.00x faster)

snapshot_files

load_snapshot_unverified
small 698.60 µs (➖ 1.03x slower)

virtq_readonly

slot_pool_segmented slot_pool_segmented_fragmented
65536 2.36 µs (➖ 1.01x faster) 2.35 µs (➖ 1.02x faster)
262144 9.36 µs (➖ 1.01x faster) 9.04 µs (➖ 1.07x faster)

virtq_readwrite

slot_pool_segmented slot_pool_segmented_fragmented
65536 8.97 µs (➖ 1.03x slower) 8.96 µs (➖ 1.04x faster)
262144 39.67 µs (➖ 1.03x faster)
8192 1.23 µs (➖ 1.09x faster) 1.24 µs (➖ 1.04x faster)
hyperv-ws2025 / intel (Windows) (➖ stable)

No benchmark improved or regressed.

Benchmark Results

function_call_codec

encode_control decode_vec_bytes_copy
byte_chunks 576.59 ns (➖ 1.00x slower)
vec_bytes 161.65 ns (➖ 1.02x faster)
3.09 ms (➖ 1.02x slower)

payload_allocation

slot_pool_segmented
65536 212.39 ns (➖ 1.00x faster)
262144 762.41 ns (➖ 1.01x slower)

sandboxes

create_initialized_and_drop
medium 13.79 ms (➖ 1.04x faster)

slot_pool

alloc_dealloc_4096 alloc_dealloc_1500 alloc_dealloc_128
10.10 ns (➖ 1.00x faster) 9.76 ns (➖ 1.00x faster) 9.87 ns (➖ 1.00x slower)

snapshot_files

load_snapshot_unverified
small 596.34 µs (➖ 1.02x slower)

virtq_readonly

slot_pool_segmented slot_pool_segmented_fragmented
65536 2.31 µs (➖ 1.01x slower) 2.26 µs (➖ 1.02x faster)
262144 7.81 µs (➖ 1.01x slower) 7.51 µs (➖ 1.03x faster)

virtq_readwrite

slot_pool_segmented slot_pool_segmented_fragmented
65536 8.28 µs (➖ 1.01x slower) 8.29 µs (➖ 1.03x faster)
262144 41.39 µs (➖ 1.07x faster)
8192 1.04 µs (➖ 1.13x faster) 1.08 µs (➖ 1.02x slower)

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

@yoshuawuyts yoshuawuyts removed the S-nominated Item nominated for the next triage meeting label Nov 30, 2026

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

C-enhancement For PRs adding features, improving functionality, docs, tests, etc. O-aarch64 Specific to 64-bit Arm processors O-linux Linux host support O-mshv Linux MSHV backend for Microsoft Hyper-V S-needs-review PR is ready for (re-)review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants