Skip to content

Commit 04e94a2

Browse files
committed
remove in-process mode
Signed-off-by: Simon Davies <simongdavies@users.noreply.github.com>
1 parent a8f1d65 commit 04e94a2

File tree

21 files changed

+101
-632
lines changed

21 files changed

+101
-632
lines changed

.github/workflows/dep_rust.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,8 @@ jobs:
102102
# with default features
103103
just test ${{ matrix.config }} ${{ matrix.hypervisor == 'mshv3' && 'mshv3' || ''}}
104104
105-
# with only one driver enabled (driver mshv/kvm feature is ignored on windows) + seccomp + inprocess
106-
just test ${{ matrix.config }} inprocess,seccomp,${{ matrix.hypervisor == 'mshv' && 'mshv2' || matrix.hypervisor == 'mshv3' && 'mshv3' || 'kvm' }}
105+
# with only one driver enabled (driver mshv/kvm feature is ignored on windows) + seccomp
106+
just test ${{ matrix.config }} seccomp,${{ matrix.hypervisor == 'mshv' && 'mshv2' || matrix.hypervisor == 'mshv3' && 'mshv3' || 'kvm' }}
107107
108108
# make sure certain cargo features compile
109109
cargo check -p hyperlight-host --features crashdump

Justfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,8 @@ test-like-ci config=default-target hypervisor="kvm":
6161
@# with default features
6262
just test {{config}} {{ if hypervisor == "mshv3" {"mshv3"} else {""} }}
6363

64-
@# with only one driver enabled + seccomp + inprocess
65-
just test {{config}} inprocess,seccomp,{{ if hypervisor == "mshv" {"mshv2"} else if hypervisor == "mshv3" {"mshv3"} else {"kvm"} }}
64+
@# with only one driver enabled + seccomp
65+
just test {{config}} seccomp,{{ if hypervisor == "mshv" {"mshv2"} else if hypervisor == "mshv3" {"mshv3"} else {"kvm"} }}
6666

6767
@# make sure certain cargo features compile
6868
cargo check -p hyperlight-host --features crashdump

src/hyperlight_host/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,6 @@ crashdump = ["dep:tempfile"] # Dumps the VM state to a file on unexpected errors
126126
kvm = ["dep:kvm-bindings", "dep:kvm-ioctls"]
127127
mshv2 = ["dep:mshv-bindings2", "dep:mshv-ioctls2"]
128128
mshv3 = ["dep:mshv-bindings3", "dep:mshv-ioctls3"]
129-
inprocess = []
130129
# This enables easy debug in the guest
131130
gdb = ["dep:gdbstub", "dep:gdbstub_arch"]
132131
fuzzing = ["hyperlight-common/fuzzing"]

src/hyperlight_host/build.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,9 +92,6 @@ fn main() -> Result<()> {
9292
gdb: { all(feature = "gdb", debug_assertions, any(feature = "kvm", feature = "mshv2", feature = "mshv3"), target_os = "linux") },
9393
kvm: { all(feature = "kvm", target_os = "linux") },
9494
mshv: { all(any(feature = "mshv2", feature = "mshv3"), target_os = "linux") },
95-
// inprocess feature is aliased with debug_assertions to make it only available in debug-builds.
96-
// You should never use #[cfg(feature = "inprocess")] in the codebase. Use #[cfg(inprocess)] instead.
97-
inprocess: { all(feature = "inprocess", debug_assertions) },
9895
// crashdump feature is aliased with debug_assertions to make it only available in debug-builds.
9996
crashdump: { all(feature = "crashdump", debug_assertions) },
10097
// print_debug feature is aliased with debug_assertions to make it only available in debug-builds.

src/hyperlight_host/src/func/guest_dispatch.rs

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -349,19 +349,6 @@ mod tests {
349349
call_guest_function_by_name_hv();
350350
}
351351

352-
#[test]
353-
#[cfg(inprocess)]
354-
fn test_call_guest_function_by_name_in_proc_manual() {
355-
let u_sbox = UninitializedSandbox::new(
356-
guest_bin(),
357-
None,
358-
Some(crate::SandboxRunOptions::RunInProcess(false)),
359-
None,
360-
)
361-
.unwrap();
362-
test_call_guest_function_by_name(u_sbox);
363-
}
364-
365352
fn terminate_vcpu_after_1000ms() -> Result<()> {
366353
// This test relies upon a Hypervisor being present so for now
367354
// we will skip it if there isn't one.
@@ -456,7 +443,6 @@ mod tests {
456443
}
457444

458445
#[test]
459-
#[cfg(not(inprocess))]
460446
fn test_trigger_exception_on_guest() {
461447
let usbox = UninitializedSandbox::new(
462448
GuestBinary::FilePath(simple_guest_as_string().expect("Guest Binary Missing")),

src/hyperlight_host/src/hypervisor/hypervisor_handler.rs

Lines changed: 63 additions & 92 deletions
Original file line numberDiff line numberDiff line change
@@ -240,8 +240,6 @@ impl HypervisorHandler {
240240
#[cfg(gdb)] debug_info: Option<DebugInfo>,
241241
) -> Result<()> {
242242
let configuration = self.configuration.clone();
243-
#[cfg(target_os = "windows")]
244-
let in_process = sandbox_memory_manager.is_in_process();
245243

246244
*self
247245
.execution_variables
@@ -309,10 +307,9 @@ impl HypervisorHandler {
309307
let hv = hv.as_mut().ok_or_else(|| new_error!("Hypervisor not set"))?;
310308

311309
#[cfg(target_os = "windows")]
312-
if !in_process {
313-
execution_variables
310+
execution_variables
314311
.set_partition_handle(hv.get_partition_handle())?;
315-
}
312+
316313

317314
#[cfg(target_os = "linux")]
318315
{
@@ -867,102 +864,76 @@ fn set_up_hypervisor_partition(
867864
pml4_ptr
868865
);
869866
}
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() });
902873

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);
909880

910-
None
911-
}
881+
None
912882
}
913-
} else {
914-
None
915-
};
883+
}
884+
} else {
885+
None
886+
};
916887

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+
}
930901

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+
}
943914

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+
}
960931

961-
_ => {
962-
log_then_return!(NoHypervisorFound());
963-
}
932+
_ => {
933+
log_then_return!(NoHypervisorFound());
964934
}
965935
}
936+
966937
}
967938

968939
#[cfg(test)]

src/hyperlight_host/src/hypervisor/mod.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,6 @@ pub(crate) mod hypervisor_handler;
3939
#[cfg(gdb)]
4040
mod gdb;
4141

42-
/// Driver for running in process instead of using hypervisor
43-
#[cfg(inprocess)]
44-
pub mod inprocess;
4542
#[cfg(kvm)]
4643
/// Functionality to manipulate KVM-based virtual machines
4744
pub mod kvm;

src/hyperlight_host/src/mem/custom_drop.rs

Lines changed: 0 additions & 109 deletions
This file was deleted.

0 commit comments

Comments
 (0)