From ae8bd5c8de09e78d56fd2ba642fd6dfbd14342e0 Mon Sep 17 00:00:00 2001 From: Ludvig Liljenberg <4257730+ludfjig@users.noreply.github.com> Date: Thu, 22 Oct 2026 10:34:19 -0700 Subject: [PATCH] Remove SandboxRuntimeConfig Each field moves to the place that already owns its data: * debug_info and guest_core_dump are read from SandboxConfiguration. * The crashdump entry point is read from the memory manager, which restore already updates. * The guest binary path is dropped. Core dumps report as the process name for every sandbox, as snapshot sandboxes already did. Sandbox setup and restore no longer need crashdump or gdb plumbing. Signed-off-by: Ludvig Liljenberg <4257730+ludfjig@users.noreply.github.com> --- CHANGELOG.md | 1 + docs/how-to-debug-a-hyperlight-guest.md | 2 +- .../src/hypervisor/crashdump.rs | 42 +---- .../src/hypervisor/hyperlight_vm/aarch64.rs | 3 - .../src/hypervisor/hyperlight_vm/mod.rs | 18 +- .../src/hypervisor/hyperlight_vm/x86_64.rs | 33 +--- src/hyperlight_host/src/hypervisor/mod.rs | 6 - .../src/sandbox/initialized.rs | 36 +--- .../src/sandbox/uninitialized.rs | 172 +++--------------- .../src/sandbox/uninitialized_evolve.rs | 24 +-- 10 files changed, 50 insertions(+), 287 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9eac2ff63..39893f5e0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/). ### Added ### Changed +* Core dumps no longer record the guest binary path. The process name and command line are always ``, as they already were for sandboxes created from snapshots by @ludfjig in https://github.com/hyperlight-dev/hyperlight/pull/1975 ### Removed diff --git a/docs/how-to-debug-a-hyperlight-guest.md b/docs/how-to-debug-a-hyperlight-guest.md index 688b08767..2deb9894d 100644 --- a/docs/how-to-debug-a-hyperlight-guest.md +++ b/docs/how-to-debug-a-hyperlight-guest.md @@ -267,7 +267,7 @@ After the core dump has been created, to inspect the state of the guest, load th #### Using gdb -Load the core dump alongside the guest binary that was running when the crash occurred: +Load the core dump alongside the guest binary that was running when the crash occurred. Core dumps do not record which guest binary that was, so keep track of the guest each sandbox runs: ```bash gdb -c diff --git a/src/hyperlight_host/src/hypervisor/crashdump.rs b/src/hyperlight_host/src/hypervisor/crashdump.rs index 6c9aec132..5a5ec92f5 100644 --- a/src/hyperlight_host/src/hypervisor/crashdump.rs +++ b/src/hyperlight_host/src/hypervisor/crashdump.rs @@ -30,6 +30,10 @@ const CORE_DUMP_PID: i32 = 1; /// The page size of the core dump const CORE_DUMP_PAGE_SIZE: usize = 0x1000; +/// Process name and command line in the core dump. Sandboxes do not +/// record which guest binary they run. +const UNKNOWN_PROCESS: &str = ""; + /// Structure to hold the crash dump context /// This structure contains the information needed to create a core dump #[derive(Debug)] @@ -38,7 +42,6 @@ pub(crate) struct CrashDumpContext { regs: [u64; 27], xsave: Vec, entry: u64, - binary: Option, } impl CrashDumpContext { @@ -47,14 +50,12 @@ impl CrashDumpContext { regs: [u64; 27], xsave: Vec, entry: u64, - binary: Option, ) -> Self { Self { regions, regs, xsave, entry, - binary, } } } @@ -88,21 +89,6 @@ impl GuestView { }) .collect(); - let filename = ctx - .binary - .as_deref() - .and_then(|path| path.file_name()) - .map_or("".to_string(), |name| { - name.to_string_lossy().into_owned() - }); - - let cmd = ctx - .binary - .as_deref() - .map_or("".to_string(), |path| { - path.to_string_lossy().into_owned() - }); - // The xsave state is checked as it can be empty let mut components = vec![]; if !ctx.xsave.is_empty() { @@ -122,7 +108,7 @@ impl GuestView { tid: 1, uid: 0, // User ID gid: 0, // Group ID - comm: filename, + comm: UNKNOWN_PROCESS.to_string(), ppid: 0, // Parent PID pgrp: 0, // Process group ID nice: 0, // Nice value @@ -135,7 +121,7 @@ impl GuestView { session: 0, // Session ID of the process sighold: 0, // Blocked signal sigpend: 0, // Pending signal - cmd_line: cmd, + cmd_line: UNKNOWN_PROCESS.to_string(), arch_state: Box::new(ArchState { gpr_state: ctx.regs.to_vec(), @@ -435,13 +421,7 @@ mod test { #[test] fn test_crashdump_write_fails_when_no_regions() { // Create a dummy context - let ctx = CrashDumpContext::new( - vec![], - [0; 27], - vec![], - 0, - Some(PathBuf::from("dummy_binary")), - ); + let ctx = CrashDumpContext::new(vec![], [0; 27], vec![], 0); let get_writer = || Ok(Box::new(std::io::empty()) as Box); @@ -466,13 +446,7 @@ mod test { region_type: crate::mem::memory_region::MemoryRegionType::Code, }]; // Create a dummy context - let ctx = CrashDumpContext::new( - regions, - [0; 27], - vec![], - 0x1000, - Some(PathBuf::from("dummy_binary")), - ); + let ctx = CrashDumpContext::new(regions, [0; 27], vec![], 0x1000); let get_writer = || Ok(Box::new(std::io::empty()) as Box); diff --git a/src/hyperlight_host/src/hypervisor/hyperlight_vm/aarch64.rs b/src/hyperlight_host/src/hypervisor/hyperlight_vm/aarch64.rs index 0c6870f23..da6ea7f63 100644 --- a/src/hyperlight_host/src/hypervisor/hyperlight_vm/aarch64.rs +++ b/src/hyperlight_host/src/hypervisor/hyperlight_vm/aarch64.rs @@ -37,8 +37,6 @@ use crate::sandbox::host_funcs::FunctionRegistry; use crate::sandbox::snapshot::NextAction; #[cfg(feature = "mem_profile")] use crate::sandbox::trace::MemTraceInfo; -#[cfg(crashdump)] -use crate::sandbox::uninitialized::SandboxRuntimeConfig; impl HyperlightVm { #[allow(clippy::too_many_arguments)] @@ -52,7 +50,6 @@ impl HyperlightVm { page_size: usize, #[cfg_attr(target_os = "windows", allow(unused_variables))] config: &SandboxConfiguration, #[cfg(gdb)] _gdb_conn: Option>, - #[cfg(crashdump)] _rt_cfg: SandboxRuntimeConfig, #[cfg(feature = "mem_profile")] _trace_info: MemTraceInfo, ) -> std::result::Result { // TODO: support gdb on aarch64 diff --git a/src/hyperlight_host/src/hypervisor/hyperlight_vm/mod.rs b/src/hyperlight_host/src/hypervisor/hyperlight_vm/mod.rs index 9d6157364..66e494ad9 100644 --- a/src/hyperlight_host/src/hypervisor/hyperlight_vm/mod.rs +++ b/src/hyperlight_host/src/hypervisor/hyperlight_vm/mod.rs @@ -44,8 +44,6 @@ use crate::sandbox::outb::{HandleOutbError, handle_outb}; use crate::sandbox::snapshot::NextAction; #[cfg(feature = "mem_profile")] use crate::sandbox::trace::MemTraceInfo; -#[cfg(crashdump)] -use crate::sandbox::uninitialized::SandboxRuntimeConfig; /// Get the logging level filter to pass to the guest entrypoint /// @@ -399,7 +397,7 @@ pub(crate) struct HyperlightVm { #[cfg(feature = "mem_profile")] pub(super) trace_info: MemTraceInfo, #[cfg(crashdump)] - pub(super) rt_cfg: SandboxRuntimeConfig, + pub(super) guest_core_dump: bool, /// MSRs restored on snapshot restore. #[cfg(target_arch = "x86_64")] pub(super) msr_reset: crate::hypervisor::regs::MsrResetState, @@ -576,18 +574,6 @@ impl HyperlightVm { self.next_action = next_action } - /// Set the guest ELF entry point used to fill `AT_ENTRY` in - /// crashdumps. - #[cfg(crashdump)] - pub(crate) fn set_crashdump_entry_point(&mut self, entry_point: u64) { - self.rt_cfg.entry_point = Some(entry_point); - } - - #[cfg(crashdump)] - pub(crate) fn clear_crashdump_binary_path(&mut self) { - self.rt_cfg.binary_path = None; - } - pub(crate) fn interrupt_handle(&self) -> Arc { self.interrupt_handle.clone() } @@ -786,7 +772,7 @@ impl HyperlightVm { } Err(e) => { #[cfg(crashdump)] - if self.rt_cfg.guest_core_dump { + if self.guest_core_dump { crate::hypervisor::crashdump::generate_crashdump(self, mem_mgr, None) .map_err(|e| RunVmError::CrashdumpGeneration(Box::new(e)))?; } diff --git a/src/hyperlight_host/src/hypervisor/hyperlight_vm/x86_64.rs b/src/hyperlight_host/src/hypervisor/hyperlight_vm/x86_64.rs index 8ca3024fc..7868e95fb 100644 --- a/src/hyperlight_host/src/hypervisor/hyperlight_vm/x86_64.rs +++ b/src/hyperlight_host/src/hypervisor/hyperlight_vm/x86_64.rs @@ -44,8 +44,6 @@ use crate::sandbox::host_funcs::FunctionRegistry; use crate::sandbox::snapshot::NextAction; #[cfg(feature = "mem_profile")] use crate::sandbox::trace::MemTraceInfo; -#[cfg(crashdump)] -use crate::sandbox::uninitialized::SandboxRuntimeConfig; #[cfg(gdb)] type BoxedVm = Box; @@ -65,7 +63,6 @@ impl HyperlightVm { page_size: usize, #[cfg_attr(target_os = "windows", allow(unused_variables))] config: &SandboxConfiguration, #[cfg(gdb)] gdb_conn: Option>, - #[cfg(crashdump)] rt_cfg: SandboxRuntimeConfig, #[cfg(feature = "mem_profile")] trace_info: MemTraceInfo, ) -> std::result::Result { let mut vm: BoxedVm = match get_available_hypervisor() { @@ -136,7 +133,7 @@ impl HyperlightVm { #[cfg(feature = "mem_profile")] trace_info, #[cfg(crashdump)] - rt_cfg, + guest_core_dump: config.get_guest_core_dump(), msr_reset, }; @@ -521,7 +518,7 @@ impl HyperlightVm { mem_mgr: &mut SandboxMemoryManager, ) -> std::result::Result, CrashDumpError> { - if self.rt_cfg.guest_core_dump { + if self.guest_core_dump { let mut regs = [0; 27]; let vcpu_regs = self.vm.regs()?; @@ -557,17 +554,12 @@ impl HyperlightVm { regs[25] = sregs.fs.selector as u64; // fs regs[26] = sregs.gs.selector as u64; // gs - // Use the stored entry point address from the runtime config. - // This is the original entry point (load_addr + ELF entry offset) - // which GDB needs for AT_ENTRY to compute the PIE load offset. - // We cannot use self.next_action here because it transitions from - // Initialise(addr) to Call(dispatch_addr) after guest init. - let initialise = self.rt_cfg.entry_point.unwrap_or_else(|| { - tracing::warn!( - "entry_point was never set in SandboxRuntimeConfig; AT_ENTRY will be 0" - ); - 0 - }); + // GDB derives the PIE load offset from AT_ENTRY. `next_action` + // holds the dispatch address after init, so use the ELF entry. + let entry = mem_mgr.original_entrypoint; + if entry == 0 { + tracing::warn!("Guest entry point is unknown; AT_ENTRY will be 0"); + } let mmap_regions: Vec = self.get_mapped_regions().cloned().collect(); let root_pt = self.get_root_pt()?; @@ -579,8 +571,7 @@ impl HyperlightVm { regions, regs, xsave.to_vec(), - initialise, - self.rt_cfg.binary_path.clone(), + entry, ))) } else { Ok(None) @@ -880,8 +871,6 @@ mod tests { use crate::mem::shared_mem::{ExclusiveSharedMemory, ReadonlySharedMemory}; use crate::sandbox::SandboxConfiguration; use crate::sandbox::host_funcs::FunctionRegistry; - #[cfg(any(crashdump, gdb))] - use crate::sandbox::uninitialized::SandboxRuntimeConfig; use crate::sandbox::uninitialized_evolve::set_up_hypervisor_partition; /// Test context holding an initialized VM with memory manager. @@ -1472,8 +1461,6 @@ mod tests { /// both `hyperlight_vm()` and `create_test_vm_context()`. fn create_test_vm_context(code: &[u8]) -> TestVmContext { let config: SandboxConfiguration = Default::default(); - #[cfg(any(crashdump, gdb))] - let rt_cfg: SandboxRuntimeConfig = Default::default(); let (layout, pt_bytes) = create_test_layout(code.len()); @@ -1506,8 +1493,6 @@ mod tests { &config, stack_top_gva, page_size::get(), - #[cfg(any(crashdump, gdb))] - rt_cfg, crate::mem::exe::LoadInfo::dummy(), ) .unwrap(); diff --git a/src/hyperlight_host/src/hypervisor/mod.rs b/src/hyperlight_host/src/hypervisor/mod.rs index aee561b47..b656b519d 100644 --- a/src/hyperlight_host/src/hypervisor/mod.rs +++ b/src/hyperlight_host/src/hypervisor/mod.rs @@ -470,8 +470,6 @@ pub(crate) mod tests { use hyperlight_testing::dummy_guest_as_pathbuf; use crate::sandbox::uninitialized::GuestBinary; - #[cfg(any(crashdump, gdb))] - use crate::sandbox::uninitialized::SandboxRuntimeConfig; use crate::sandbox::uninitialized_evolve::set_up_hypervisor_partition; use crate::sandbox::{SandboxConfiguration, UninitializedSandbox}; use crate::{Result, is_hypervisor_present}; @@ -489,8 +487,6 @@ pub(crate) mod tests { let filename = dummy_guest_as_pathbuf(); let config: SandboxConfiguration = Default::default(); - #[cfg(any(crashdump, gdb))] - let rt_cfg: SandboxRuntimeConfig = Default::default(); let sandbox = UninitializedSandbox::new(GuestBinary::FilePath(filename.clone()), Some(config))?; let (mut mem_mgr, gshm) = sandbox.mgr.build().unwrap(); @@ -502,8 +498,6 @@ pub(crate) mod tests { &config, exn_stack_top_gva, page_size::get(), - #[cfg(any(crashdump, gdb))] - rt_cfg, sandbox.load_info, )?; diff --git a/src/hyperlight_host/src/sandbox/initialized.rs b/src/hyperlight_host/src/sandbox/initialized.rs index 37ab42084..85db5a42f 100644 --- a/src/hyperlight_host/src/sandbox/initialized.rs +++ b/src/hyperlight_host/src/sandbox/initialized.rs @@ -287,32 +287,8 @@ impl Sandbox { #[cfg(target_os = "linux")] crate::signal_handlers::setup_signal_handlers(&config)?; - // Runtime config for the restored sandbox. `guest_core_dump` - // (crashdump) and `guest_debug_info` (gdb) come from the caller's - // config. `binary_path` stays `None`. `set_up_hypervisor_partition` - // fills `entry_point` from the manager's entry point so crashdumps - // carry the correct `AT_ENTRY`. - #[cfg(any(crashdump, gdb))] - let rt_cfg = crate::sandbox::uninitialized::SandboxRuntimeConfig { - #[cfg(crashdump)] - binary_path: None, - #[cfg(gdb)] - debug_info: config.get_guest_debug_info(), - #[cfg(crashdump)] - guest_core_dump: config.get_guest_core_dump(), - #[cfg(crashdump)] - entry_point: None, - }; - - let mut vm = set_up_hypervisor_partition( - gshm, - &config, - stack_top_gva, - page_size, - #[cfg(any(crashdump, gdb))] - rt_cfg, - load_info, - )?; + let mut vm = + set_up_hypervisor_partition(gshm, &config, stack_top_gva, page_size, load_info)?; let seed = { let mut rng = rand::rng(); @@ -670,14 +646,6 @@ impl Sandbox { self.vm.set_stack_top(snapshot.stack_top_gva()); self.vm.set_next_action(snapshot.next_action()); - // Carry the guest ELF entry point across restore so a later - // crashdump fills `AT_ENTRY` from the restored image. - #[cfg(crashdump)] - { - self.vm - .set_crashdump_entry_point(snapshot.original_entrypoint()); - self.vm.clear_crashdump_binary_path(); - } self.mem_mgr .request_libc_rng_reseed(rand::random::())?; diff --git a/src/hyperlight_host/src/sandbox/uninitialized.rs b/src/hyperlight_host/src/sandbox/uninitialized.rs index 267f87325..bf6e3198b 100644 --- a/src/hyperlight_host/src/sandbox/uninitialized.rs +++ b/src/hyperlight_host/src/sandbox/uninitialized.rs @@ -22,25 +22,6 @@ use crate::mem::shared_mem::{ExclusiveSharedMemory, SharedMemory}; use crate::sandbox::SandboxConfiguration; use crate::{Result, Sandbox, new_error}; -#[cfg(any(crashdump, gdb))] -#[derive(Clone, Debug, Default)] -pub(crate) struct SandboxRuntimeConfig { - #[cfg(crashdump)] - pub(crate) binary_path: Option, - #[cfg(gdb)] - pub(crate) debug_info: Option, - #[cfg(crashdump)] - pub(crate) guest_core_dump: bool, - /// The original entry point address of the loaded guest binary - /// (load_addr + ELF entry offset). Used for AT_ENTRY in core dumps - /// so GDB can compute the correct load offset for PIE binaries. - /// - /// `None` until resolved from the snapshot's `NextAction::Initialise` - /// in `set_up_hypervisor_partition`. - #[cfg(crashdump)] - pub(crate) entry_point: Option, -} - /// A preliminary sandbox that represents allocated memory and registered host functions, /// but has not yet created the underlying virtual machine. /// @@ -58,8 +39,6 @@ pub struct UninitializedSandbox { /// The memory manager for the sandbox. pub(crate) mgr: SandboxMemoryManager, pub(crate) config: SandboxConfiguration, - #[cfg(any(crashdump, gdb))] - pub(crate) rt_cfg: SandboxRuntimeConfig, pub(crate) load_info: crate::mem::exe::LoadInfo, // This is needed to convey the stack pointer between the snapshot // and the HyperlightVm creation @@ -162,11 +141,7 @@ impl UninitializedSandbox { // `InterruptHandler` on Linux. // // This is ok for now as this is not a public function - fn from_snapshot( - snapshot: Arc, - cfg: Option, - #[cfg(crashdump)] binary_path: Option, - ) -> Result { + fn from_snapshot(snapshot: Arc, cfg: Option) -> Result { #[cfg(feature = "build-metadata")] log_build_details(); @@ -176,28 +151,6 @@ impl UninitializedSandbox { let sandbox_cfg = cfg.unwrap_or_default(); - #[cfg(any(crashdump, gdb))] - let rt_cfg = { - #[cfg(crashdump)] - let guest_core_dump = sandbox_cfg.get_guest_core_dump(); - - #[cfg(gdb)] - let debug_info = sandbox_cfg.get_guest_debug_info(); - - SandboxRuntimeConfig { - #[cfg(crashdump)] - binary_path, - #[cfg(gdb)] - debug_info, - #[cfg(crashdump)] - guest_core_dump, - // entry_point is set later in set_up_hypervisor_partition - // once the entrypoint is resolved from the snapshot - #[cfg(crashdump)] - entry_point: None, - } - }; - let mem_mgr_wrapper = SandboxMemoryManager::::from_snapshot(snapshot.as_ref())?; @@ -207,8 +160,6 @@ impl UninitializedSandbox { host_funcs, mgr: mem_mgr_wrapper, config: sandbox_cfg, - #[cfg(any(crashdump, gdb))] - rt_cfg, load_info: snapshot.load_info(), stack_top_gva: snapshot.stack_top_gva(), pending_file_mappings: Vec::new(), @@ -235,19 +186,8 @@ impl UninitializedSandbox { cfg: Option, ) -> Result { let cfg = cfg.unwrap_or_default(); - let env = env.into(); - #[cfg(crashdump)] - let binary_path = match &env.guest_binary { - GuestBinary::FilePath(path) => Some(path.clone()), - GuestBinary::Buffer(_) => None, - }; let snapshot = Snapshot::from_env(env, cfg)?; - Self::from_snapshot( - Arc::new(snapshot), - Some(cfg), - #[cfg(crashdump)] - binary_path, - ) + Self::from_snapshot(Arc::new(snapshot), Some(cfg)) } /// Creates and initializes the virtual machine, transforming this into a ready-to-use sandbox. @@ -1128,22 +1068,12 @@ mod tests { ); // Create first sandbox from snapshot - let sandbox1 = UninitializedSandbox::from_snapshot( - snapshot.clone(), - None, - #[cfg(crashdump)] - Some(binary_path.clone()), - ) - .expect("Failed to create first sandbox from snapshot"); + let sandbox1 = UninitializedSandbox::from_snapshot(snapshot.clone(), None) + .expect("Failed to create first sandbox from snapshot"); // Create second sandbox from same snapshot - let sandbox2 = UninitializedSandbox::from_snapshot( - snapshot.clone(), - None, - #[cfg(crashdump)] - Some(binary_path.clone()), - ) - .expect("Failed to create second sandbox from snapshot"); + let sandbox2 = UninitializedSandbox::from_snapshot(snapshot.clone(), None) + .expect("Failed to create second sandbox from snapshot"); // Both should be able to evolve independently let _evolved1 = sandbox1.evolve().expect("Failed to evolve sandbox1"); @@ -1162,13 +1092,8 @@ mod tests { .expect("Failed to create snapshot with custom heap size"), ); - let sandbox = UninitializedSandbox::from_snapshot( - snapshot, - None, - #[cfg(crashdump)] - Some(binary_path.clone()), - ) - .expect("Failed to create sandbox from snapshot with custom heap"); + let sandbox = UninitializedSandbox::from_snapshot(snapshot, None) + .expect("Failed to create sandbox from snapshot with custom heap"); let _evolved = sandbox.evolve().expect("Failed to evolve sandbox"); } @@ -1185,13 +1110,8 @@ mod tests { .expect("Failed to create snapshot with custom stack size"), ); - let sandbox = UninitializedSandbox::from_snapshot( - snapshot, - None, - #[cfg(crashdump)] - Some(binary_path.clone()), - ) - .expect("Failed to create sandbox from snapshot with custom stack"); + let sandbox = UninitializedSandbox::from_snapshot(snapshot, None) + .expect("Failed to create sandbox from snapshot with custom stack"); let _evolved = sandbox.evolve().expect("Failed to evolve sandbox"); } @@ -1210,27 +1130,12 @@ mod tests { ); // Create multiple sandboxes from the same snapshot - let sandbox1 = UninitializedSandbox::from_snapshot( - snapshot.clone(), - None, - #[cfg(crashdump)] - Some(binary_path.clone()), - ) - .expect("Failed to create sandbox1 from fully customized snapshot"); - let sandbox2 = UninitializedSandbox::from_snapshot( - snapshot.clone(), - None, - #[cfg(crashdump)] - Some(binary_path.clone()), - ) - .expect("Failed to create sandbox2 from fully customized snapshot"); - let sandbox3 = UninitializedSandbox::from_snapshot( - snapshot.clone(), - None, - #[cfg(crashdump)] - Some(binary_path.clone()), - ) - .expect("Failed to create sandbox3 from fully customized snapshot"); + let sandbox1 = UninitializedSandbox::from_snapshot(snapshot.clone(), None) + .expect("Failed to create sandbox1 from fully customized snapshot"); + let sandbox2 = UninitializedSandbox::from_snapshot(snapshot.clone(), None) + .expect("Failed to create sandbox2 from fully customized snapshot"); + let sandbox3 = UninitializedSandbox::from_snapshot(snapshot.clone(), None) + .expect("Failed to create sandbox3 from fully customized snapshot"); let _evolved1 = sandbox1.evolve().expect("Failed to evolve sandbox1"); let _evolved2 = sandbox2.evolve().expect("Failed to evolve sandbox2"); @@ -1246,13 +1151,8 @@ mod tests { .expect("Failed to create snapshot from buffer"), ); - let sandbox = UninitializedSandbox::from_snapshot( - snapshot, - None, - #[cfg(crashdump)] - None, - ) - .expect("Failed to create sandbox from buffer-based snapshot"); + let sandbox = UninitializedSandbox::from_snapshot(snapshot, None) + .expect("Failed to create sandbox from buffer-based snapshot"); let _evolved = sandbox.evolve().expect("Failed to evolve sandbox"); } @@ -1265,13 +1165,8 @@ mod tests { Snapshot::from_env(env, Default::default()).expect("Failed to create snapshot"), ); - let mut sandbox = UninitializedSandbox::from_snapshot( - snapshot, - None, - #[cfg(crashdump)] - Some(binary_path.clone()), - ) - .expect("Failed to create sandbox from snapshot"); + let mut sandbox = UninitializedSandbox::from_snapshot(snapshot, None) + .expect("Failed to create sandbox from snapshot"); // Register a custom host function sandbox @@ -1307,13 +1202,8 @@ mod tests { .expect("Failed to create snapshot with init data"), ); - let sandbox = UninitializedSandbox::from_snapshot( - snapshot, - None, - #[cfg(crashdump)] - Some(binary_path.clone()), - ) - .expect("Failed to create sandbox from snapshot with init data"); + let sandbox = UninitializedSandbox::from_snapshot(snapshot, None) + .expect("Failed to create sandbox from snapshot with init data"); let _evolved = sandbox.evolve().expect("Failed to evolve sandbox"); } @@ -1325,26 +1215,16 @@ mod tests { Snapshot::from_env(env, Default::default()) .expect("Failed to create snapshot with default config"), ); - let orig_sandbox = UninitializedSandbox::from_snapshot( - orig_snapshot, - None, - #[cfg(crashdump)] - Some(binary_path.clone()), - ) - .expect("Failed to create orig_sandbox"); + let orig_sandbox = UninitializedSandbox::from_snapshot(orig_snapshot, None) + .expect("Failed to create orig_sandbox"); let mut initialized_sandbox = orig_sandbox .evolve() .expect("Failed to evolve orig_sandbox"); let new_snapshot = initialized_sandbox .snapshot() .expect("Failed to create new_snapshot"); - let new_sandbox = UninitializedSandbox::from_snapshot( - new_snapshot, - None, - #[cfg(crashdump)] - Some(binary_path.clone()), - ) - .expect("Failed to create new_sandbox"); + let new_sandbox = UninitializedSandbox::from_snapshot(new_snapshot, None) + .expect("Failed to create new_sandbox"); let _evolved = new_sandbox.evolve().expect("Failed to evolve new_sandbox"); } } diff --git a/src/hyperlight_host/src/sandbox/uninitialized_evolve.rs b/src/hyperlight_host/src/sandbox/uninitialized_evolve.rs index 5cfcddd6b..8668b8f83 100644 --- a/src/hyperlight_host/src/sandbox/uninitialized_evolve.rs +++ b/src/hyperlight_host/src/sandbox/uninitialized_evolve.rs @@ -5,8 +5,6 @@ use tracing::{Span, instrument}; use super::SandboxConfiguration; use super::snapshot::NextAction; -#[cfg(any(crashdump, gdb))] -use super::uninitialized::SandboxRuntimeConfig; use crate::hypervisor::hyperlight_vm::{HyperlightVm, HyperlightVmError}; use crate::mem::exe::LoadInfo; use crate::mem::mgr::SandboxMemoryManager; @@ -35,8 +33,6 @@ pub(super) fn initialize_sandbox(u_sbox: UninitializedSandbox) -> Result Result { // Create gdb thread if gdb is enabled and the configuration is provided #[cfg(gdb)] - let gdb_conn = if let Some(DebugInfo { port }) = rt_cfg.debug_info { + let gdb_conn = if let Some(DebugInfo { port }) = config.get_guest_debug_info() { use crate::hypervisor::gdb::create_gdb_thread; let gdb_conn = create_gdb_thread(port); @@ -133,21 +128,6 @@ pub(crate) fn set_up_hypervisor_partition( #[cfg(feature = "mem_profile")] let trace_info = MemTraceInfo::new(_load_info.info)?; - // Store the original entry point address in the runtime config for core dumps. - // This is needed because `next_action` transitions from `Initialise(addr)` to - // `Call(dispatch_addr)` after guest initialisation, losing the original value - // that GDB needs to compute the PIE binary's load offset. The manager carries - // it across that transition (and across snapshot save/restore), so it is - // correct for both the evolve path and `Sandbox::from_snapshot`. - #[cfg(crashdump)] - let rt_cfg = { - let mut rt_cfg = rt_cfg; - if mgr.original_entrypoint != 0 { - rt_cfg.entry_point = Some(mgr.original_entrypoint); - } - rt_cfg - }; - Ok(HyperlightVm::new( mgr.shared_mem, mgr.scratch_mem, @@ -158,8 +138,6 @@ pub(crate) fn set_up_hypervisor_partition( config, #[cfg(gdb)] gdb_conn, - #[cfg(crashdump)] - rt_cfg, #[cfg(feature = "mem_profile")] trace_info, )