@@ -55,8 +55,11 @@ use super::{
5555} ;
5656use super :: { HyperlightExit , Hypervisor , InterruptHandle , VirtualCPU } ;
5757use crate :: hypervisor:: fpu:: FP_CONTROL_WORD_DEFAULT ;
58- use crate :: hypervisor:: get_memory_access_violation ;
58+ use crate :: hypervisor:: regs :: { CommonFpu , CommonRegisters } ;
5959use crate :: hypervisor:: wrappers:: WHvGeneralRegisters ;
60+ use crate :: hypervisor:: {
61+ InterruptHandleInternal , get_memory_access_violation, get_memory_access_violation,
62+ } ;
6063use crate :: mem:: memory_region:: { MemoryRegion , MemoryRegionFlags } ;
6164use crate :: mem:: ptr:: { GuestPtr , RawPtr } ;
6265use crate :: mem:: shared_mem:: HostSharedMemory ;
@@ -737,8 +740,12 @@ impl Hypervisor for HypervWindowsDriver {
737740
738741 #[ instrument( err( Debug ) , skip_all, parent = Span :: current( ) , level = "Trace" ) ]
739742 fn run ( & mut self ) -> Result < super :: HyperlightExit > {
743+ // Cast to internal trait for access to internal methods
744+ let interrupt_handle_internal =
745+ self . interrupt_handle . as_ref ( ) as & dyn super :: InterruptHandleInternal ;
746+
740747 // Get current generation and set running bit
741- let generation = self . interrupt_handle . set_running_bit ( ) ;
748+ let generation = interrupt_handle_internal . set_running_bit ( ) ;
742749
743750 #[ cfg( not( gdb) ) ]
744751 let debug_interrupt = false ;
@@ -749,8 +756,7 @@ impl Hypervisor for HypervWindowsDriver {
749756 . load ( Ordering :: Relaxed ) ;
750757
751758 // Check if cancellation was requested for THIS generation
752- let exit_context = if self
753- . interrupt_handle
759+ let exit_context = if interrupt_handle_internal
754760 . is_cancel_requested_for_generation ( generation)
755761 || debug_interrupt
756762 {
@@ -773,18 +779,17 @@ impl Hypervisor for HypervWindowsDriver {
773779 } ;
774780
775781 // Clear running bit
776- self . interrupt_handle . clear_running_bit ( ) ;
782+ interrupt_handle_internal . clear_running_bit ( ) ;
777783
778784 let is_canceled = exit_context. ExitReason == WHV_RUN_VP_EXIT_REASON ( 8193i32 ) ; // WHvRunVpExitReasonCanceled
779785
780786 // Check if this was a manual cancellation (vs internal Windows cancellation)
781- let cancel_was_requested_manually = self
782- . interrupt_handle
783- . is_cancel_requested_for_generation ( generation) ;
787+ let cancel_was_requested_manually =
788+ interrupt_handle_internal. is_cancel_requested_for_generation ( generation) ;
784789
785790 // Only clear cancel_requested if we're actually processing a cancellation for this generation
786791 if is_canceled && cancel_was_requested_manually {
787- self . interrupt_handle . clear_cancel_requested ( ) ;
792+ interrupt_handle_internal . clear_cancel_requested ( ) ;
788793 }
789794
790795 #[ cfg( gdb) ]
@@ -915,7 +920,36 @@ impl Hypervisor for HypervWindowsDriver {
915920 Ok ( result)
916921 }
917922
918- fn interrupt_handle ( & self ) -> Arc < dyn InterruptHandle > {
923+ /// Get regs
924+ #[ allow( dead_code) ]
925+ fn regs ( & self ) -> Result < CommonRegisters > {
926+ self . processor . regs ( )
927+ }
928+ /// Set regs
929+ fn set_regs ( & mut self , regs : & CommonRegisters ) -> Result < ( ) > {
930+ self . processor . set_regs ( regs)
931+ }
932+ /// Get fpu regs
933+ #[ allow( dead_code) ]
934+ fn fpu ( & self ) -> Result < CommonFpu > {
935+ self . processor . fpu ( )
936+ }
937+ /// Set fpu regs
938+ fn set_fpu ( & mut self , fpu : & CommonFpu ) -> Result < ( ) > {
939+ self . processor . set_fpu ( fpu)
940+ }
941+ /// Get special regs
942+ #[ allow( dead_code) ]
943+ fn sregs ( & self ) -> Result < CommonSpecialRegisters > {
944+ self . processor . sregs ( )
945+ }
946+ /// Set special regs
947+ #[ allow( dead_code) ]
948+ fn set_sregs ( & mut self , sregs : & CommonSpecialRegisters ) -> Result < ( ) > {
949+ self . processor . set_sregs ( sregs)
950+ }
951+
952+ fn interrupt_handle ( & self ) -> Arc < dyn super :: InterruptHandleInternal > {
919953 self . interrupt_handle . clone ( )
920954 }
921955
@@ -1204,19 +1238,22 @@ impl InterruptHandle for WindowsInterruptHandle {
12041238 // Only call WHvCancelRunVirtualProcessor if VCPU is actually running in guest mode
12051239 running && unsafe { WHvCancelRunVirtualProcessor ( self . partition_handle , 0 , 0 ) . is_ok ( ) }
12061240 }
1241+
12071242 #[ cfg( gdb) ]
12081243 fn kill_from_debugger ( & self ) -> bool {
12091244 self . debug_interrupt . store ( true , Ordering :: Relaxed ) ;
12101245 let ( running, _) = self . get_running_and_generation ( ) ;
12111246 running && unsafe { WHvCancelRunVirtualProcessor ( self . partition_handle , 0 , 0 ) . is_ok ( ) }
12121247 }
12131248
1214- fn get_call_active ( & self ) -> & AtomicBool {
1215- & self . call_active
1249+ fn dropped ( & self ) -> bool {
1250+ self . dropped . load ( Ordering :: Relaxed )
12161251 }
1252+ }
12171253
1218- fn get_dropped ( & self ) -> & AtomicBool {
1219- & self . dropped
1254+ impl InterruptHandleInternal for WindowsInterruptHandle {
1255+ fn get_call_active ( & self ) -> & AtomicBool {
1256+ & self . call_active
12201257 }
12211258
12221259 fn get_running ( & self ) -> & AtomicU64 {
0 commit comments