@@ -35,10 +35,16 @@ use crate::hypervisor::regs::{CommonFpu, CommonRegisters, CommonSpecialRegisters
3535use crate :: hypervisor:: virtual_machine:: hvf:: HvfVm ;
3636#[ cfg( kvm) ]
3737use crate :: hypervisor:: virtual_machine:: kvm:: KvmVm ;
38+ #[ cfg( target_os = "windows" ) ]
39+ use crate :: hypervisor:: virtual_machine:: whp:: WhpVm ;
3840use crate :: hypervisor:: virtual_machine:: {
3941 HypervisorType , RegisterError , ResetVcpuError , VirtualMachine , VmError ,
4042 get_available_hypervisor,
4143} ;
44+ #[ cfg( target_os = "linux" ) ]
45+ use crate :: hypervisor:: LinuxInterruptHandle ;
46+ #[ cfg( target_os = "windows" ) ]
47+ use crate :: hypervisor:: WindowsInterruptHandle ;
4248use crate :: mem:: mgr:: { SandboxMemoryManager , SnapshotSharedMemory } ;
4349use crate :: mem:: shared_mem:: { GuestSharedMemory , HostSharedMemory } ;
4450use crate :: sandbox:: SandboxConfiguration ;
@@ -59,7 +65,7 @@ impl HyperlightVm {
5965 next_action : NextAction ,
6066 rsp_gva : u64 ,
6167 page_size : usize ,
62- config : & SandboxConfiguration ,
68+ # [ cfg_attr ( target_os = "windows" , allow ( unused_variables ) ) ] config : & SandboxConfiguration ,
6369 #[ cfg( gdb) ] _gdb_conn : Option < DebugCommChannel < DebugResponse , DebugMsg > > ,
6470 #[ cfg( crashdump) ] _rt_cfg : SandboxRuntimeConfig ,
6571 #[ cfg( feature = "mem_profile" ) ] _trace_info : MemTraceInfo ,
@@ -72,13 +78,14 @@ impl HyperlightVm {
7278 let mut vm: VmType = match get_available_hypervisor ( ) {
7379 #[ cfg( kvm) ]
7480 Some ( HypervisorType :: Kvm ) => Box :: new ( KvmVm :: new ( ) . map_err ( VmError :: CreateVm ) ?) ,
75- // TODO: mshv support
7681 #[ cfg( mshv3) ]
7782 Some ( HypervisorType :: Mshv ) => return Err ( CreateHyperlightVmError :: NoHypervisorFound ) ,
7883 #[ cfg( hvf) ]
7984 Some ( HypervisorType :: Hvf ) => {
8085 Box :: new ( HvfVm :: new ( interrupt_handle. clone ( ) ) . map_err ( VmError :: CreateVm ) ?)
8186 }
87+ #[ cfg( target_os = "windows" ) ]
88+ Some ( HypervisorType :: Whp ) => Box :: new ( WhpVm :: new ( ) . map_err ( VmError :: CreateVm ) ?) ,
8289 None => return Err ( CreateHyperlightVmError :: NoHypervisorFound ) ,
8390 } ;
8491 vm. set_sregs ( & CommonSpecialRegisters :: defaults ( root_pt_addr) )
@@ -87,6 +94,10 @@ impl HyperlightVm {
8794 let interrupt_handle: Arc < dyn InterruptHandleImpl > =
8895 Arc :: new ( LinuxInterruptHandle :: new ( config) ) ;
8996
97+ #[ cfg( target_os = "windows" ) ]
98+ let interrupt_handle: Arc < dyn InterruptHandleImpl > =
99+ Arc :: new ( WindowsInterruptHandle :: new ( vm. partition_handle ( ) ) ) ;
100+
90101 let snapshot_slot = 0u32 ;
91102 let scratch_slot = 1u32 ;
92103 let vm_can_reset_vcpu = vm. can_reset_vcpu ( ) ;
@@ -206,7 +217,7 @@ impl HyperlightVm {
206217 self . vm_can_reset_vcpu,
207218 "No fallback path for vcpu reset on aarch64"
208219 ) ;
209- self . vm . reset_vcpu ( ) ?;
220+ self . interrupt_handle . reset_vcpu ( self . vm . as_mut ( ) ) ?;
210221 self . apply_sregs ( cr3, sregs) ?;
211222 Ok ( ( ) )
212223 }
0 commit comments