Skip to content

feat(aarch64): add GDB debugging for Windows ARM64 WHP - #1907

Open
cshung wants to merge 9 commits into
hyperlight-dev:mainfrom
cshung:cshung/whp-aarch64-gdb
Open

cshung wants to merge 9 commits into
hyperlight-dev:mainfrom
cshung:cshung/whp-aarch64-gdb

Conversation

@cshung

@cshung cshung commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

Windows ARM64 WHP GDB

WHP guests support register and memory access, two hardware breakpoints,
four-byte BRK software breakpoints, and hardware single-step.
Guest synchronous exception vectors forward debug stops through HVC.
The backend preserves interrupted context and debugger state across cache
synchronization and vCPU reset.

Dependencies

Requires shared debugger support in #2050. This PR provides WHP integration,
platform enablement, the read-only cache-sync page, and backend tests.
The full diff includes the shared prerequisite.

WHP-only comparison.

Validation

November 23, base f297a914:

  • Formatting, Windows ARM64 GDB-enabled cross-Clippy, and Linux just clippyw pass.
  • Windows x64 Clippy and focused debugger tests pass.
  • The shared prerequisite passes fresh guests, build, and the full Windows just test recipe.

Earlier native Windows ARM64 validation passed six real GDB client tests and
14 backend/recovery tests on the combined WHP/KVM tree.
Shared support has November 19 native ARM64 MSHV validation through #2052.
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 Oct 8, 2026
@hyperlight-gh-bot

This comment has been minimized.

@cshung
cshung marked this pull request as ready for review October 8, 2026 19:33
Copilot AI balanced review requested due to automatic review settings October 8, 2026 19:33

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

Breakpoint state can survive crash or cancellation recovery, and the hidden cache-sync mapping conflicts with the public mapping contract.

4 open findings
What changed in this PR

Adds Windows ARM64 WHP guest debugging and generalizes the GDB implementation across architectures.

Changes:

  • Adds ARM64 registers, software breakpoints, stepping, and cache synchronization.
  • Extracts shared debugger logic from x86_64 code.
  • Updates tests, documentation, and platform configuration.
File Description
CHANGELOG.md Records ARM64 GDB support.
docs/​how-to-debug-a-hyperlight-guest.md Documents architecture-specific capabilities.
src/​hyperlight_host/​build.rs Enables GDB on Windows ARM64.
src/​hyperlight_host/​examples/​guest-debugging/​main.rs Adds ARM64 debugging tests.
src/​hyperlight_host/​src/​hypervisor/​gdb/​arch.rs Dispatches architecture-specific logic.
src/​hyperlight_host/​src/​hypervisor/​gdb/​arch/​aarch64.rs Implements ARM64 breakpoint and step decoding.
src/​hyperlight_host/​src/​hypervisor/​gdb/​arch/​x86_64.rs Houses extracted x86_64 logic.
src/​hyperlight_host/​src/​hypervisor/​gdb/​event_loop.rs Maps ARM64 stop reasons.
src/​hyperlight_host/​src/​hypervisor/​gdb/​mod.rs Extends shared debugging interfaces.
src/​hyperlight_host/​src/​hypervisor/​gdb/​target.rs Adds architecture-specific GDB registers.
src/​hyperlight_host/​src/​hypervisor/​hyperlight_vm/​aarch64.rs Connects GDB to ARM64 VMs.
src/​hyperlight_host/​src/​hypervisor/​hyperlight_vm/​debug.rs Centralizes breakpoint and stepping state.
src/​hyperlight_host/​src/​hypervisor/​hyperlight_vm/​mod.rs Handles ARM64 debug exits.
src/​hyperlight_host/​src/​hypervisor/​hyperlight_vm/​x86_64.rs Removes extracted debugger logic.
src/​hyperlight_host/​src/​hypervisor/​virtual_machine/​mod.rs Extends VM exits and errors.
src/​hyperlight_host/​src/​hypervisor/​virtual_machine/​whp/​aarch64.rs Implements WHP debugging and cache synchronization.
src/​hyperlight_host/​src/​sandbox/​initialized.rs Guards snapshots with active breakpoints.

🧠 Review effort: Balanced


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

@cshung
cshung force-pushed the cshung/whp-aarch64-gdb branch from 8c0c245 to 39ea4cb Compare October 9, 2026 16:54
@hyperlight-gh-bot

This comment has been minimized.

@syntactically

Copy link
Copy Markdown
Member

@cshung I guess you are using software breakpoints here because WHPX aarch64 does not yet support setting MDCR_EL2.TDE. I think this is very divergent from the other implementations and especially the emulation of software step looks very fragile in its current state.

I wonder if we can make things a little bit more congruent with the other implementations by using the same hardware debug approach as other targets, but on WHP set MDSCR_EL1.KDE and have little assembly stubs catch this case and make hvcs (or, even make an hvc on every exception entry, when in gdb mode)? Admittedly this will not work very well if VBAR_EL1 or virtual memory configuration for the exception handlers are messed up, but in that case I think given the current guest architecture it is extremely unlikely that guest code would continue to execute and produce any useful results.

@cshung
cshung force-pushed the cshung/whp-aarch64-gdb branch from 7238539 to 6c35092 Compare October 19, 2026 14:56
@hyperlight-gh-bot

This comment has been minimized.

@hyperlight-gh-bot

This comment has been minimized.

@hyperlight-gh-bot

This comment has been minimized.

@cshung
cshung force-pushed the cshung/whp-aarch64-gdb branch from dd86b49 to 698b851 Compare October 20, 2026 17:59
@hyperlight-gh-bot

This comment has been minimized.

@cshung
cshung force-pushed the cshung/whp-aarch64-gdb branch from 698b851 to 3e3983f Compare October 26, 2026 16:30
@hyperlight-gh-bot

This comment has been minimized.

@cshung
cshung force-pushed the cshung/whp-aarch64-gdb branch from 3e3983f to bed283f Compare October 30, 2026 16:47
@hyperlight-gh-bot

This comment has been minimized.

@cshung
cshung force-pushed the cshung/whp-aarch64-gdb branch from bed283f to 905ca05 Compare November 2, 2026 16:19
@hyperlight-gh-bot

This comment has been minimized.

@cshung
cshung force-pushed the cshung/whp-aarch64-gdb branch from 8cce8f0 to 6c2307b Compare November 16, 2026 18:16
@hyperlight-gh-bot

This comment has been minimized.

@hyperlight-gh-bot

This comment has been minimized.

@cshung
cshung force-pushed the cshung/whp-aarch64-gdb branch from e02c22c to 93a3c0c Compare November 23, 2026 17:25
@hyperlight-gh-bot

This comment has been minimized.

@cshung
cshung force-pushed the cshung/whp-aarch64-gdb branch from 93a3c0c to b078024 Compare November 24, 2026 19:30
@hyperlight-gh-bot

This comment has been minimized.

@dblnz dblnz 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.

Hey, could you add some explainer about how debugging works with this changes? What the page cache is used for and what the general flow is?
I remember there's a documentation for debugging that explains how it works.

}

// Check against the hidden debug cache-sync page
#[cfg(all(gdb, target_arch = "aarch64", target_os = "windows"))]

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.

Could you elaborate a bit on this cache page? Why it's used?

@cshung
cshung force-pushed the cshung/whp-aarch64-gdb branch 3 times, most recently from 56ae2b4 to db3a774 Compare November 25, 2026 17:22
@hyperlight-gh-bot

This comment has been minimized.

@cshung
cshung force-pushed the cshung/whp-aarch64-gdb branch from db3a774 to be0fb30 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/whp-aarch64-gdb branch from be0fb30 to 71b3dc9 Compare November 25, 2026 18:42
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/whp-aarch64-gdb branch from 71b3dc9 to 62f0357 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>
Guest debug exceptions reach WHP through HVC. Saved exception context, hardware breakpoints and single-step survive cache synchronization and vCPU reset. The cache-sync trampoline is read-only to guests. Shared debugger behavior belongs to the parent commit.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Signed-off-by: cshung <3410332+cshung@users.noreply.github.com>
Describe exception forwarding, saved context, and guest instruction-cache synchronization. Check that reset clears hardware single-step.

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/whp-aarch64-gdb branch from 62f0357 to 04b1b50 Compare November 25, 2026 19:46
@hyperlight-gh-bot

This comment has been minimized.

The debug matrix selects the guest-debugging examples and host GDB regressions on Windows ARM64.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Signed-off-by: cshung <3410332+cshung@users.noreply.github.com>
@hyperlight-gh-bot

Copy link
Copy Markdown

Benchmark Results

Measured commit: 0376c2edb8a5
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 290.40 ns (➖ 1.07x slower)
vec_bytes 79.23 ns (➖ 1.00x slower)
371.99 µs (➖ 1.00x faster)

payload_allocation

slot_pool_segmented
65536 141.15 ns (➖ 1.05x faster)
262144 520.65 ns (➖ 1.02x faster)

sandboxes

create_initialized_and_drop
medium 13.48 ms (➖ 1.01x faster)

slot_pool

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

snapshot_files

load_snapshot_unverified
small 108.86 µs (➖ 1.05x slower)

virtq_readonly

slot_pool_segmented slot_pool_segmented_fragmented
65536 1.93 µs (➖ 1.10x faster) 2.04 µs (➖ 1.06x slower)
262144 7.00 µs (➖ 1.01x slower) 7.20 µs (➖ 1.02x slower)

virtq_readwrite

slot_pool_segmented slot_pool_segmented_fragmented
65536 6.14 µs (➖ 1.02x faster) 6.18 µs (➖ 1.02x faster)
262144 26.70 µs (➖ 1.02x faster)
8192 1.04 µs (➖ 1.02x slower) 1.04 µ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 259.77 ns (➖ 1.01x faster)
vec_bytes 83.53 ns (➖ 1.00x slower)
655.53 µs (➖ 1.03x faster)

payload_allocation

slot_pool_segmented
65536 134.53 ns (➖ 1.02x faster)
262144 499.61 ns (➖ 1.00x slower)

sandboxes

create_initialized_and_drop
medium 14.87 ms (➖ 1.09x faster)

slot_pool

alloc_dealloc_4096 alloc_dealloc_1500 alloc_dealloc_128
6.93 ns (➖ 1.00x slower) 6.91 ns (➖ 1.00x slower) 6.94 ns (➖ 1.01x slower)

snapshot_files

load_snapshot_unverified
small 53.13 µs (➖ 1.02x faster)

virtq_readonly

slot_pool_segmented slot_pool_segmented_fragmented
65536 2.12 µs (➖ 1.00x slower) 2.12 µs (➖ 1.00x faster)
262144 7.47 µs (➖ 1.00x faster) 7.48 µs (➖ 1.00x slower)

virtq_readwrite

slot_pool_segmented slot_pool_segmented_fragmented
65536 6.92 µs (➖ 1.03x faster) 6.97 µs (➖ 1.01x faster)
262144 31.16 µs (➖ 1.08x slower)
8192 695.95 ns (➖ 1.02x faster) 723.39 ns (➖ 1.00x faster)
mshv3 / amd (Linux) (➖ stable)

No benchmark improved or regressed.

Benchmark Results

function_call_codec

encode_control decode_vec_bytes_copy
byte_chunks 363.63 ns (➖ 1.06x faster)
vec_bytes 96.78 ns (➖ 1.01x slower)
265.08 µs (➖ 1.13x faster)

payload_allocation

slot_pool_segmented
65536 199.74 ns (➖ 1.05x slower)
262144 720.20 ns (➖ 1.01x faster)

sandboxes

create_initialized_and_drop
medium 60.08 ms (➖ 1.04x faster)

slot_pool

alloc_dealloc_4096 alloc_dealloc_1500 alloc_dealloc_128
9.75 ns (➖ 1.00x faster) 9.68 ns (➖ 1.00x faster) 9.74 ns (➖ 1.01x faster)

snapshot_files

load_snapshot_unverified
small 102.38 µs (➖ 1.07x slower)

virtq_readonly

slot_pool_segmented slot_pool_segmented_fragmented
65536 2.17 µs (➖ 1.00x slower) 2.33 µs (➖ 1.02x faster)
262144 13.58 µs (➖ 1.42x slower) 14.32 µs (➖ 1.32x slower)

virtq_readwrite

slot_pool_segmented slot_pool_segmented_fragmented
65536 8.05 µs (➖ 1.19x faster) 9.60 µs (➖ 1.01x slower)
262144 35.53 µs (➖ 1.25x faster)
8192 1.26 µs (➖ 1.08x slower) 1.25 µs (➖ 1.01x slower)
mshv3 / intel (Linux) (➖ stable)

No benchmark improved or regressed.

Benchmark Results

function_call_codec

encode_control decode_vec_bytes_copy
byte_chunks 349.61 ns (➖ 1.00x slower)
vec_bytes 85.99 ns (➖ 1.01x slower)
708.21 µs (➖ 1.00x slower)

payload_allocation

slot_pool_segmented
65536 171.76 ns (➖ 1.01x slower)
262144 637.18 ns (➖ 1.01x slower)

sandboxes

create_initialized_and_drop
medium 69.92 ms (➖ 1.15x slower)

slot_pool

alloc_dealloc_4096 alloc_dealloc_1500 alloc_dealloc_128
8.67 ns (➖ 1.01x faster) 9.16 ns (➖ 1.00x slower) 8.69 ns (➖ 1.01x faster)

snapshot_files

load_snapshot_unverified
small 57.26 µs (➖ 1.08x slower)

virtq_readonly

slot_pool_segmented slot_pool_segmented_fragmented
65536 2.30 µs (➖ 1.02x slower) 2.25 µs (➖ 1.00x faster)
262144 7.95 µs (➖ 1.00x slower) 8.00 µs (➖ 1.00x faster)

virtq_readwrite

slot_pool_segmented slot_pool_segmented_fragmented
65536 7.38 µs (➖ 1.01x faster) 7.40 µs (➖ 1.02x faster)
262144 38.42 µs (➖ 1.03x faster)
8192 900.20 ns (➖ 1.02x faster) 900.62 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 546.53 ns (➖ 1.01x faster)
vec_bytes 158.42 ns (➖ 1.00x slower)
2.00 ms (➖ 1.03x slower)

payload_allocation

slot_pool_segmented
65536 228.62 ns (➖ 1.01x faster)
262144 792.98 ns (➖ 1.01x faster)

sandboxes

create_initialized_and_drop
medium 13.14 ms (➖ 1.01x faster)

slot_pool

alloc_dealloc_4096 alloc_dealloc_1500 alloc_dealloc_128
10.36 ns (➖ 1.01x faster) 10.09 ns (➖ 1.00x slower) 10.77 ns (➖ 1.00x faster)

snapshot_files

load_snapshot_unverified
small 861.46 µs (➖ 1.10x faster)

virtq_readonly

slot_pool_segmented slot_pool_segmented_fragmented
65536 2.35 µs (➖ 1.00x slower) 2.31 µs (➖ 1.02x faster)
262144 9.35 µs (➖ 1.01x slower) 9.23 µs (➖ 1.02x faster)

virtq_readwrite

slot_pool_segmented slot_pool_segmented_fragmented
65536 8.84 µs (➖ 1.02x slower) 8.82 µs (➖ 1.00x slower)
262144 42.29 µs (➖ 1.17x faster)
8192 1.25 µs (➖ 1.06x faster) 1.26 µs (➖ 1.00x faster)
hyperv-ws2025 / intel (Windows) (➖ stable)

No benchmark improved or regressed.

Benchmark Results

function_call_codec

encode_control decode_vec_bytes_copy
byte_chunks 573.54 ns (➖ 1.34x faster)
vec_bytes 157.65 ns (➖ 1.02x faster)
3.25 ms (➖ 1.03x slower)

payload_allocation

slot_pool_segmented
65536 243.85 ns (➖ 1.16x slower)
262144 763.64 ns (➖ 1.24x faster)

sandboxes

create_initialized_and_drop
medium 15.19 ms (➖ 1.04x slower)

slot_pool

alloc_dealloc_4096 alloc_dealloc_1500 alloc_dealloc_128
10.06 ns (➖ 1.01x faster) 9.74 ns (➖ 1.00x slower) 9.89 ns (➖ 1.00x faster)

snapshot_files

load_snapshot_unverified
small 590.22 µs (➖ 1.03x faster)

virtq_readonly

slot_pool_segmented slot_pool_segmented_fragmented
65536 2.30 µs (➖ 1.01x slower) 2.28 µs (➖ 1.01x faster)
262144 7.77 µs (➖ 1.01x slower) 7.70 µs (➖ 1.00x slower)

virtq_readwrite

slot_pool_segmented slot_pool_segmented_fragmented
65536 8.27 µs (➖ 1.00x faster) 8.48 µs (➖ 1.01x faster)
262144 45.19 µs (➖ 1.27x faster)
8192 1.04 µs (➖ 1.11x faster) 1.05 µs (➖ 1.00x slower)

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants