-
Notifications
You must be signed in to change notification settings - Fork 162
feat: enable guest compilation for aarch64 #1297
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
ludfjig
wants to merge
4
commits into
hyperlight-dev:main
Choose a base branch
from
ludfjig:aarch64_guest
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
eb3ada4
refactor: move out32 into arch-specific exit module
ludfjig cd1e034
refactor: gate invariant_tsc module on x86_64
ludfjig f67b03a
refactor: gate x86_64-specific code in hyperlight-guest-bin
ludfjig 9420c72
feat: add aarch64 arch stubs for guest crates
ludfjig File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| /* | ||
| Copyright 2025 The Hyperlight Authors. | ||
|
|
||
| Licensed under the Apache License, Version 2.0 (the "License"); | ||
| you may not use this file except in compliance with the License. | ||
| You may obtain a copy of the License at | ||
|
|
||
| http://www.apache.org/licenses/LICENSE-2.0 | ||
|
|
||
| Unless required by applicable law or agreed to in writing, software | ||
| distributed under the License is distributed on an "AS IS" BASIS, | ||
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| See the License for the specific language governing permissions and | ||
| limitations under the License. | ||
| */ | ||
|
|
||
| // TODO(aarch64): implement VM exit mechanism (e.g. hvc instruction) | ||
|
|
||
| /// Trigger a VM exit sending a 32-bit value to the host on the given port. | ||
| pub(crate) unsafe fn out32(_port: u16, _val: u32) { | ||
| unimplemented!("aarch64 out32") | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| /* | ||
| Copyright 2025 The Hyperlight Authors. | ||
|
|
||
| Licensed under the Apache License, Version 2.0 (the "License"); | ||
| you may not use this file except in compliance with the License. | ||
| You may obtain a copy of the License at | ||
|
|
||
| http://www.apache.org/licenses/LICENSE-2.0 | ||
|
|
||
| Unless required by applicable law or agreed to in writing, software | ||
| distributed under the License is distributed on an "AS IS" BASIS, | ||
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| See the License for the specific language governing permissions and | ||
| limitations under the License. | ||
| */ | ||
|
|
||
| // TODO(aarch64): these values are placeholders copied from amd64 | ||
| pub const MAIN_STACK_TOP_GVA: u64 = 0xffff_ff00_0000_0000; | ||
| pub const MAIN_STACK_LIMIT_GVA: u64 = 0xffff_fe00_0000_0000; | ||
|
|
||
| pub fn scratch_size() -> u64 { | ||
| unimplemented!("aarch64 scratch_size") | ||
| } | ||
|
|
||
| pub fn scratch_base_gpa() -> u64 { | ||
| unimplemented!("aarch64 scratch_base_gpa") | ||
| } | ||
|
|
||
| pub fn scratch_base_gva() -> u64 { | ||
| unimplemented!("aarch64 scratch_base_gva") | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| /* | ||
| Copyright 2025 The Hyperlight Authors. | ||
|
|
||
| Licensed under the Apache License, Version 2.0 (the "License"); | ||
| you may not use this file except in compliance with the License. | ||
| You may obtain a copy of the License at | ||
|
|
||
| http://www.apache.org/licenses/LICENSE-2.0 | ||
|
|
||
| Unless required by applicable law or agreed to in writing, software | ||
| distributed under the License is distributed on an "AS IS" BASIS, | ||
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| See the License for the specific language governing permissions and | ||
| limitations under the License. | ||
| */ | ||
|
|
||
| // TODO(aarch64): implement real aarch64 page allocator | ||
|
|
||
| // There are no notable architecture-specific safety considerations | ||
| // here, and the general conditions are documented in the | ||
| // architecture-independent re-export in prim_alloc.rs | ||
| #[allow(clippy::missing_safety_doc)] | ||
| pub unsafe fn alloc_phys_pages(_n: u64) -> u64 { | ||
| unimplemented!("aarch64 alloc_phys_pages") | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,60 @@ | ||
| /* | ||
| Copyright 2025 The Hyperlight Authors. | ||
|
|
||
| Licensed under the Apache License, Version 2.0 (the "License"); | ||
| you may not use this file except in compliance with the License. | ||
| You may obtain a copy of the License at | ||
|
|
||
| http://www.apache.org/licenses/LICENSE-2.0 | ||
|
|
||
| Unless required by applicable law or agreed to in writing, software | ||
| distributed under the License is distributed on an "AS IS" BASIS, | ||
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| See the License for the specific language governing permissions and | ||
| limitations under the License. | ||
| */ | ||
|
|
||
| use core::arch::asm; | ||
|
|
||
| #[cfg(feature = "trace_guest")] | ||
| use hyperlight_common::outb::OutBAction; | ||
|
|
||
| /// OUT function for sending a 32-bit value to the host. | ||
| /// `out32` can be called from an exception context, so we must be careful | ||
| /// with the tracing state that might be locked at that time. | ||
| /// The tracing state calls `try_lock` internally to avoid deadlocks. | ||
| /// Furthermore, the instrument macro is not used here to avoid creating spans | ||
| /// in exception contexts. Because if the trace state is already locked, trying to create a span | ||
| /// would cause a panic, which is undesirable in exception handling. | ||
| pub(crate) unsafe fn out32(port: u16, val: u32) { | ||
| #[cfg(feature = "trace_guest")] | ||
| { | ||
| if let Some((ptr, len)) = hyperlight_guest_tracing::serialized_data() { | ||
| // If tracing is enabled and there is data to send, send it along with the OUT action | ||
| unsafe { | ||
| asm!("out dx, eax", | ||
| in("dx") port, | ||
| in("eax") val, | ||
| in("r8") OutBAction::TraceBatch as u64, | ||
| in("r9") ptr, | ||
| in("r10") len, | ||
| options(preserves_flags, nomem, nostack) | ||
| ) | ||
| }; | ||
|
|
||
| // Reset the trace state after sending the batch | ||
| // This clears all existing spans/events ensuring a clean state for the next operations | ||
| // The trace state is expected to be flushed before this call | ||
| hyperlight_guest_tracing::reset(); | ||
| } else { | ||
| // If tracing is not enabled, just send the value | ||
| unsafe { | ||
| asm!("out dx, eax", in("dx") port, in("eax") val, options(preserves_flags, nomem, nostack)) | ||
| }; | ||
| } | ||
| } | ||
| #[cfg(not(feature = "trace_guest"))] | ||
| unsafe { | ||
| asm!("out dx, eax", in("dx") port, in("eax") val, options(preserves_flags, nomem, nostack)); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.