Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
258 changes: 258 additions & 0 deletions docs/aarch64-architecture-plan.md

Large diffs are not rendered by default.

25 changes: 25 additions & 0 deletions src/hyperlight_common/src/arch/aarch64/layout.rs
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): change these, they are only provided in order to compile
pub const MAX_GVA: usize = 0xffff_ffff_ffff_efff;
pub const SNAPSHOT_PT_GVA_MIN: usize = 0xffff_8000_0000_0000;
pub const SNAPSHOT_PT_GVA_MAX: usize = 0xffff_80ff_ffff_ffff;
pub const MAX_GPA: usize = 0x0000_000f_ffff_ffff;

pub fn min_scratch_size(_input_data_size: usize, _output_data_size: usize) -> usize {
unimplemented!("min_scratch_size")
}
52 changes: 52 additions & 0 deletions src/hyperlight_common/src/arch/aarch64/vmem.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/*
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 page table operations

use crate::vmem::{Mapping, TableOps, TableReadOps, Void};

pub const PAGE_SIZE: usize = 4096;
pub const PAGE_TABLE_SIZE: usize = 4096;
pub type PageTableEntry = u64;
pub type VirtAddr = u64;
pub type PhysAddr = u64;

/// # Safety
/// See `TableOps` documentation.
#[allow(clippy::missing_safety_doc)]
pub unsafe fn map<Op: TableOps>(_op: &Op, _mapping: Mapping) {
unimplemented!("map")
}

/// # Safety
/// See `TableReadOps` documentation.
#[allow(clippy::missing_safety_doc)]
pub unsafe fn virt_to_phys<'a, Op: TableReadOps + 'a>(
_op: impl core::convert::AsRef<Op> + Copy + 'a,
_address: u64,
_len: u64,
) -> impl Iterator<Item = Mapping> + 'a {
unimplemented!("virt_to_phys");
#[allow(unreachable_code)]
core::iter::empty()
}

pub trait TableMovability<Op: TableReadOps + ?Sized, TableMoveInfo> {}
impl<Op: TableOps<TableMovability = crate::vmem::MayMoveTable>> TableMovability<Op, Op::TableAddr>
for crate::vmem::MayMoveTable
{
}
impl<Op: TableReadOps> TableMovability<Op, Void> for crate::vmem::MayNotMoveTable {}
1 change: 1 addition & 0 deletions src/hyperlight_common/src/layout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ limitations under the License.

#[cfg_attr(target_arch = "x86_64", path = "arch/amd64/layout.rs")]
#[cfg_attr(target_arch = "x86", path = "arch/i686/layout.rs")]
#[cfg_attr(target_arch = "aarch64", path = "arch/aarch64/layout.rs")]
mod arch;

pub use arch::{MAX_GPA, MAX_GVA, SNAPSHOT_PT_GVA_MAX, SNAPSHOT_PT_GVA_MIN};
Expand Down
1 change: 1 addition & 0 deletions src/hyperlight_common/src/vmem.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ limitations under the License.

#[cfg_attr(target_arch = "x86_64", path = "arch/amd64/vmem.rs")]
#[cfg_attr(target_arch = "x86", path = "arch/i686/vmem.rs")]
#[cfg_attr(target_arch = "aarch64", path = "arch/aarch64/vmem.rs")]
mod arch;

/// This is always the page size that the /guest/ is being compiled
Expand Down
4 changes: 2 additions & 2 deletions src/hyperlight_host/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ chrono = { version = "0.4", optional = true }
anyhow = "1.0"
metrics = "0.24.3"
serde_json = "1.0"
elfcore = "2.0"
elfcore = { version = "2.0", optional = true }
uuid = { version = "1.22.0", features = ["v4"] }

[target.'cfg(windows)'.dependencies]
Expand Down Expand Up @@ -128,7 +128,7 @@ executable_heap = []
# This feature enables printing of debug information to stdout in debug builds
print_debug = []
# Dumps the VM state to a file on unexpected errors or crashes. The path of the file will be printed on stdout and logged.
crashdump = ["dep:chrono"]
crashdump = ["dep:chrono", "dep:elfcore"]
trace_guest = ["dep:opentelemetry", "dep:tracing-opentelemetry", "dep:hyperlight-guest-tracing", "hyperlight-common/trace_guest"]
mem_profile = [ "trace_guest", "dep:framehop", "dep:fallible-iterator", "hyperlight-common/mem_profile" ]
kvm = ["dep:kvm-bindings", "dep:kvm-ioctls"]
Expand Down
4 changes: 2 additions & 2 deletions src/hyperlight_host/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,10 +99,10 @@ fn main() -> Result<()> {
// Essentially the kvm and mshv3 features are ignored on windows as long as you use #[cfg(kvm)] and not #[cfg(feature = "kvm")].
// You should never use #[cfg(feature = "kvm")] or #[cfg(feature = "mshv3")] in the codebase.
cfg_aliases::cfg_aliases! {
gdb: { all(feature = "gdb", debug_assertions) },
gdb: { all(feature = "gdb", debug_assertions, target_arch = "x86_64") },
kvm: { all(feature = "kvm", target_os = "linux") },
mshv3: { all(feature = "mshv3", target_os = "linux") },
crashdump: { all(feature = "crashdump") },
crashdump: { all(feature = "crashdump", target_arch = "x86_64") },
// print_debug feature is aliased with debug_assertions to make it only available in debug-builds.
print_debug: { all(feature = "print_debug", debug_assertions) },
}
Expand Down
99 changes: 99 additions & 0 deletions src/hyperlight_host/src/hypervisor/hyperlight_vm/aarch64.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
/*
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 arch-specific HyperlightVm methods

use std::sync::Arc;

use super::{
AccessPageTableError, CreateHyperlightVmError, DispatchGuestCallError, HyperlightVm,
InitializeError,
};
#[cfg(gdb)]
use crate::hypervisor::gdb::{DebugCommChannel, DebugMsg, DebugResponse};
use crate::hypervisor::regs::CommonSpecialRegisters;
use crate::hypervisor::virtual_machine::RegisterError;
use crate::mem::mgr::SandboxMemoryManager;
use crate::mem::shared_mem::{GuestSharedMemory, HostSharedMemory};
use crate::sandbox::SandboxConfiguration;
use crate::sandbox::host_funcs::FunctionRegistry;
use crate::sandbox::snapshot::NextAction;
#[cfg(feature = "mem_profile")]
use crate::sandbox::trace::MemTraceInfo;
#[cfg(crashdump)]
use crate::sandbox::uninitialized::SandboxRuntimeConfig;

impl HyperlightVm {
#[allow(clippy::too_many_arguments)]
pub(crate) fn new(
_snapshot_mem: GuestSharedMemory,
_scratch_mem: GuestSharedMemory,
_pml4_addr: u64,
_entrypoint: NextAction,
_rsp_gva: u64,
_config: &SandboxConfiguration,
#[cfg(gdb)] _gdb_conn: Option<DebugCommChannel<DebugResponse, DebugMsg>>,
#[cfg(crashdump)] _rt_cfg: SandboxRuntimeConfig,
#[cfg(feature = "mem_profile")] _trace_info: MemTraceInfo,
) -> std::result::Result<Self, CreateHyperlightVmError> {
unimplemented!("new")
}

#[allow(clippy::too_many_arguments)]
pub(crate) fn initialise(
&mut self,
_peb_addr: crate::mem::ptr::RawPtr,
_seed: u64,
_page_size: u32,
_mem_mgr: &mut SandboxMemoryManager<HostSharedMemory>,
_host_funcs: &Arc<std::sync::Mutex<FunctionRegistry>>,
_guest_max_log_level: Option<tracing_core::LevelFilter>,
#[cfg(gdb)] _dbg_mem_access_fn: Arc<
std::sync::Mutex<SandboxMemoryManager<HostSharedMemory>>,
>,
) -> Result<(), InitializeError> {
unimplemented!("initialise")
}

pub(crate) fn dispatch_call_from_host(
&mut self,
_mem_mgr: &mut SandboxMemoryManager<HostSharedMemory>,
_host_funcs: &Arc<std::sync::Mutex<FunctionRegistry>>,
#[cfg(gdb)] _dbg_mem_access_fn: Arc<
std::sync::Mutex<SandboxMemoryManager<HostSharedMemory>>,
>,
) -> Result<(), DispatchGuestCallError> {
unimplemented!("dispatch_call_from_host")
}

pub(crate) fn get_root_pt(&self) -> Result<u64, AccessPageTableError> {
unimplemented!("get_root_pt")
}

pub(crate) fn get_snapshot_sregs(
&mut self,
) -> Result<CommonSpecialRegisters, AccessPageTableError> {
unimplemented!("get_snapshot_sregs")
}

pub(crate) fn reset_vcpu(
&mut self,
_cr3: u64,
_sregs: &CommonSpecialRegisters,
) -> std::result::Result<(), RegisterError> {
unimplemented!("reset_vcpu")
}
}
Loading