Skip to content

Commit 439af32

Browse files
committed
Remove Sandbox trait
Signed-off-by: Jorge Prendes <jorge.prendes@gmail.com>
1 parent 976c7d0 commit 439af32

File tree

6 files changed

+3
-114
lines changed

6 files changed

+3
-114
lines changed

src/hyperlight_host/src/lib.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,6 @@ pub mod metrics;
5858
/// outside this file. Types from this module needed for public consumption are
5959
/// re-exported below.
6060
pub mod sandbox;
61-
/// `trait`s and other functionality for dealing with defining sandbox
62-
/// states and moving between them
63-
pub mod sandbox_state;
6461
#[cfg(all(feature = "seccomp", target_os = "linux"))]
6562
pub(crate) mod seccomp;
6663
/// Signal handling for Linux

src/hyperlight_host/src/sandbox/initialized_multi_use.rs

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ use crate::mem::memory_region::{MemoryRegion, MemoryRegionFlags};
4242
use crate::mem::ptr::RawPtr;
4343
use crate::mem::shared_mem::HostSharedMemory;
4444
use crate::metrics::maybe_time_and_emit_guest_call;
45-
use crate::sandbox_state::sandbox::Sandbox;
4645
use crate::{HyperlightError, Result, log_then_return};
4746

4847
/// A sandbox that supports being used Multiple times.
@@ -241,7 +240,7 @@ impl MultiUseSandbox {
241240
self.dbg_mem_access_fn.clone(),
242241
)?;
243242

244-
self.check_stack_guard()?;
243+
self.mem_mgr.check_stack_guard()?;
245244
check_for_guest_error(self.get_mgr_wrapper_mut())?;
246245

247246
self.get_mgr_wrapper_mut()
@@ -277,12 +276,6 @@ impl WrapperGetter for MultiUseSandbox {
277276
}
278277
}
279278

280-
impl Sandbox for MultiUseSandbox {
281-
fn check_stack_guard(&self) -> Result<bool> {
282-
self.mem_mgr.check_stack_guard()
283-
}
284-
}
285-
286279
impl std::fmt::Debug for MultiUseSandbox {
287280
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
288281
f.debug_struct("MultiUseSandbox")

src/hyperlight_host/src/sandbox/uninitialized.rs

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ use crate::mem::memory_region::{DEFAULT_GUEST_BLOB_MEM_FLAGS, MemoryRegionFlags}
3434
use crate::mem::mgr::{STACK_COOKIE_LEN, SandboxMemoryManager};
3535
use crate::mem::shared_mem::ExclusiveSharedMemory;
3636
use crate::sandbox::SandboxConfiguration;
37-
use crate::{MultiUseSandbox, Result, log_then_return, new_error};
37+
use crate::{MultiUseSandbox, Result, new_error};
3838

3939
#[cfg(all(target_os = "linux", feature = "seccomp"))]
4040
const EXTRA_ALLOWED_SYSCALLS_FOR_WRITER_FUNC: &[super::ExtraAllowedSyscall] = &[
@@ -80,18 +80,6 @@ pub struct UninitializedSandbox {
8080
pub(crate) rt_cfg: SandboxRuntimeConfig,
8181
}
8282

83-
impl crate::sandbox_state::sandbox::UninitializedSandbox for UninitializedSandbox {
84-
#[instrument(skip_all, parent = Span::current(), level = "Trace")]
85-
fn get_uninitialized_sandbox(&self) -> &crate::sandbox::UninitializedSandbox {
86-
self
87-
}
88-
89-
#[instrument(skip_all, parent = Span::current(), level = "Trace")]
90-
fn get_uninitialized_sandbox_mut(&mut self) -> &mut crate::sandbox::UninitializedSandbox {
91-
self
92-
}
93-
}
94-
9583
impl Debug for UninitializedSandbox {
9684
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
9785
f.debug_struct("UninitializedSandbox")
@@ -100,14 +88,6 @@ impl Debug for UninitializedSandbox {
10088
}
10189
}
10290

103-
impl crate::sandbox_state::sandbox::Sandbox for UninitializedSandbox {
104-
fn check_stack_guard(&self) -> Result<bool> {
105-
log_then_return!(
106-
"Checking the stack cookie before the sandbox is initialized is unsupported"
107-
);
108-
}
109-
}
110-
11191
impl UninitializedSandbox {
11292
/// Evolve `self` to a `MultiUseSandbox` without any additional metadata.
11393
#[instrument(err(Debug), skip_all, parent = Span::current(), level = "Trace")]

src/hyperlight_host/src/sandbox/uninitialized_evolve.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ use crate::sandbox::host_funcs::FunctionRegistry;
4141
use crate::sandbox::mem_access::mem_access_handler_wrapper;
4242
use crate::sandbox::outb::outb_handler_wrapper;
4343
use crate::sandbox::{HostSharedMemory, MemMgrWrapper};
44-
use crate::sandbox_state::sandbox::Sandbox;
4544
#[cfg(target_os = "linux")]
4645
use crate::signal_handlers::setup_signal_handlers;
4746
use crate::{MultiUseSandbox, Result, UninitializedSandbox, log_then_return, new_error};
@@ -58,7 +57,7 @@ use crate::{MultiUseSandbox, Result, UninitializedSandbox, log_then_return, new_
5857
/// If this doesn't make sense, and you want to change this type,
5958
/// please reach out to a Hyperlight developer before making the change.
6059
#[instrument(err(Debug), skip_all, , parent = Span::current(), level = "Trace")]
61-
fn evolve_impl<TransformFunc, ResSandbox: Sandbox>(
60+
fn evolve_impl<TransformFunc, ResSandbox>(
6261
u_sbox: UninitializedSandbox,
6362
transform: TransformFunc,
6463
) -> Result<ResSandbox>

src/hyperlight_host/src/sandbox_state/mod.rs

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

src/hyperlight_host/src/sandbox_state/sandbox.rs

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

0 commit comments

Comments
 (0)