@@ -54,9 +54,8 @@ use super::{
5454 EFER_LMA , EFER_LME , EFER_NX , EFER_SCE ,
5555} ;
5656use super :: { HyperlightExit , Hypervisor , InterruptHandle , VirtualCPU } ;
57- use crate :: hypervisor:: fpu:: FP_CONTROL_WORD_DEFAULT ;
58- use crate :: hypervisor:: get_memory_access_violation;
59- use crate :: hypervisor:: wrappers:: WHvGeneralRegisters ;
57+ use crate :: hypervisor:: regs:: { CommonFpu , CommonRegisters } ;
58+ use crate :: hypervisor:: { InterruptHandleInternal , get_memory_access_violation} ;
6059use crate :: mem:: memory_region:: { MemoryRegion , MemoryRegionFlags } ;
6160use crate :: mem:: ptr:: { GuestPtr , RawPtr } ;
6261use crate :: mem:: shared_mem:: HostSharedMemory ;
@@ -736,9 +735,16 @@ impl Hypervisor for HypervWindowsDriver {
736735 }
737736
738737 #[ instrument( err( Debug ) , skip_all, parent = Span :: current( ) , level = "Trace" ) ]
739- fn run ( & mut self ) -> Result < super :: HyperlightExit > {
738+ fn run (
739+ & mut self ,
740+ #[ cfg( feature = "trace_guest" ) ] tc : & mut crate :: sandbox:: trace:: TraceContext ,
741+ ) -> Result < super :: HyperlightExit > {
742+ // Cast to internal trait for access to internal methods
743+ let interrupt_handle_internal =
744+ self . interrupt_handle . as_ref ( ) as & dyn super :: InterruptHandleInternal ;
745+
740746 // Get current generation and set running bit
741- let generation = self . interrupt_handle . set_running_bit ( ) ;
747+ let generation = interrupt_handle_internal . set_running_bit ( ) ;
742748
743749 #[ cfg( not( gdb) ) ]
744750 let debug_interrupt = false ;
@@ -749,8 +755,7 @@ impl Hypervisor for HypervWindowsDriver {
749755 . load ( Ordering :: Relaxed ) ;
750756
751757 // Check if cancellation was requested for THIS generation
752- let exit_context = if self
753- . interrupt_handle
758+ let exit_context = if interrupt_handle_internal
754759 . is_cancel_requested_for_generation ( generation)
755760 || debug_interrupt
756761 {
@@ -773,18 +778,17 @@ impl Hypervisor for HypervWindowsDriver {
773778 } ;
774779
775780 // Clear running bit
776- self . interrupt_handle . clear_running_bit ( ) ;
781+ interrupt_handle_internal . clear_running_bit ( ) ;
777782
778783 let is_canceled = exit_context. ExitReason == WHV_RUN_VP_EXIT_REASON ( 8193i32 ) ; // WHvRunVpExitReasonCanceled
779784
780785 // 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) ;
786+ let cancel_was_requested_manually =
787+ interrupt_handle_internal. is_cancel_requested_for_generation ( generation) ;
784788
785789 // Only clear cancel_requested if we're actually processing a cancellation for this generation
786790 if is_canceled && cancel_was_requested_manually {
787- self . interrupt_handle . clear_cancel_requested ( ) ;
791+ interrupt_handle_internal . clear_cancel_requested ( ) ;
788792 }
789793
790794 #[ cfg( gdb) ]
@@ -915,7 +919,36 @@ impl Hypervisor for HypervWindowsDriver {
915919 Ok ( result)
916920 }
917921
918- fn interrupt_handle ( & self ) -> Arc < dyn InterruptHandle > {
922+ /// Get regs
923+ #[ allow( dead_code) ]
924+ fn regs ( & self ) -> Result < CommonRegisters > {
925+ self . processor . regs ( )
926+ }
927+ /// Set regs
928+ fn set_regs ( & mut self , regs : & CommonRegisters ) -> Result < ( ) > {
929+ self . processor . set_regs ( regs)
930+ }
931+ /// Get fpu regs
932+ #[ allow( dead_code) ]
933+ fn fpu ( & self ) -> Result < CommonFpu > {
934+ self . processor . fpu ( )
935+ }
936+ /// Set fpu regs
937+ fn set_fpu ( & mut self , fpu : & CommonFpu ) -> Result < ( ) > {
938+ self . processor . set_fpu ( fpu)
939+ }
940+ /// Get special regs
941+ #[ allow( dead_code) ]
942+ fn sregs ( & self ) -> Result < CommonSpecialRegisters > {
943+ self . processor . sregs ( )
944+ }
945+ /// Set special regs
946+ #[ allow( dead_code) ]
947+ fn set_sregs ( & mut self , sregs : & CommonSpecialRegisters ) -> Result < ( ) > {
948+ self . processor . set_sregs ( sregs)
949+ }
950+
951+ fn interrupt_handle ( & self ) -> Arc < dyn super :: InterruptHandleInternal > {
919952 self . interrupt_handle . clone ( )
920953 }
921954
@@ -1204,19 +1237,22 @@ impl InterruptHandle for WindowsInterruptHandle {
12041237 // Only call WHvCancelRunVirtualProcessor if VCPU is actually running in guest mode
12051238 running && unsafe { WHvCancelRunVirtualProcessor ( self . partition_handle , 0 , 0 ) . is_ok ( ) }
12061239 }
1240+
12071241 #[ cfg( gdb) ]
12081242 fn kill_from_debugger ( & self ) -> bool {
12091243 self . debug_interrupt . store ( true , Ordering :: Relaxed ) ;
12101244 let ( running, _) = self . get_running_and_generation ( ) ;
12111245 running && unsafe { WHvCancelRunVirtualProcessor ( self . partition_handle , 0 , 0 ) . is_ok ( ) }
12121246 }
12131247
1214- fn get_call_active ( & self ) -> & AtomicBool {
1215- & self . call_active
1248+ fn dropped ( & self ) -> bool {
1249+ self . dropped . load ( Ordering :: Relaxed )
12161250 }
1251+ }
12171252
1218- fn get_dropped ( & self ) -> & AtomicBool {
1219- & self . dropped
1253+ impl InterruptHandleInternal for WindowsInterruptHandle {
1254+ fn get_call_active ( & self ) -> & AtomicBool {
1255+ & self . call_active
12201256 }
12211257
12221258 fn get_running ( & self ) -> & AtomicU64 {
0 commit comments