Skip to content

Commit 5f992dc

Browse files
cshungCopilot
andcommitted
fix(aarch64): make WHP backend operational
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Signed-off-by: cshung <3410332+cshung@users.noreply.github.com>
1 parent c771624 commit 5f992dc

7 files changed

Lines changed: 234 additions & 108 deletions

File tree

src/hyperlight_host/src/hypervisor/hyperlight_vm/aarch64.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ impl HyperlightVm {
236236
self.vm_can_reset_vcpu,
237237
"No fallback path for vcpu reset on aarch64"
238238
);
239-
self.vm.reset_vcpu()?;
239+
self.interrupt_handle.reset_vcpu(self.vm.as_mut())?;
240240
self.apply_sregs(cr3, sregs)?;
241241
Ok(())
242242
}

src/hyperlight_host/src/hypervisor/mod.rs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ use std::sync::atomic::{AtomicU8, Ordering};
4646
#[cfg(any(kvm, mshv3))]
4747
use std::time::Duration;
4848

49+
use self::virtual_machine::{ResetVcpuError, VirtualMachine};
50+
4951
/// A trait for platform-specific interrupt handle implementation details
5052
pub(crate) trait InterruptHandleImpl: InterruptHandle {
5153
/// Set the thread ID for the vcpu thread
@@ -67,6 +69,11 @@ pub(crate) trait InterruptHandleImpl: InterruptHandle {
6769
/// Clear the cancellation request flag
6870
fn clear_cancel(&self);
6971

72+
/// Reset the vCPU while honoring platform lifecycle synchronization.
73+
fn reset_vcpu(&self, vm: &mut dyn VirtualMachine) -> Result<(), ResetVcpuError> {
74+
vm.reset_vcpu()
75+
}
76+
7077
/// Check if debug interrupt was requested (always returns false when gdb feature is disabled)
7178
fn is_debug_interrupted(&self) -> bool;
7279

@@ -347,6 +354,19 @@ impl InterruptHandleImpl for WindowsInterruptHandle {
347354
self.state.fetch_and(!Self::RUNNING_BIT, Ordering::Release);
348355
}
349356

357+
fn reset_vcpu(&self, vm: &mut dyn VirtualMachine) -> Result<(), ResetVcpuError> {
358+
let guard = self
359+
.partition_state
360+
.write()
361+
.map_err(|e| ResetVcpuError::Unknown(e.to_string()))?;
362+
if guard.dropped {
363+
return Err(ResetVcpuError::Unknown(
364+
"cannot reset a dropped partition".to_string(),
365+
));
366+
}
367+
vm.reset_vcpu()
368+
}
369+
350370
fn is_debug_interrupted(&self) -> bool {
351371
#[cfg(gdb)]
352372
{

src/hyperlight_host/src/hypervisor/regs.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,13 @@ pub(crate) use x86_64::*;
2121

2222
#[cfg(target_arch = "aarch64")]
2323
mod aarch64;
24-
#[cfg(target_os = "windows")]
24+
#[cfg(all(target_arch = "x86_64", target_os = "windows"))]
2525
use std::collections::HashSet;
2626

2727
#[cfg(target_arch = "aarch64")]
2828
pub(crate) use aarch64::*;
2929

30-
#[cfg(target_os = "windows")]
30+
#[cfg(all(target_arch = "x86_64", target_os = "windows"))]
3131
#[derive(Debug, PartialEq)]
3232
pub(crate) enum FromWhpRegisterError {
3333
MissingRegister(HashSet<i32>),

0 commit comments

Comments
 (0)