feat: enable guest compilation for aarch64#1297
feat: enable guest compilation for aarch64#1297ludfjig wants to merge 4 commits intohyperlight-dev:mainfrom
Conversation
There was a problem hiding this comment.
Pull request overview
Enable building the guest runtime for aarch64 by moving x86_64-specific code behind architecture gates and adding aarch64 stub modules.
Changes:
- Added aarch64 arch module selection and stub implementations (
unimplemented!()) to allow compilation. - Moved
out32into an architecture-specific module and gated x86_64-only modules/features. - Updated
build.rsto skip C/musl compilation on non-x86_64 targets.
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| src/hyperlight_guest_tracing/src/lib.rs | Gate invariant TSC module to x86_64 only. |
| src/hyperlight_guest_bin/src/lib.rs | Select aarch64 arch module; gate x86_64-only modules and mem profiling paths. |
| src/hyperlight_guest_bin/src/arch/aarch64/mod.rs | Add aarch64 guest entrypoint/dispatch stubs. |
| src/hyperlight_guest_bin/build.rs | Skip C/musl build and header copying on non-x86_64 targets. |
| src/hyperlight_guest/src/prim_alloc.rs | Add aarch64 arch file selection for primitive allocator. |
| src/hyperlight_guest/src/layout.rs | Add aarch64 arch file selection for layout constants/functions. |
| src/hyperlight_guest/src/exit.rs | Extract out32 into arch modules; add aarch64 exit stub. |
| src/hyperlight_guest/src/arch/amd64/exit.rs | New x86_64 implementation of out32 (moved from exit.rs). |
| src/hyperlight_guest/src/arch/aarch64/prim_alloc.rs | Add aarch64 allocator stub. |
| src/hyperlight_guest/src/arch/aarch64/layout.rs | Add aarch64 layout placeholders + unimplemented scratch helpers. |
| src/hyperlight_guest/src/arch/aarch64/exit.rs | Add aarch64 out32 stub. |
| use hyperlight_common::outb::OutBAction; | ||
|
|
||
| #[cfg_attr(target_arch = "x86_64", path = "arch/amd64/exit.rs")] | ||
| #[cfg_attr(target_arch = "x86", path = "arch/amd64/exit.rs")] |
There was a problem hiding this comment.
The target_arch = \"x86\" path points to arch/amd64/exit.rs, but that implementation uses x86_64-only registers in inline asm (e.g., r8/r9/r10). This will fail to compile for 32-bit x86. Point target_arch = \"x86\" to an i686-specific implementation (e.g., arch/i686/exit.rs) or gate/remove the x86 mapping if 32-bit x86 isn’t supported.
| #[cfg_attr(target_arch = "x86", path = "arch/amd64/exit.rs")] |
There was a problem hiding this comment.
Is this necessary? I don't think so, right?
Extract the out32 VM exit function from exit.rs into arch/amd64/exit.rs. exit.rs now delegates to the arch module via cfg_attr, keeping arch-independent code (outb, abort, debug_print) in the shared file. Signed-off-by: Ludvig Liljenberg <4257730+ludfjig@users.noreply.github.com>
The invariant_tsc module uses core::arch::x86_64 intrinsics (CPUID, RDTSC) which are not available on other architectures. Signed-off-by: Ludvig Liljenberg <4257730+ludfjig@users.noreply.github.com>
- Gate paging and exception modules on target_arch = x86_64 - Gate ProfiledLockedHeap (uses x86 out asm) on x86_64 - Skip musl/printf C compilation in build.rs on non-x86_64 Signed-off-by: Ludvig Liljenberg <4257730+ludfjig@users.noreply.github.com>
Add aarch64 arch modules with unimplemented!() stubs: - hyperlight-guest: layout, prim_alloc, exit modules - hyperlight-guest-bin: dispatch and entrypoint stubs Update cfg_attr paths in layout.rs and prim_alloc.rs to include aarch64. All stubs panic at runtime — no aarch64 guest functionality is implemented yet. Signed-off-by: Ludvig Liljenberg <4257730+ludfjig@users.noreply.github.com>
| use hyperlight_common::outb::OutBAction; | ||
|
|
||
| #[cfg_attr(target_arch = "x86_64", path = "arch/amd64/exit.rs")] | ||
| #[cfg_attr(target_arch = "x86", path = "arch/amd64/exit.rs")] |
There was a problem hiding this comment.
Is this necessary? I don't think so, right?
Enable guest compilation for aarch64: