Repository navigation
Conversation
There was a problem hiding this comment.
🟡 Changes recommended
Resume translation errors can terminate the debugger session, and partially successful code writes can return without synchronizing the guest instruction cache.
2 open issues
What changed in this PR
This PR provides shared ARM64 debugger infrastructure for Hyperlight’s WHP, KVM and MSHV backends. ARM64 platform enablement remains in separate backend PRs.
Changes:
- Adds architecture-specific register handling, breakpoint support and shared debugger request processing.
- Adds guest-page-sized memory access, cache synchronization hooks and snapshot recovery safeguards.
- Adds debugger tests, guest exception forwarding and backend-layer documentation.
| File | Description |
|---|---|
src/hyperlight_host/src/sandbox/uninitialized_evolve.rs |
Initializes ARM64 guest debug vectors. |
src/hyperlight_host/src/sandbox/snapshot/memory/backing.rs |
Exposes backing ranges for cache synchronization. |
src/hyperlight_host/src/sandbox/initialized.rs |
Adds breakpoint guards, recovery handling and tests. |
src/hyperlight_host/src/mem/mgr.rs |
Exposes guest backing host ranges to debugging code. |
src/hyperlight_host/src/mem/exe.rs |
Carries debug-vector addresses in load metadata. |
src/hyperlight_host/src/mem/elf.rs |
Finds and relocates guest debug-vector symbols. |
src/hyperlight_host/src/hypervisor/virtual_machine/whp/x86_64.rs |
Adopts the shared address-translation interface. |
src/hyperlight_host/src/hypervisor/virtual_machine/mshv/x86_64.rs |
Adopts the shared address-translation interface. |
src/hyperlight_host/src/hypervisor/virtual_machine/mod.rs |
Adds ARM64 debug exit and initialization types. |
src/hyperlight_host/src/hypervisor/virtual_machine/kvm/x86_64.rs |
Adopts the shared address-translation interface. |
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 shared debug state and stop handling. |
src/hyperlight_host/src/hypervisor/hyperlight_vm/debug.rs |
Implements shared requests, breakpoints and ARM64 stepping. |
src/hyperlight_host/src/hypervisor/hyperlight_vm/aarch64.rs |
Adds debugger initialization and reset hooks. |
src/hyperlight_host/src/hypervisor/gdb/target.rs |
Supports ARM64 register packets and conversion tests. |
src/hyperlight_host/src/hypervisor/gdb/mod.rs |
Adds page-table translation and cache synchronization hooks. |
src/hyperlight_host/src/hypervisor/gdb/event_loop.rs |
Handles ARM64 initial-stop notifications. |
src/hyperlight_host/src/hypervisor/gdb/arch/x86_64.rs |
Contains x86_64 breakpoint and stop classification logic. |
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 the architecture-specific debugger adapter. |
src/hyperlight_host/examples/guest-debugging/main.rs |
Adds ARM64 GDB client scenarios. |
src/hyperlight_guest_bin/src/arch/aarch64/exception/entry.rs |
Exports debug vectors and forwards synchronous exceptions. |
src/hyperlight_common/src/arch/aarch64/exn.rs |
Defines the debug exception HVC immediate. |
Justfile |
Includes shared debugger and recovery test filters. |
docs/gdb-commit-layers.md |
Documents backend dependencies and validation requirements. |
CHANGELOG.md |
Records debugger memory-access and recovery fixes. |
Review effort: Balanced
a1e7706 to
1790d3c
Compare
This comment has been minimized.
This comment has been minimized.
1790d3c to
7d01a90
Compare
This comment has been minimized.
This comment has been minimized.
7d01a90 to
2ceebf4
Compare
This comment has been minimized.
This comment has been minimized.
2ceebf4 to
bec37d8
Compare
This comment has been minimized.
This comment has been minimized.
bec37d8 to
5e34600
Compare
This comment has been minimized.
This comment has been minimized.
5e34600 to
39376e2
Compare
This comment has been minimized.
This comment has been minimized.
| self.handle_initial_debug_stop(mem_mgr) | ||
| .map_err(super::RunVmError::DebugHandler)?; | ||
|
|
||
| self.run(mem_mgr, host_funcs) |
There was a problem hiding this comment.
The handle_initial_debug_stop eventually calls handle_debug, why can't this be handled by the default path through the self.run here?
| .set_regs(®s) | ||
| .map_err(DispatchGuestCallError::SetupRegs)?; | ||
| #[cfg(gdb)] | ||
| self.handle_initial_debug_stop(mem_mgr) |
There was a problem hiding this comment.
Shouldn't this be done only on initialise step? Or is this the case for an already initialised sandbox loaded from a snapshot?
| #[cfg(gdb)] | ||
| if self.gdb_conn.is_some() { | ||
| self.vm | ||
| .set_single_step(false) |
There was a problem hiding this comment.
Is this really needed?
The x86 variants already reset the debug registers when the vm.reset_vcpu is called, so this is not needed for x86.
I think the need for it in AARCH64 stems from the default implementation for the Trait of the set_single_step. Maybe it would be better, semantically speaking, to implement it explicitly and return not supported to avoid always setting single step to false here (that always returns Ok).
| } | ||
|
|
||
| #[cfg(target_arch = "aarch64")] | ||
| fn begin_software_step( |
There was a problem hiding this comment.
I'm not sure what the motivation was to do SW breakpoint stepping, but when I've implemented the x86 debugging support, I didn't have to do that because most debuggers (gdb especially) do this by themselves. When you want to step (software step, the usual approach), it adds a SW breakpoint at the next instruction automatically by calculating what the offset is. It's separate from the hardware stepping.
The Hardware stepping is done by specifically invoking si in gdb, that only steps one CPU instruction.
Maybe we can get away from having to do this SW breakpoint stepping ourselves.
| } | ||
| } | ||
| #[cfg(target_arch = "aarch64")] | ||
| let stop_reason = if self.pending_software_step.is_some() { |
There was a problem hiding this comment.
See the SW stepping comment I left in debug.rs maybe all this SW stepping logic can go away.
|
Maybe it would be helpful to use the stacked PRs feature of GH to chain these PRs together. |
ea843fb to
8d25a98
Compare
This comment has been minimized.
This comment has been minimized.
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>
b258a30 to
905faf2
Compare
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>
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>
Benchmark ResultsMeasured commit: kvm / amd (Linux) (➖ stable)No benchmark improved or regressed. Benchmark Resultsfunction_call_codec
payload_allocation
sandboxes
slot_pool
snapshot_files
virtq_readonly
virtq_readwrite
kvm / intel (Linux) (➖ stable)No benchmark improved or regressed. Benchmark Resultsfunction_call_codec
payload_allocation
sandboxes
slot_pool
snapshot_files
virtq_readonly
virtq_readwrite
mshv3 / amd (Linux) (➖ stable)No benchmark improved or regressed. Benchmark Resultsfunction_call_codec
payload_allocation
sandboxes
slot_pool
snapshot_files
virtq_readonly
virtq_readwrite
mshv3 / intel (Linux) (➖ stable)No benchmark improved or regressed. Benchmark Resultsfunction_call_codec
payload_allocation
sandboxes
slot_pool
snapshot_files
virtq_readonly
virtq_readwrite
hyperv-ws2025 / amd (Windows) (➖ stable)No benchmark improved or regressed. Benchmark Resultsfunction_call_codec
payload_allocation
sandboxes
slot_pool
snapshot_files
virtq_readonly
virtq_readwrite
hyperv-ws2025 / intel (Windows) (➖ stable)No benchmark improved or regressed. Benchmark Resultsfunction_call_codec
payload_allocation
sandboxes
slot_pool
snapshot_files
virtq_readonly
virtq_readwrite
Reported by |

Shared GDB support
Architecture adapters and common debugger handling support ARM64 register
packets, software breakpoints, page-sized memory access, guest debug vectors,
and snapshot, cancellation and crash-detach recovery.
The existing x86_64 platform guard remains. Backend PRs enable ARM64 GDB.
Related PRs
Backend integration is in #1907 for WHP, #2016 for KVM, and #2052 for MSHV.
The MSHV backend is part of
mainthrough #1626.Validation
November 23, base
f297a914:just testrecipe, and focused debugger tests pass.just clippyw.November 19 native ARM64 MSHV validation through #2052 passed 481 library
tests (13 ignored), five concurrency tests, and seven real GDB client tests.
Native ARM64 runtime tests have not been repeated on this base.