@@ -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,11 +307,7 @@ 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
314
- . set_partition_handle ( hv. get_partition_handle ( ) ) ?;
315
- }
316
-
310
+ execution_variables. set_partition_handle ( hv. get_partition_handle ( ) ) ?;
317
311
#[ cfg( target_os = "linux" ) ]
318
312
{
319
313
// We cannot use the Killable trait, so we get the `pthread_t` via a libc
@@ -867,100 +861,73 @@ fn set_up_hypervisor_partition(
867
861
pml4_ptr
868
862
) ;
869
863
}
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 ( ) } ) ;
902
864
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) ;
865
+ // Create gdb thread if gdb is enabled and the configuration is provided
866
+ // This is only done when the hypervisor is not in-process
867
+ #[ cfg( gdb) ]
868
+ let gdb_conn = if let Some ( DebugInfo { port } ) = debug_info {
869
+ let gdb_conn = create_gdb_thread ( * port, unsafe { pthread_self ( ) } ) ;
909
870
910
- None
911
- }
912
- }
913
- } else {
914
- None
915
- } ;
871
+ // in case the gdb thread creation fails, we still want to continue
872
+ // without gdb
873
+ match gdb_conn {
874
+ Ok ( gdb_conn ) => Some ( gdb_conn ) ,
875
+ Err ( e ) => {
876
+ log :: error! ( "Could not create gdb connection: {:#}" , e ) ;
916
877
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) )
878
+ None
929
879
}
880
+ }
881
+ } else {
882
+ None
883
+ } ;
930
884
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
- }
885
+ match * get_available_hypervisor ( ) {
886
+ #[ cfg( mshv) ]
887
+ Some ( HypervisorType :: Mshv ) => {
888
+ let hv = crate :: hypervisor:: hyperv_linux:: HypervLinuxDriver :: new (
889
+ regions,
890
+ entrypoint_ptr,
891
+ rsp_ptr,
892
+ pml4_ptr,
893
+ #[ cfg( gdb) ]
894
+ gdb_conn,
895
+ ) ?;
896
+ Ok ( Box :: new ( hv) )
897
+ }
943
898
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
- }
899
+ #[ cfg( kvm) ]
900
+ Some ( HypervisorType :: Kvm ) => {
901
+ let hv = crate :: hypervisor:: kvm:: KVMDriver :: new (
902
+ regions,
903
+ pml4_ptr. absolute ( ) ?,
904
+ entrypoint_ptr. absolute ( ) ?,
905
+ rsp_ptr. absolute ( ) ?,
906
+ #[ cfg( gdb) ]
907
+ gdb_conn,
908
+ ) ?;
909
+ Ok ( Box :: new ( hv) )
910
+ }
960
911
961
- _ => {
962
- log_then_return ! ( NoHypervisorFound ( ) ) ;
963
- }
912
+ #[ cfg( target_os = "windows" ) ]
913
+ Some ( HypervisorType :: Whp ) => {
914
+ let mmap_file_handle = mgr
915
+ . shared_mem
916
+ . with_exclusivity ( |e| e. get_mmap_file_handle ( ) ) ?;
917
+ let hv = crate :: hypervisor:: hyperv_windows:: HypervWindowsDriver :: new (
918
+ regions,
919
+ mgr. shared_mem . raw_mem_size ( ) , // we use raw_* here because windows driver requires 64K aligned addresses,
920
+ mgr. shared_mem . raw_ptr ( ) as * mut c_void , // and instead convert it to base_addr where needed in the driver itself
921
+ pml4_ptr. absolute ( ) ?,
922
+ entrypoint_ptr. absolute ( ) ?,
923
+ rsp_ptr. absolute ( ) ?,
924
+ HandleWrapper :: from ( mmap_file_handle) ,
925
+ ) ?;
926
+ Ok ( Box :: new ( hv) )
927
+ }
928
+
929
+ _ => {
930
+ log_then_return ! ( NoHypervisorFound ( ) ) ;
964
931
}
965
932
}
966
933
}
0 commit comments