Skip to content

Implement MSHV aarch64 backend - #1626

Draft
cshung wants to merge 7 commits into
hyperlight-dev:mainfrom
cshung:cshung/mshv-aarch64
Draft

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

Conversation

@cshung

@cshung cshung commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

Summary

Implements the VirtualMachine trait for MSHV on aarch64, replacing the previous stub.

Changes

  • mshv/aarch64.rs: Full implementation — VM creation, memory mapping, vcpu run loop with MMIO-based I/O dispatch, register access (general/FPU/special via hv_register_assoc), vcpu reset
  • hyperlight_vm/aarch64.rs: Wire up MshvVm::new() when MSHV is detected
  • memory_region.rs: Implement TryFrom<hv_arm64_memory_intercept_message> for MemoryRegionFlags

Design

  • Follows KVM aarch64 I/O page pattern (MMIO writes to I/O page GPA → port I/O)
  • Follows MSHV x86_64 patterns for partition creation and register access
  • Uses low-level get_reg/set_reg for system regs (get_sregs/set_sregs not available on aarch64 in mshv-ioctls)

Testing

  • Cross-compiled and checked for aarch64-unknown-linux-gnu locally ✅
  • No MSHV aarch64 runtime environment available yet for integration testing

@cshung cshung added the kind/enhancement For PRs adding features, improving functionality, docs, tests, etc. label Jul 7, 2026
@cshung
cshung force-pushed the cshung/mshv-aarch64 branch from b34cc5d to fb92ede Compare July 31, 2026 16:13
@cshung
cshung force-pushed the cshung/mshv-aarch64 branch from fb92ede to 3736e16 Compare August 12, 2026 14:55
@cshung
cshung force-pushed the cshung/mshv-aarch64 branch 2 times, most recently from b440e24 to 4ada969 Compare August 20, 2026 17:42
@cshung
cshung force-pushed the cshung/mshv-aarch64 branch from 4ada969 to 7f2289d Compare September 2, 2026 22:47
@cshung
cshung force-pushed the cshung/mshv-aarch64 branch from a70dcfa to 1b275f2 Compare September 29, 2026 05:30
@cshung
cshung force-pushed the cshung/mshv-aarch64 branch from 1b275f2 to 2f42d32 Compare November 2, 2026 17:10
cshung and others added 7 commits November 2, 2026 09:40
Add a full VirtualMachine trait implementation for MSHV on aarch64,
replacing the previous stub that returned false/unimplemented.

Key changes:
- mshv/aarch64.rs: Complete implementation including VM creation,
  memory mapping, vcpu run loop with MMIO-based I/O dispatch,
  general/FPU/special register access via hv_register_assoc, and
  vcpu reset support.
- hyperlight_vm/aarch64.rs: Wire up MshvVm::new() so MSHV is used
  when detected (previously returned NoHypervisorFound).
- memory_region.rs: Implement TryFrom<hv_arm64_memory_intercept_message>
  for MemoryRegionFlags using intercept_access_type field.

The implementation mirrors the KVM aarch64 backend's I/O page pattern
(MMIO writes to the I/O page GPA are interpreted as port I/O) and
follows MSHV x86_64 patterns for partition creation and register access.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Signed-off-by: cshung <3410332+cshung@users.noreply.github.com>
Configure the GIC, decode MMIO writes, preserve register state, and rebuild the partition during restore.

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

Copilot-Session: 6f20a05d-6bee-4e2e-b320-12f8d9759bbc
Signed-off-by: cshung <3410332+cshung@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 6f20a05d-6bee-4e2e-b320-12f8d9759bbc
Signed-off-by: cshung <3410332+cshung@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 6f20a05d-6bee-4e2e-b320-12f8d9759bbc
Signed-off-by: cshung <3410332+cshung@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 6f20a05d-6bee-4e2e-b320-12f8d9759bbc
Signed-off-by: cshung <3410332+cshung@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 6f20a05d-6bee-4e2e-b320-12f8d9759bbc
Signed-off-by: cshung <3410332+cshung@users.noreply.github.com>
@hyperlight-gh-bot

Copy link
Copy Markdown

Benchmark Results

Measured commit: 2f42d322fcc6
Baseline commit: fa13116cd998

kvm / amd (Linux) (➖ stable)

No benchmark improved or regressed.

Benchmark Results

function_call_codec

decode_vec_bytes_copy encode_control
373.22 µs (➖ 1.00x faster)
byte_chunks 774.35 ns (➖ 1.01x slower)
vec_bytes 581.30 ns (➖ 1.03x faster)

payload_allocation

slot_pool_segmented
65536 143.53 ns (➖ 1.01x slower)
262144 525.28 ns (➖ 1.01x faster)

sandboxes

create_initialized_and_drop
medium 13.36 ms (➖ 1.01x slower)

slot_pool

alloc_dealloc_4096 alloc_dealloc_128 alloc_dealloc_1500
7.83 ns (➖ 1.01x slower) 7.68 ns (➖ 1.03x faster) 7.68 ns (➖ 1.00x slower)

snapshot_files

load_snapshot_unverified
small 100.85 µs (➖ 1.00x slower)

virtq_readonly

slot_pool_segmented slot_pool_segmented_fragmented
65536 1.95 µs (➖ 1.06x faster) 2.03 µs (➖ 1.06x slower)
262144 7.20 µs (➖ 1.02x faster) 7.25 µs (➖ 1.00x slower)

virtq_readwrite

slot_pool_segmented slot_pool_segmented_fragmented
8192 1.08 µs (➖ 1.02x slower) 1.05 µs (➖ 1.05x faster)
65536 6.19 µs (➖ 1.04x faster) 6.27 µs (➖ 1.04x faster)
262144 26.90 µs (➖ 1.01x faster)
kvm / intel (Linux) (➖ stable)

No benchmark improved or regressed.

Benchmark Results

function_call_codec

decode_vec_bytes_copy encode_control
762.84 µs (➖ 1.01x slower)
byte_chunks 791.78 ns (➖ 1.04x faster)
vec_bytes 612.47 ns (➖ 1.01x slower)

payload_allocation

slot_pool_segmented
65536 204.75 ns (➖ 1.00x slower)
262144 594.41 ns (➖ 1.00x slower)

sandboxes

create_initialized_and_drop
medium 15.60 ms (➖ 1.00x faster)

slot_pool

alloc_dealloc_4096 alloc_dealloc_128 alloc_dealloc_1500
8.10 ns (➖ 1.01x faster) 8.13 ns (➖ 1.00x faster) 8.10 ns (➖ 1.01x faster)

snapshot_files

load_snapshot_unverified
small 56.41 µs (➖ 1.05x faster)

virtq_readonly

slot_pool_segmented slot_pool_segmented_fragmented
65536 2.54 µs (➖ 1.01x faster) 2.53 µs (➖ 1.01x faster)
262144 8.99 µs (➖ 1.00x faster) 8.97 µs (➖ 1.01x faster)

virtq_readwrite

slot_pool_segmented slot_pool_segmented_fragmented
8192 842.41 ns (➖ 1.01x slower) 853.13 ns (➖ 1.04x faster)
65536 8.37 µs (➖ 1.02x faster) 8.39 µs (➖ 1.02x faster)
262144 34.83 µs (➖ 1.00x faster)
mshv3 / amd (Linux) (➖ stable)

No benchmark improved or regressed.

Benchmark Results

function_call_codec

decode_vec_bytes_copy encode_control
314.96 µs (➖ 1.19x faster)
byte_chunks 928.72 ns (➖ 1.05x slower)
vec_bytes 667.87 ns (➖ 1.05x faster)

payload_allocation

slot_pool_segmented
65536 182.56 ns (➖ 1.00x faster)
262144 670.67 ns (➖ 1.00x faster)

sandboxes

create_initialized_and_drop
medium 63.16 ms (➖ 1.12x faster)

slot_pool

alloc_dealloc_4096 alloc_dealloc_128 alloc_dealloc_1500
9.87 ns (➖ 1.00x faster) 9.88 ns (➖ 1.00x faster) 9.89 ns (➖ 1.00x slower)

snapshot_files

load_snapshot_unverified
small 109.23 µs (➖ 1.04x faster)

virtq_readonly

slot_pool_segmented slot_pool_segmented_fragmented
65536 2.48 µs (➖ 1.00x slower) 2.63 µs (➖ 1.02x faster)
262144 9.03 µs (➖ 1.06x faster) 12.02 µs (➖ 1.28x slower)

virtq_readwrite

slot_pool_segmented slot_pool_segmented_fragmented
8192 1.32 µs (➖ 1.04x slower) 1.38 µs (➖ 1.06x slower)
65536 7.93 µs (➖ 1.02x faster) 7.98 µs (➖ 1.01x faster)
262144 34.92 µs (➖ 1.05x faster)
mshv3 / intel (Linux) (➖ stable)

No benchmark improved or regressed.

Benchmark Results

function_call_codec

decode_vec_bytes_copy encode_control
660.67 µs (➖ 1.03x slower)
byte_chunks 923.31 ns (➖ 1.02x slower)
vec_bytes 688.79 ns (➖ 1.04x slower)

payload_allocation

slot_pool_segmented
65536 260.13 ns (➖ 1.00x faster)
262144 739.38 ns (➖ 1.10x slower)

sandboxes

create_initialized_and_drop
medium 64.64 ms (➖ 1.20x faster)

slot_pool

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

snapshot_files

load_snapshot_unverified
small 53.62 µs (➖ 1.06x faster)

virtq_readonly

slot_pool_segmented slot_pool_segmented_fragmented
65536 2.25 µs (➖ 1.01x faster) 2.28 µs (➖ 1.00x slower)
262144 7.92 µs (➖ 1.00x faster) 7.89 µs (➖ 1.02x faster)

virtq_readwrite

slot_pool_segmented slot_pool_segmented_fragmented
8192 894.66 ns (➖ 1.01x faster) 903.16 ns (➖ 1.02x faster)
65536 7.43 µs (➖ 1.02x faster) 7.54 µs (➖ 1.00x faster)
262144 36.67 µs (➖ 1.05x faster)
hyperv-ws2025 / amd (Windows) (➖ stable)

No benchmark improved or regressed.

Benchmark Results

function_call_codec

decode_vec_bytes_copy encode_control
1.96 ms (➖ 1.01x slower)
byte_chunks 1.21 µs (➖ 1.01x faster)
vec_bytes 821.72 ns (➖ 1.05x slower)

payload_allocation

slot_pool_segmented
65536 270.93 ns (➖ 1.18x slower)
262144 814.11 ns (➖ 1.05x faster)

sandboxes

create_initialized_and_drop
medium 12.86 ms (➖ 1.05x slower)

slot_pool

alloc_dealloc_4096 alloc_dealloc_128 alloc_dealloc_1500
10.00 ns (➖ 1.00x slower) 10.15 ns (➖ 1.02x slower) 10.14 ns (➖ 1.01x slower)

snapshot_files

load_snapshot_unverified
small 853.51 µs (➖ 1.07x slower)

virtq_readonly

slot_pool_segmented slot_pool_segmented_fragmented
65536 2.36 µs (➖ 1.08x faster) 2.36 µs (➖ 1.00x faster)
262144 9.28 µs (➖ 1.07x faster) 9.47 µs (➖ 1.08x faster)

virtq_readwrite

slot_pool_segmented slot_pool_segmented_fragmented
8192 1.30 µs (➖ 1.02x slower) 1.30 µs (➖ 1.06x slower)
65536 8.95 µs (➖ 1.05x faster) 9.13 µs (➖ 1.03x faster)
262144 44.52 µs (➖ 1.05x slower)
hyperv-ws2025 / intel (Windows) (➖ stable)

No benchmark improved or regressed.

Benchmark Results

function_call_codec

decode_vec_bytes_copy encode_control
2.87 ms (➖ 1.03x faster)
byte_chunks 1.16 µs (➖ 1.00x faster)
vec_bytes 754.06 ns (➖ 1.01x faster)

payload_allocation

slot_pool_segmented
65536 214.16 ns (➖ 1.03x slower)
262144 743.79 ns (➖ 1.06x faster)

sandboxes

create_initialized_and_drop
medium 13.33 ms (➖ 1.07x faster)

slot_pool

alloc_dealloc_4096 alloc_dealloc_128 alloc_dealloc_1500
10.30 ns (➖ 1.01x slower) 9.70 ns (➖ 1.04x faster) 9.75 ns (➖ 1.02x faster)

snapshot_files

load_snapshot_unverified
small 607.48 µs (➖ 1.09x faster)

virtq_readonly

slot_pool_segmented slot_pool_segmented_fragmented
65536 2.63 µs (➖ 1.13x slower) 2.31 µs (➖ 1.00x slower)
262144 7.61 µs (➖ 1.00x faster) 7.70 µs (➖ 1.02x slower)

virtq_readwrite

slot_pool_segmented slot_pool_segmented_fragmented
8192 1.10 µs (➖ 1.04x slower) 1.19 µs (➖ 1.10x slower)
65536 8.97 µs (➖ 1.06x slower) 8.79 µs (➖ 1.05x slower)
262144 44.44 µs (➖ 1.10x faster)

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

kind/enhancement For PRs adding features, improving functionality, docs, tests, etc.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant