Skip to content

feat: enable hyperlight-host cross-compilation for aarch64#1285

Draft
ludfjig wants to merge 1 commit intomainfrom
aarch64
Draft

feat: enable hyperlight-host cross-compilation for aarch64#1285
ludfjig wants to merge 1 commit intomainfrom
aarch64

Conversation

@ludfjig
Copy link
Contributor

@ludfjig ludfjig commented Mar 6, 2026

Add conditional compilation gates and aarch64 stub modules so that cargo build --target aarch64-unknown-linux-gnu -p hyperlight-host succeeds. No aarch64 implementation is added. All aarch64 code paths are stubs that panic at runtime.

There will be some code duplication addition for aarch64 initially, espeically regarding HyperlihtVm and KvmVm and MshvVm. It will make sense to factor some of this out when we figure out more what the code looks like with aarch64 support added

@ludfjig ludfjig marked this pull request as draft March 6, 2026 22:28
@ludfjig ludfjig added the kind/refactor For PRs that restructure or remove code without adding new functionality. label Mar 6, 2026
Add conditional compilation gates and aarch64 stub modules so that
cargo build --target aarch64-unknown-linux-gnu -p hyperlight-host
succeeds. No aarch64 implementation is added. All aarch64 code paths
are stubs that panic at runtime.

Signed-off-by: Ludvig Liljenberg <4257730+ludfjig@users.noreply.github.com>
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Enable hyperlight-host to cross-compile for aarch64-unknown-linux-gnu by adding arch-specific module gating and aarch64 stub implementations, without changing x86_64 behavior.

Changes:

  • Added aarch64 stub modules for KVM/MSHV and Hyperlight VM plumbing behind cfg(target_arch).
  • Split register and VM backend modules into arch-specific submodules with conditional re-exports.
  • Updated build configuration and dependencies to gate x86_64-only functionality (gdb/crashdump) and unblock aarch64 builds.

Reviewed changes

Copilot reviewed 19 out of 25 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
src/hyperlight_host/src/mem/memory_region.rs Adds arch-gated MSHV imports and aarch64 stub TryFrom for intercept messages.
src/hyperlight_host/src/hypervisor/virtual_machine/mshv/mod.rs Introduces arch-split MSHV module selection via cfg(target_arch).
src/hyperlight_host/src/hypervisor/virtual_machine/mshv/aarch64.rs Adds aarch64 MSHV stub VM implementation.
src/hyperlight_host/src/hypervisor/virtual_machine/mod.rs Relaxes “no hypervisor” compile error for aarch64; adjusts VmExit::Debug fields for arch gating.
src/hyperlight_host/src/hypervisor/virtual_machine/kvm/mod.rs Introduces arch-split KVM module selection via cfg(target_arch).
src/hyperlight_host/src/hypervisor/virtual_machine/kvm/aarch64.rs Adds aarch64 KVM stub VM implementation.
src/hyperlight_host/src/hypervisor/regs/x86_64/mod.rs Moves x86_64 register modules under an arch-specific namespace.
src/hyperlight_host/src/hypervisor/regs/aarch64/mod.rs Adds placeholder aarch64 register type stubs.
src/hyperlight_host/src/hypervisor/regs.rs Switches to arch-gated register module re-exports.
src/hyperlight_host/src/hypervisor/hyperlight_vm/mod.rs Extracts arch-independent HyperlightVm logic into a shared module.
src/hyperlight_host/src/hypervisor/hyperlight_vm/aarch64.rs Adds aarch64 HyperlightVm method stubs to satisfy compilation.
src/hyperlight_host/src/hypervisor/hyperlight_vm.rs Refactors existing HyperlightVm implementation to rely on shared module pieces and visibility changes.
src/hyperlight_host/build.rs Gates gdb and crashdump cfg aliases to x86_64.
src/hyperlight_host/Cargo.toml Makes elfcore optional and ties it to the crashdump feature.
src/hyperlight_common/src/vmem.rs Adds cfg_attr mapping for aarch64 vmem implementation file.
src/hyperlight_common/src/layout.rs Adds cfg_attr mapping for aarch64 layout implementation file.
src/hyperlight_common/src/arch/aarch64/vmem.rs Adds aarch64 vmem stub module with placeholder APIs.
src/hyperlight_common/src/arch/aarch64/layout.rs Adds aarch64 layout stub module with placeholder APIs.
docs/aarch64-architecture-plan.md Documents the phased approach and desired patterns for aarch64 support.

Comment on lines +586 to +604
Ok(VmExit::MmioRead(addr)) => {
let all_regions = self.get_mapped_regions();
match get_memory_access_violation(
addr as usize,
MemoryRegionFlags::WRITE,
all_regions,
) {
Some(MemoryAccess::AccessViolation(region_flags)) => {
break Err(RunVmError::MemoryAccessViolation {
addr,
access_type: MemoryRegionFlags::READ,
region_flags,
});
}
None => {
break Err(RunVmError::MmioReadUnmapped(addr));
}
}
}
Copy link

Copilot AI Mar 7, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The MMIO read path checks permissions using MemoryRegionFlags::WRITE, which will misclassify missing READ permissions (and can incorrectly report violations based on write permission). Pass MemoryRegionFlags::READ as the tried flag for VmExit::MmioRead.

Copilot uses AI. Check for mistakes.
}

/// Get the currently mapped dynamic memory regions (not including initial sandbox region)
pub(crate) fn get_mapped_regions(&self) -> impl Iterator<Item = &MemoryRegion> + Clone {
Copy link

Copilot AI Mar 7, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Requiring the returned iterator to be Clone is an extra API constraint that may make future refactors harder (e.g., if the implementation changes to an iterator that isn’t trivially cloneable). If cloning isn’t required by callers, consider dropping the + Clone bound.

Suggested change
pub(crate) fn get_mapped_regions(&self) -> impl Iterator<Item = &MemoryRegion> + Clone {
pub(crate) fn get_mapped_regions(&self) -> impl Iterator<Item = &MemoryRegion> {

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/refactor For PRs that restructure or remove code without adding new functionality.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants