Skip to content

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

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

cshung wants to merge 2 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 and others added 2 commits November 24, 2026 11:29
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>
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>
@cshung
cshung force-pushed the cshung/mshv-aarch64-gdb branch from bc44203 to 6fe29f5 Compare November 24, 2026 19:30
@hyperlight-gh-bot

Copy link
Copy Markdown

Benchmark Results

Measured commit: 6fe29f5cd6ac
Baseline commit: 81848a915b4e

kvm / amd (Linux) (➖ stable)

No benchmark improved or regressed.

Benchmark Results

function_call_codec

encode_control decode_vec_bytes_copy
byte_chunks 261.94 ns (➖ 1.10x faster)
vec_bytes 80.19 ns (➖ 1.01x faster)
373.29 µs (➖ 1.00x faster)

payload_allocation

slot_pool_segmented
65536 144.51 ns (➖ 1.01x slower)
262144 530.33 ns (➖ 1.01x slower)

sandboxes

create_initialized_and_drop
medium 13.88 ms (➖ 1.01x slower)

slot_pool

alloc_dealloc_4096 alloc_dealloc_1500 alloc_dealloc_128
7.67 ns (➖ 1.00x faster) 7.68 ns (➖ 1.14x faster) 7.82 ns (➖ 1.32x faster)

snapshot_files

load_snapshot_unverified
small 117.47 µs (➖ 1.01x slower)

virtq_readonly

slot_pool_segmented slot_pool_segmented_fragmented
65536 1.93 µs (➖ 1.12x faster) 2.03 µs (➖ 1.04x slower)
262144 7.00 µs (➖ 1.01x slower) 7.12 µs (➖ 1.01x faster)

virtq_readwrite

slot_pool_segmented slot_pool_segmented_fragmented
65536 6.14 µs (➖ 1.16x faster) 6.27 µs (➖ 1.03x faster)
262144 28.44 µs (➖ 1.03x slower)
8192 1.02 µs (➖ 1.01x faster) 1.02 µs (➖ 1.02x faster)
kvm / intel (Linux) (➖ stable)

No benchmark improved or regressed.

Benchmark Results

function_call_codec

encode_control decode_vec_bytes_copy
byte_chunks 305.76 ns (➖ 1.02x slower)
vec_bytes 94.44 ns (➖ 1.04x slower)
751.44 µs (➖ 1.01x slower)

payload_allocation

slot_pool_segmented
65536 200.66 ns (➖ 1.02x faster)
262144 587.16 ns (➖ 1.01x faster)

sandboxes

create_initialized_and_drop
medium 15.43 ms (➖ 1.03x faster)

slot_pool

alloc_dealloc_4096 alloc_dealloc_1500 alloc_dealloc_128
8.01 ns (➖ 1.00x slower) 8.00 ns (➖ 1.01x faster) 8.01 ns (➖ 1.01x faster)

snapshot_files

load_snapshot_unverified
small 64.89 µs (➖ 1.01x slower)

virtq_readonly

slot_pool_segmented slot_pool_segmented_fragmented
65536 2.48 µs (➖ 1.00x slower) 2.50 µs (➖ 1.01x faster)
262144 8.93 µs (➖ 1.00x faster) 8.90 µs (➖ 1.00x slower)

virtq_readwrite

slot_pool_segmented slot_pool_segmented_fragmented
65536 8.32 µs (➖ 1.01x faster) 8.23 µs (➖ 1.01x faster)
262144 34.49 µs (➖ 1.01x slower)
8192 834.51 ns (➖ 1.01x slower) 855.00 ns (➖ 1.01x slower)
mshv3 / amd (Linux) (➖ stable)

No benchmark improved or regressed.

Benchmark Results

function_call_codec

encode_control decode_vec_bytes_copy
byte_chunks 388.82 ns (➖ 1.05x slower)
vec_bytes 106.47 ns (➖ 1.02x slower)
266.50 µs (➖ 1.02x slower)

payload_allocation

slot_pool_segmented
65536 193.93 ns (➖ 1.01x slower)
262144 731.63 ns (➖ 1.01x slower)

sandboxes

create_initialized_and_drop
medium 66.36 ms (➖ 1.04x slower)

slot_pool

alloc_dealloc_4096 alloc_dealloc_1500 alloc_dealloc_128
9.52 ns (➖ 1.00x faster) 9.62 ns (➖ 1.01x faster) 9.51 ns (➖ 1.00x faster)

snapshot_files

load_snapshot_unverified
small 110.09 µs (➖ 1.07x slower)

virtq_readonly

slot_pool_segmented slot_pool_segmented_fragmented
65536 2.23 µs (➖ 1.00x slower) 2.39 µs (➖ 1.04x faster)
262144 10.20 µs (➖ 1.04x slower) 9.79 µs (➖ 1.03x faster)

virtq_readwrite

slot_pool_segmented slot_pool_segmented_fragmented
65536 8.34 µs (➖ 1.25x faster) 8.36 µs (➖ 1.17x faster)
262144 36.26 µs (➖ 1.05x faster)
8192 1.22 µs (➖ 1.01x faster) 1.23 µs (➖ 1.03x faster)
mshv3 / intel (Linux) (➖ stable)

No benchmark improved or regressed.

Benchmark Results

function_call_codec

encode_control decode_vec_bytes_copy
byte_chunks 364.53 ns (➖ 1.00x faster)
vec_bytes 90.05 ns (➖ 1.02x faster)
658.58 µs (➖ 1.22x faster)

payload_allocation

slot_pool_segmented
65536 258.10 ns (➖ 1.04x slower)
262144 678.46 ns (➖ 1.02x faster)

sandboxes

create_initialized_and_drop
medium 93.83 ms (➖ 1.10x faster)

slot_pool

alloc_dealloc_4096 alloc_dealloc_1500 alloc_dealloc_128
8.71 ns (➖ 1.00x faster) 8.77 ns (➖ 1.07x faster) 8.74 ns (➖ 1.00x faster)

snapshot_files

load_snapshot_unverified
small 60.00 µs (➖ 1.03x slower)

virtq_readonly

slot_pool_segmented slot_pool_segmented_fragmented
65536 2.29 µs (➖ 1.01x faster) 2.29 µs (➖ 1.00x faster)
262144 7.92 µs (➖ 1.01x faster) 7.90 µs (➖ 1.01x faster)

virtq_readwrite

slot_pool_segmented slot_pool_segmented_fragmented
65536 7.46 µs (➖ 1.08x faster) 7.49 µs (➖ 1.00x faster)
262144 38.80 µs (➖ 1.06x faster)
8192 900.78 ns (➖ 1.04x faster) 909.28 ns (➖ 1.01x faster)
hyperv-ws2025 / amd (Windows) (➖ stable)

No benchmark improved or regressed.

Benchmark Results

function_call_codec

encode_control decode_vec_bytes_copy
byte_chunks 568.97 ns (➖ 1.01x slower)
vec_bytes 161.57 ns (➖ 1.01x faster)
1.92 ms (➖ 1.01x faster)

payload_allocation

slot_pool_segmented
65536 229.47 ns (➖ 1.00x slower)
262144 789.33 ns (➖ 1.01x slower)

sandboxes

create_initialized_and_drop
medium 13.49 ms (➖ 1.08x slower)

slot_pool

alloc_dealloc_4096 alloc_dealloc_1500 alloc_dealloc_128
10.35 ns (➖ 1.04x slower) 9.99 ns (➖ 1.01x slower) 10.06 ns (➖ 1.01x slower)

snapshot_files

load_snapshot_unverified
small 809.60 µs (➖ 1.00x faster)

virtq_readonly

slot_pool_segmented slot_pool_segmented_fragmented
65536 2.35 µs (➖ 1.00x slower) 2.35 µs (➖ 1.00x faster)
262144 9.53 µs (➖ 1.03x slower) 9.23 µs (➖ 1.00x slower)

virtq_readwrite

slot_pool_segmented slot_pool_segmented_fragmented
65536 8.82 µs (➖ 1.00x slower) 8.69 µs (➖ 1.01x faster)
262144 38.48 µs (➖ 1.01x faster)
8192 1.31 µs (➖ 1.03x faster) 1.33 µ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 504.63 ns (➖ 1.01x faster)
vec_bytes 143.90 ns (➖ 1.05x slower)
3.20 ms (➖ 1.00x slower)

payload_allocation

slot_pool_segmented
65536 194.58 ns (➖ 1.01x slower)
262144 669.61 ns (➖ 1.02x slower)

sandboxes

create_initialized_and_drop
medium 13.01 ms (➖ 1.01x faster)

slot_pool

alloc_dealloc_4096 alloc_dealloc_1500 alloc_dealloc_128
8.62 ns (➖ 1.00x slower) 8.64 ns (➖ 1.02x faster) 8.62 ns (➖ 1.00x slower)

snapshot_files

load_snapshot_unverified
small 538.67 µs (➖ 1.00x faster)

virtq_readonly

slot_pool_segmented slot_pool_segmented_fragmented
65536 2.48 µs (➖ 1.00x slower) 2.49 µs (➖ 1.01x slower)
262144 8.58 µs (➖ 1.00x slower) 8.59 µs (➖ 1.00x faster)

virtq_readwrite

slot_pool_segmented slot_pool_segmented_fragmented
65536 9.19 µs (➖ 1.02x slower) 9.20 µs (➖ 1.01x slower)
262144 34.45 µs (➖ 1.01x faster)
8192 1.06 µs (➖ 1.03x faster) 1.06 µs (➖ 1.01x slower)

Reported by cargo ci bench-report --candidate run:45470882858 --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

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 S-nominated Item nominated for the next triage meeting

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants