Skip to content

Commit 5c02687

Browse files
committed
Remove old code
Signed-off-by: Ludvig Liljenberg <[email protected]>
1 parent f154d8e commit 5c02687

File tree

4 files changed

+1
-98
lines changed

4 files changed

+1
-98
lines changed

src/hyperlight_host/src/mem/layout.rs

Lines changed: 1 addition & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -385,24 +385,6 @@ impl SandboxMemoryLayout {
385385
self.stack_size
386386
}
387387

388-
/// Get the offset in guest memory to the OutB pointer.
389-
#[instrument(skip_all, parent = Span::current(), level= "Trace")]
390-
#[allow(dead_code)]
391-
pub(super) fn get_outb_pointer_offset(&self) -> usize {
392-
// The outb pointer is immediately after the code pointer
393-
// in the `CodeAndOutBPointers` struct which is a u64
394-
self.peb_code_pointer_offset + size_of::<u64>()
395-
}
396-
397-
/// Get the offset in guest memory to the OutB context.
398-
#[instrument(skip_all, parent = Span::current(), level= "Trace")]
399-
#[allow(dead_code)]
400-
pub(super) fn get_outb_context_offset(&self) -> usize {
401-
// The outb context is immediately after the outb pointer
402-
// in the `CodeAndOutBPointers` struct which is a u64
403-
self.get_outb_pointer_offset() + size_of::<u64>()
404-
}
405-
406388
/// Get the offset in guest memory to the output data pointer.
407389
#[instrument(skip_all, parent = Span::current(), level= "Trace")]
408390
fn get_output_data_pointer_offset(&self) -> usize {
@@ -424,7 +406,7 @@ impl SandboxMemoryLayout {
424406
/// This function exists to accommodate the macro that generates C API
425407
/// compatible functions.
426408
#[instrument(skip_all, parent = Span::current(), level= "Trace")]
427-
#[allow(dead_code)]
409+
#[cfg(test)]
428410
pub(crate) fn get_output_data_offset(&self) -> usize {
429411
self.output_data_buffer_offset
430412
}
@@ -459,13 +441,6 @@ impl SandboxMemoryLayout {
459441
self.peb_guest_dispatch_function_ptr_offset
460442
}
461443

462-
/// Get the offset in guest memory to the PEB address
463-
#[instrument(skip_all, parent = Span::current(), level= "Trace")]
464-
#[allow(dead_code)]
465-
pub(super) fn get_in_process_peb_offset(&self) -> usize {
466-
self.peb_offset
467-
}
468-
469444
/// Get the offset in guest memory to the heap size
470445
#[instrument(skip_all, parent = Span::current(), level= "Trace")]
471446
fn get_heap_size_offset(&self) -> usize {
@@ -494,13 +469,6 @@ impl SandboxMemoryLayout {
494469
self.get_min_guest_stack_address_offset() + size_of::<u64>()
495470
}
496471

497-
/// Get the offset to the guest guard page
498-
#[instrument(skip_all, parent = Span::current(), level= "Trace")]
499-
#[allow(dead_code)]
500-
pub fn get_guard_page_offset(&self) -> usize {
501-
self.guard_page_offset
502-
}
503-
504472
/// Get the total size of guest memory in `self`'s memory
505473
/// layout.
506474
#[instrument(skip_all, parent = Span::current(), level= "Trace")]

src/hyperlight_host/src/mem/mgr.rs

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -281,21 +281,6 @@ where
281281
snapshot.restore_from_snapshot(&mut self.shared_mem)?;
282282
Ok(())
283283
}
284-
285-
/// Sets `addr` to the correct offset in the memory referenced by
286-
/// `shared_mem` to indicate the address of the outb pointer and context
287-
/// for calling outb function
288-
#[instrument(err(Debug), skip_all, parent = Span::current(), level= "Trace")]
289-
#[allow(dead_code)]
290-
pub(crate) fn set_outb_address_and_context(&mut self, addr: u64, context: u64) -> Result<()> {
291-
let pointer_offset = self.layout.get_outb_pointer_offset();
292-
let context_offset = self.layout.get_outb_context_offset();
293-
self.shared_mem.with_exclusivity(|excl| -> Result<()> {
294-
excl.write_u64(pointer_offset, addr)?;
295-
excl.write_u64(context_offset, context)?;
296-
Ok(())
297-
})?
298-
}
299284
}
300285

301286
impl SandboxMemoryManager<ExclusiveSharedMemory> {

src/hyperlight_host/src/mem/shared_mem.rs

Lines changed: 0 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -502,46 +502,6 @@ impl ExclusiveSharedMemory {
502502
})
503503
}
504504

505-
#[allow(dead_code)]
506-
pub(super) fn make_memory_executable(&self) -> Result<()> {
507-
#[cfg(target_os = "windows")]
508-
{
509-
let mut _old_flags = PAGE_PROTECTION_FLAGS::default();
510-
if let Err(e) = unsafe {
511-
VirtualProtect(
512-
self.region.ptr as *const c_void,
513-
self.region.size,
514-
PAGE_EXECUTE_READWRITE,
515-
&mut _old_flags as *mut PAGE_PROTECTION_FLAGS,
516-
)
517-
} {
518-
log_then_return!(WindowsAPIError(e.clone()));
519-
}
520-
}
521-
522-
// make the memory executable on Linux
523-
#[cfg(target_os = "linux")]
524-
{
525-
use libc::{PROT_EXEC, PROT_READ, PROT_WRITE, mprotect};
526-
527-
let res = unsafe {
528-
mprotect(
529-
self.region.ptr as *mut c_void,
530-
self.region.size,
531-
PROT_READ | PROT_WRITE | PROT_EXEC,
532-
)
533-
};
534-
535-
if res != 0 {
536-
return Err(new_error!(
537-
"Failed to make memory executable: {:#?}",
538-
Error::last_os_error().raw_os_error()
539-
));
540-
}
541-
}
542-
Ok(())
543-
}
544-
545505
/// Internal helper method to get the backing memory as a mutable slice.
546506
///
547507
/// # Safety
@@ -614,15 +574,6 @@ impl ExclusiveSharedMemory {
614574
Ok(())
615575
}
616576

617-
/// Return the address of memory at an offset to this `SharedMemory` checking
618-
/// that the memory is within the bounds of the `SharedMemory`.
619-
#[instrument(err(Debug), skip_all, parent = Span::current(), level= "Trace")]
620-
#[allow(dead_code)]
621-
pub(crate) fn calculate_address(&self, offset: usize) -> Result<usize> {
622-
bounds_check!(offset, 0, self.mem_size());
623-
Ok(self.base_addr() + offset)
624-
}
625-
626577
generate_reader!(read_u8, u8);
627578
generate_reader!(read_i8, i8);
628579
generate_reader!(read_u16, u16);

src/hyperlight_host/src/sandbox/initialized_multi_use.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,6 @@ impl MultiUseSandbox {
333333
/// Map the contents of a file into the guest at a particular address
334334
///
335335
/// Returns the length of the mapping in bytes.
336-
#[allow(dead_code)]
337336
#[instrument(err(Debug), skip(self, _fp, _guest_base), parent = Span::current())]
338337
pub fn map_file_cow(&mut self, _fp: &Path, _guest_base: u64) -> Result<u64> {
339338
#[cfg(windows)]

0 commit comments

Comments
 (0)