Skip to content

Commit a862d4a

Browse files
authored
Remove support from hyperlight_host for PE formatted guests (#485)
Signed-off-by: Simon Davies <simongdavies@users.noreply.github.com>
1 parent e99716a commit a862d4a

File tree

16 files changed

+17
-1195
lines changed

16 files changed

+17
-1195
lines changed

src/hyperlight_host/src/error.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -98,10 +98,6 @@ pub enum HyperlightError {
9898
#[error("Guest aborted: {0} {1}")]
9999
GuestAborted(u8, String),
100100

101-
///Cannot run from guest binary unless the binary is a file
102-
#[error("Cannot run from guest binary when guest binary is a buffer")]
103-
GuestBinaryShouldBeAFile(),
104-
105101
/// Guest call resulted in error in guest
106102
#[error("Guest error occurred {0:?}: {1}")]
107103
GuestError(ErrorCode, String),

src/hyperlight_host/src/func/guest_dispatch.rs

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

352-
#[test]
353-
#[cfg(all(target_os = "windows", inprocess))]
354-
fn test_call_guest_function_by_name_in_proc_load_lib() {
355-
use hyperlight_testing::simple_guest_exe_as_string;
356-
357-
let u_sbox = UninitializedSandbox::new(
358-
GuestBinary::FilePath(simple_guest_exe_as_string().expect("Guest Exe Missing")),
359-
None,
360-
Some(crate::SandboxRunOptions::RunInProcess(true)),
361-
None,
362-
)
363-
.unwrap();
364-
test_call_guest_function_by_name(u_sbox);
365-
}
366-
367352
#[test]
368353
#[cfg(inprocess)]
369354
fn test_call_guest_function_by_name_in_proc_manual() {

src/hyperlight_host/src/mem/exe.rs

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@ use std::io::Read;
1919
use std::vec::Vec;
2020

2121
use super::elf::ElfInfo;
22-
use super::pe::headers::PEHeaders;
23-
use super::pe::pe_info::PEInfo;
2422
use super::ptr_offset::Offset;
2523
use crate::Result;
2624

@@ -29,7 +27,6 @@ use crate::Result;
2927
// cost of an indirection.
3028
#[allow(clippy::large_enum_variant)]
3129
pub enum ExeInfo {
32-
PE(PEInfo),
3330
Elf(ElfInfo),
3431
}
3532

@@ -48,31 +45,25 @@ impl ExeInfo {
4845
Self::from_buf(&contents)
4946
}
5047
pub fn from_buf(buf: &[u8]) -> Result<Self> {
51-
PEInfo::new(buf)
52-
.map(ExeInfo::PE)
53-
.or_else(|_| ElfInfo::new(buf).map(ExeInfo::Elf))
48+
ElfInfo::new(buf).map(ExeInfo::Elf)
5449
}
5550
pub fn stack_reserve(&self) -> u64 {
5651
match self {
57-
ExeInfo::PE(pe) => pe.stack_reserve(),
5852
ExeInfo::Elf(_) => DEFAULT_ELF_STACK_RESERVE,
5953
}
6054
}
6155
pub fn heap_reserve(&self) -> u64 {
6256
match self {
63-
ExeInfo::PE(pe) => pe.heap_reserve(),
6457
ExeInfo::Elf(_) => DEFAULT_ELF_HEAP_RESERVE,
6558
}
6659
}
6760
pub fn entrypoint(&self) -> Offset {
6861
match self {
69-
ExeInfo::PE(pe) => Offset::from(PEHeaders::from(pe).entrypoint_offset),
7062
ExeInfo::Elf(elf) => Offset::from(elf.entrypoint_va()),
7163
}
7264
}
7365
pub fn loaded_size(&self) -> usize {
7466
match self {
75-
ExeInfo::PE(pe) => pe.payload.len(),
7667
ExeInfo::Elf(elf) => elf.get_va_size(),
7768
}
7869
}
@@ -82,11 +73,6 @@ impl ExeInfo {
8273
// which requires it to be &mut.
8374
pub fn load(&mut self, load_addr: usize, target: &mut [u8]) -> Result<()> {
8475
match self {
85-
ExeInfo::PE(pe) => {
86-
let patches = pe.get_exe_relocation_patches(load_addr)?;
87-
pe.apply_relocation_patches(patches)?;
88-
target[0..pe.payload.len()].copy_from_slice(&pe.payload);
89-
}
9076
ExeInfo::Elf(elf) => {
9177
elf.load_at(load_addr, target)?;
9278
}

src/hyperlight_host/src/mem/loaded_lib.rs

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

0 commit comments

Comments
 (0)