@@ -36,13 +36,13 @@ use super::regs::{CommonFpu, CommonRegisters};
3636#[ cfg( target_os = "windows" ) ]
3737use super :: { PartitionState , WindowsInterruptHandle } ;
3838use crate :: HyperlightError :: { ExecutionCanceledByHost , NoHypervisorFound } ;
39- #[ cfg( not( gdb) ) ]
40- use crate :: hypervisor:: Hypervisor ;
4139#[ cfg( any( kvm, mshv3) ) ]
4240use crate :: hypervisor:: LinuxInterruptHandle ;
4341#[ cfg( crashdump) ]
4442use crate :: hypervisor:: crashdump;
4543use crate :: hypervisor:: regs:: CommonSpecialRegisters ;
44+ #[ cfg( not( gdb) ) ]
45+ use crate :: hypervisor:: vm:: Vm ;
4646#[ cfg( kvm) ]
4747use crate :: hypervisor:: vm:: kvm:: KvmVm ;
4848#[ cfg( mshv3) ]
@@ -51,7 +51,7 @@ use crate::hypervisor::vm::mshv::MshvVm;
5151use crate :: hypervisor:: vm:: whp:: WhpVm ;
5252#[ cfg( target_os = "windows" ) ]
5353use crate :: hypervisor:: wrappers:: HandleWrapper ;
54- use crate :: hypervisor:: { HyperlightExit , InterruptHandle , InterruptHandleImpl , get_max_log_level} ;
54+ use crate :: hypervisor:: { InterruptHandle , InterruptHandleImpl , get_max_log_level, vm :: VmExit } ;
5555use crate :: mem:: memory_region:: { MemoryRegion , MemoryRegionFlags , MemoryRegionType } ;
5656use crate :: mem:: mgr:: SandboxMemoryManager ;
5757use crate :: mem:: ptr:: { GuestPtr , RawPtr } ;
@@ -77,7 +77,7 @@ pub(crate) struct HyperlightVm {
7777 #[ cfg( gdb) ]
7878 vm : Box < dyn DebuggableVm > ,
7979 #[ cfg( not( gdb) ) ]
80- vm : Box < dyn Hypervisor > ,
80+ vm : Box < dyn Vm > ,
8181 page_size : usize ,
8282 entrypoint : u64 ,
8383 orig_rsp : GuestPtr ,
@@ -117,7 +117,7 @@ impl HyperlightVm {
117117 #[ cfg( gdb) ]
118118 type VmType = Box < dyn DebuggableVm > ;
119119 #[ cfg( not( gdb) ) ]
120- type VmType = Box < dyn Hypervisor > ;
120+ type VmType = Box < dyn Vm > ;
121121
122122 #[ cfg_attr( not( gdb) , allow( unused_mut) ) ]
123123 let mut vm: VmType = match get_available_hypervisor ( ) {
@@ -368,7 +368,7 @@ impl HyperlightVm {
368368 let result = loop {
369369 // ===== KILL() TIMING POINT 2: Before set_tid() =====
370370 // If kill() is called and ran to completion BEFORE this line executes:
371- // - CANCEL_BIT will be set and we will return an early HyperlightExit ::Cancelled()
371+ // - CANCEL_BIT will be set and we will return an early VmExit ::Cancelled()
372372 // without sending any signals/WHV api calls
373373 #[ cfg( any( kvm, mshv3) ) ]
374374 self . interrupt_handle . set_tid ( ) ;
@@ -379,7 +379,7 @@ impl HyperlightVm {
379379 let exit_reason = if self . interrupt_handle . is_cancelled ( )
380380 || self . interrupt_handle . is_debug_interrupted ( )
381381 {
382- Ok ( HyperlightExit :: Cancelled ( ) )
382+ Ok ( VmExit :: Cancelled ( ) )
383383 } else {
384384 #[ cfg( feature = "trace_guest" ) ]
385385 tc. setup_guest_trace ( Span :: current ( ) . context ( ) ) ;
@@ -424,7 +424,7 @@ impl HyperlightVm {
424424 // - Signals will not be sent
425425 match exit_reason {
426426 #[ cfg( gdb) ]
427- Ok ( HyperlightExit :: Debug { dr6, exception } ) => {
427+ Ok ( VmExit :: Debug { dr6, exception } ) => {
428428 // Handle debug event (breakpoints)
429429 let stop_reason =
430430 arch:: vcpu_stop_reason ( self . vm . as_mut ( ) , dr6, self . entrypoint , exception) ?;
@@ -433,13 +433,11 @@ impl HyperlightVm {
433433 }
434434 }
435435
436- Ok ( HyperlightExit :: Halt ( ) ) => {
436+ Ok ( VmExit :: Halt ( ) ) => {
437437 break Ok ( ( ) ) ;
438438 }
439- Ok ( HyperlightExit :: IoOut ( port, data) ) => {
440- self . handle_io ( mem_mgr, host_funcs, port, data) ?
441- }
442- Ok ( HyperlightExit :: MmioRead ( addr) ) => {
439+ Ok ( VmExit :: IoOut ( port, data) ) => self . handle_io ( mem_mgr, host_funcs, port, data) ?,
440+ Ok ( VmExit :: MmioRead ( addr) ) => {
443441 let all_regions = self . sandbox_regions . iter ( ) . chain ( self . get_mapped_regions ( ) ) ;
444442 match get_memory_access_violation (
445443 addr as usize ,
@@ -465,7 +463,7 @@ impl HyperlightVm {
465463 }
466464 }
467465 }
468- Ok ( HyperlightExit :: MmioWrite ( addr) ) => {
466+ Ok ( VmExit :: MmioWrite ( addr) ) => {
469467 let all_regions = self . sandbox_regions . iter ( ) . chain ( self . get_mapped_regions ( ) ) ;
470468 match get_memory_access_violation (
471469 addr as usize ,
@@ -491,15 +489,15 @@ impl HyperlightVm {
491489 }
492490 }
493491 }
494- Ok ( HyperlightExit :: Cancelled ( ) ) => {
492+ Ok ( VmExit :: Cancelled ( ) ) => {
495493 // If cancellation was not requested for this specific guest function call,
496494 // the vcpu was interrupted by a stale cancellation. This can occur when:
497495 // - Linux: A signal from a previous call arrives late
498496 // - Windows: WHvCancelRunVirtualProcessor called right after vcpu exits but RUNNING_BIT is still true
499497 if !cancel_requested && !debug_interrupted {
500498 // Track that an erroneous vCPU kick occurred
501499 metrics:: counter!( METRIC_ERRONEOUS_VCPU_KICKS ) . increment ( 1 ) ;
502- // treat this the same as a HyperlightExit ::Retry, the cancel was not meant for this call
500+ // treat this the same as a VmExit ::Retry, the cancel was not meant for this call
503501 continue ;
504502 }
505503
@@ -517,10 +515,10 @@ impl HyperlightVm {
517515 metrics:: counter!( METRIC_GUEST_CANCELLATION ) . increment ( 1 ) ;
518516 break Err ( ExecutionCanceledByHost ( ) ) ;
519517 }
520- Ok ( HyperlightExit :: Unknown ( reason) ) => {
518+ Ok ( VmExit :: Unknown ( reason) ) => {
521519 break Err ( new_error ! ( "Unexpected VM Exit: {:?}" , reason) ) ;
522520 }
523- Ok ( HyperlightExit :: Retry ( ) ) => continue ,
521+ Ok ( VmExit :: Retry ( ) ) => continue ,
524522 Err ( e) => {
525523 break Err ( e) ;
526524 }
0 commit comments