Skip to content

Commit 46670b1

Browse files
committed
Remove in process mode from hyperlight-host
Signed-off-by: Simon Davies <simongdavies@users.noreply.github.com>
1 parent a8f1d65 commit 46670b1

File tree

22 files changed

+110
-717
lines changed

22 files changed

+110
-717
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

docs/debugging-hyperlight.md

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

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: 61 additions & 94 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,11 +307,7 @@ 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
314-
.set_partition_handle(hv.get_partition_handle())?;
315-
}
316-
310+
execution_variables.set_partition_handle(hv.get_partition_handle())?;
317311
#[cfg(target_os = "linux")]
318312
{
319313
// We cannot use the Killable trait, so we get the `pthread_t` via a libc
@@ -867,100 +861,73 @@ fn set_up_hypervisor_partition(
867861
pml4_ptr
868862
);
869863
}
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() });
902864

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() });
909870

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

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
929879
}
880+
}
881+
} else {
882+
None
883+
};
930884

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

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

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());
964931
}
965932
}
966933
}

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;

0 commit comments

Comments
 (0)