@@ -240,8 +240,6 @@ impl HypervisorHandler {
240
240
#[ cfg( gdb) ] debug_info : Option < DebugInfo > ,
241
241
) -> Result < ( ) > {
242
242
let configuration = self . configuration . clone ( ) ;
243
- #[ cfg( target_os = "windows" ) ]
244
- let in_process = sandbox_memory_manager. is_in_process ( ) ;
245
243
246
244
* self
247
245
. execution_variables
@@ -309,10 +307,9 @@ impl HypervisorHandler {
309
307
let hv = hv. as_mut ( ) . ok_or_else ( || new_error ! ( "Hypervisor not set" ) ) ?;
310
308
311
309
#[ cfg( target_os = "windows" ) ]
312
- if !in_process {
313
- execution_variables
310
+ execution_variables
314
311
. set_partition_handle ( hv. get_partition_handle ( ) ) ?;
315
- }
312
+
316
313
317
314
#[ cfg( target_os = "linux" ) ]
318
315
{
@@ -867,102 +864,76 @@ fn set_up_hypervisor_partition(
867
864
pml4_ptr
868
865
) ;
869
866
}
870
- if mgr. is_in_process ( ) {
871
- cfg_if:: cfg_if! {
872
- if #[ cfg( inprocess) ] {
873
- // in-process feature + debug build
874
- use super :: inprocess:: InprocessArgs ;
875
- use crate :: sandbox:: leaked_outb:: LeakedOutBWrapper ;
876
- use super :: inprocess:: InprocessDriver ;
877
-
878
- let leaked_outb_wrapper = LeakedOutBWrapper :: new( mgr, outb_handler) ?;
879
- let hv = InprocessDriver :: new( InprocessArgs {
880
- entrypoint_raw: u64 :: from( mgr. load_addr. clone( ) + mgr. entrypoint_offset) ,
881
- peb_ptr_raw: mgr
882
- . get_in_process_peb_address( mgr. shared_mem. base_addr( ) as u64 ) ?,
883
- leaked_outb_wrapper,
884
- } ) ?;
885
- Ok ( Box :: new( hv) )
886
- } else if #[ cfg( inprocess) ] {
887
- // in-process feature, but not debug build
888
- log_then_return!( "In-process mode is only available on debug-builds" ) ;
889
- } else if #[ cfg( debug_assertions) ] {
890
- // debug build without in-process feature
891
- log_then_return!( "In-process mode requires `inprocess` cargo feature" ) ;
892
- } else {
893
- log_then_return!( "In-process mode requires `inprocess` cargo feature and is only available on debug-builds" ) ;
894
- }
895
- }
896
- } else {
897
- // Create gdb thread if gdb is enabled and the configuration is provided
898
- // This is only done when the hypervisor is not in-process
899
- #[ cfg( gdb) ]
900
- let gdb_conn = if let Some ( DebugInfo { port } ) = debug_info {
901
- let gdb_conn = create_gdb_thread ( * port, unsafe { pthread_self ( ) } ) ;
867
+
868
+ // Create gdb thread if gdb is enabled and the configuration is provided
869
+ // This is only done when the hypervisor is not in-process
870
+ #[ cfg( gdb) ]
871
+ let gdb_conn = if let Some ( DebugInfo { port } ) = debug_info {
872
+ let gdb_conn = create_gdb_thread ( * port, unsafe { pthread_self ( ) } ) ;
902
873
903
- // in case the gdb thread creation fails, we still want to continue
904
- // without gdb
905
- match gdb_conn {
906
- Ok ( gdb_conn) => Some ( gdb_conn) ,
907
- Err ( e) => {
908
- log:: error!( "Could not create gdb connection: {:#}" , e) ;
874
+ // in case the gdb thread creation fails, we still want to continue
875
+ // without gdb
876
+ match gdb_conn {
877
+ Ok ( gdb_conn) => Some ( gdb_conn) ,
878
+ Err ( e) => {
879
+ log:: error!( "Could not create gdb connection: {:#}" , e) ;
909
880
910
- None
911
- }
881
+ None
912
882
}
913
- } else {
914
- None
915
- } ;
883
+ }
884
+ } else {
885
+ None
886
+ } ;
916
887
917
- match * get_available_hypervisor ( ) {
918
- #[ cfg( mshv) ]
919
- Some ( HypervisorType :: Mshv ) => {
920
- let hv = crate :: hypervisor:: hyperv_linux:: HypervLinuxDriver :: new (
921
- regions,
922
- entrypoint_ptr,
923
- rsp_ptr,
924
- pml4_ptr,
925
- #[ cfg( gdb) ]
926
- gdb_conn,
927
- ) ?;
928
- Ok ( Box :: new ( hv) )
929
- }
888
+ match * get_available_hypervisor ( ) {
889
+ #[ cfg( mshv) ]
890
+ Some ( HypervisorType :: Mshv ) => {
891
+ let hv = crate :: hypervisor:: hyperv_linux:: HypervLinuxDriver :: new (
892
+ regions,
893
+ entrypoint_ptr,
894
+ rsp_ptr,
895
+ pml4_ptr,
896
+ #[ cfg( gdb) ]
897
+ gdb_conn,
898
+ ) ?;
899
+ Ok ( Box :: new ( hv) )
900
+ }
930
901
931
- #[ cfg( kvm) ]
932
- Some ( HypervisorType :: Kvm ) => {
933
- let hv = crate :: hypervisor:: kvm:: KVMDriver :: new (
934
- regions,
935
- pml4_ptr. absolute ( ) ?,
936
- entrypoint_ptr. absolute ( ) ?,
937
- rsp_ptr. absolute ( ) ?,
938
- #[ cfg( gdb) ]
939
- gdb_conn,
940
- ) ?;
941
- Ok ( Box :: new ( hv) )
942
- }
902
+ #[ cfg( kvm) ]
903
+ Some ( HypervisorType :: Kvm ) => {
904
+ let hv = crate :: hypervisor:: kvm:: KVMDriver :: new (
905
+ regions,
906
+ pml4_ptr. absolute ( ) ?,
907
+ entrypoint_ptr. absolute ( ) ?,
908
+ rsp_ptr. absolute ( ) ?,
909
+ #[ cfg( gdb) ]
910
+ gdb_conn,
911
+ ) ?;
912
+ Ok ( Box :: new ( hv) )
913
+ }
943
914
944
- #[ cfg( target_os = "windows" ) ]
945
- Some ( HypervisorType :: Whp ) => {
946
- let mmap_file_handle = mgr
947
- . shared_mem
948
- . with_exclusivity ( |e| e. get_mmap_file_handle ( ) ) ?;
949
- let hv = crate :: hypervisor:: hyperv_windows:: HypervWindowsDriver :: new (
950
- regions,
951
- mgr. shared_mem . raw_mem_size ( ) , // we use raw_* here because windows driver requires 64K aligned addresses,
952
- mgr. shared_mem . raw_ptr ( ) as * mut c_void , // and instead convert it to base_addr where needed in the driver itself
953
- pml4_ptr. absolute ( ) ?,
954
- entrypoint_ptr. absolute ( ) ?,
955
- rsp_ptr. absolute ( ) ?,
956
- HandleWrapper :: from ( mmap_file_handle) ,
957
- ) ?;
958
- Ok ( Box :: new ( hv) )
959
- }
915
+ #[ cfg( target_os = "windows" ) ]
916
+ Some ( HypervisorType :: Whp ) => {
917
+ let mmap_file_handle = mgr
918
+ . shared_mem
919
+ . with_exclusivity ( |e| e. get_mmap_file_handle ( ) ) ?;
920
+ let hv = crate :: hypervisor:: hyperv_windows:: HypervWindowsDriver :: new (
921
+ regions,
922
+ mgr. shared_mem . raw_mem_size ( ) , // we use raw_* here because windows driver requires 64K aligned addresses,
923
+ mgr. shared_mem . raw_ptr ( ) as * mut c_void , // and instead convert it to base_addr where needed in the driver itself
924
+ pml4_ptr. absolute ( ) ?,
925
+ entrypoint_ptr. absolute ( ) ?,
926
+ rsp_ptr. absolute ( ) ?,
927
+ HandleWrapper :: from ( mmap_file_handle) ,
928
+ ) ?;
929
+ Ok ( Box :: new ( hv) )
930
+ }
960
931
961
- _ => {
962
- log_then_return ! ( NoHypervisorFound ( ) ) ;
963
- }
932
+ _ => {
933
+ log_then_return ! ( NoHypervisorFound ( ) ) ;
964
934
}
965
935
}
936
+
966
937
}
967
938
968
939
#[ cfg( test) ]
0 commit comments