Skip to content

Commit 1fe6ac4

Browse files
committed
[guest,host,common] removed uneeded entrypoint arg
Removed an uneeded entrypoint argument for the size of the PEB structure, which was a re-use of the ops argument in dev that is also unused. + cleaned up some TODOs (better error messages for unwraps and uneeded host fxn details section). Signed-off-by: danbugs <[email protected]>
1 parent 63e3c69 commit 1fe6ac4

File tree

12 files changed

+13
-49
lines changed

12 files changed

+13
-49
lines changed

src/hyperlight_common/src/outb.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,5 @@ pub fn outb(port: u16, value: u8) {
5959
panic!("Tried to call outb in invalid runmode");
6060
}
6161
}
62-
63-
// TODO(danbugs:297): bring back
64-
// check_for_host_error();
6562
}
6663
}

src/hyperlight_guest/src/entrypoint.rs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -73,13 +73,7 @@ static INIT: Once = Once::new();
7373
// Note: entrypoint cannot currently have a stackframe >4KB, as that will invoke __chkstk on msvc
7474
// target without first having setup global `RUNNING_MODE` variable, which __chkstk relies on.
7575
#[no_mangle]
76-
pub extern "win64" fn entrypoint(
77-
peb_address: u64,
78-
// TODO(danbugs:297): remove the extra arg
79-
_: u64,
80-
seed: u64,
81-
max_log_level: u64,
82-
) {
76+
pub extern "win64" fn entrypoint(peb_address: u64, seed: u64, max_log_level: u64) {
8377
INIT.call_once(|| unsafe {
8478
PEB = peb_address as *mut HyperlightPEB;
8579
RUNNING_MODE = (*PEB).clone().run_mode;

src/hyperlight_host/src/hypervisor/hyperv_linux.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -461,7 +461,6 @@ impl Hypervisor for HypervLinuxDriver {
461461
fn initialise(
462462
&mut self,
463463
hyperlight_peb_guest_memory_region_address: u64,
464-
hyperlight_peb_guest_memory_region_size: u64,
465464
seed: u64,
466465
outb_hdl: OutBHandlerWrapper,
467466
mem_access_hdl: MemAccessHandlerWrapper,
@@ -481,9 +480,8 @@ impl Hypervisor for HypervLinuxDriver {
481480

482481
// function args
483482
rcx: hyperlight_peb_guest_memory_region_address,
484-
rdx: hyperlight_peb_guest_memory_region_size,
485-
r8: seed,
486-
r9: max_guest_log_level,
483+
rdx: seed,
484+
r8: max_guest_log_level,
487485

488486
..Default::default()
489487
};

src/hyperlight_host/src/hypervisor/hypervisor_handler.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,6 @@ struct HvHandlerCommChannels {
182182
#[derive(Clone)]
183183
pub(crate) struct HvHandlerConfig {
184184
pub(crate) hyperlight_peb_guest_memory_region_address: u64,
185-
pub(crate) hyperlight_peb_guest_memory_region_size: u64,
186185
pub(crate) seed: u64,
187186
pub(crate) max_init_time: Duration,
188187
pub(crate) max_exec_time: Duration,
@@ -353,7 +352,6 @@ impl HypervisorHandler {
353352

354353
let res = hv.initialise(
355354
configuration.hyperlight_peb_guest_memory_region_address,
356-
configuration.hyperlight_peb_guest_memory_region_size,
357355
configuration.seed,
358356
configuration.outb_handler.clone(),
359357
configuration.mem_access_handler.clone(),
@@ -844,9 +842,10 @@ fn set_up_hypervisor_partition(
844842

845843
let rsp_ptr = GuestPtr::try_from(RawPtr::from(mgr.init_rsp))?;
846844

847-
// TODO(danbugs:297): change unwrap to proper error handling informing paging isn't set up.
848845
let pml4_ptr = GuestPtr::try_from(Offset::from(
849-
mgr.memory_sections.get_paging_structures_offset().unwrap() as u64,
846+
mgr.memory_sections
847+
.get_paging_structures_offset()
848+
.ok_or("PML4 offset not found")? as u64,
850849
))?;
851850
let entrypoint_ptr = {
852851
let entrypoint_total_offset = mgr.load_addr.clone() + mgr.entrypoint_offset;

src/hyperlight_host/src/hypervisor/kvm.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -404,7 +404,6 @@ impl Hypervisor for KVMDriver {
404404
fn initialise(
405405
&mut self,
406406
hyperlight_peb_guest_memory_region_address: u64,
407-
hyperlight_peb_guest_memory_region_size: u64,
408407
seed: u64,
409408
outb_hdl: OutBHandlerWrapper,
410409
mem_access_hdl: MemAccessHandlerWrapper,
@@ -423,9 +422,8 @@ impl Hypervisor for KVMDriver {
423422

424423
// function args
425424
rcx: hyperlight_peb_guest_memory_region_address,
426-
rdx: hyperlight_peb_guest_memory_region_size,
427-
r8: seed,
428-
r9: max_guest_log_level,
425+
rdx: seed,
426+
r8: max_guest_log_level,
429427

430428
..Default::default()
431429
};

src/hyperlight_host/src/hypervisor/mod.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,6 @@ pub(crate) trait Hypervisor: Debug + Sync + Send {
127127
fn initialise(
128128
&mut self,
129129
hyperlight_peb_guest_memory_region_address: u64,
130-
hyperlight_peb_guest_memory_region_size: u64,
131130
seed: u64,
132131
outb_hdl: OutBHandlerWrapper,
133132
mem_access_fn: MemAccessHandlerWrapper,

src/hyperlight_host/src/mem/mgr.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,8 +139,10 @@ where
139139
let memory_sections = self.memory_sections.clone();
140140

141141
self.shared_mem.with_exclusivity(|shared_mem| {
142-
// TODO(danbugs:297): improve error message removing unwrap
143-
let pml4_offset = self.memory_sections.get_paging_structures_offset().unwrap();
142+
let pml4_offset = self
143+
.memory_sections
144+
.get_paging_structures_offset()
145+
.ok_or("PML4 offset not found")?;
144146
let pdpt_offset = pml4_offset + PDPT_OFFSET;
145147
let pd_offset = pml4_offset + PD_OFFSET;
146148
let pt_offset = pml4_offset + PT_OFFSET;

src/hyperlight_host/src/sandbox/host_funcs.rs

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -143,17 +143,6 @@ fn register_host_function_helper(
143143
.get_host_func_details_mut()
144144
.sort_host_functions_by_name();
145145

146-
// TODO(danbugs:297): host function details section is now determined in the guest, so
147-
// we can't write these details to memory at this point in time. Regardless, writing this
148-
// stuff to memory is pretty pointless, so we can remove this logic.
149-
// let buffer: Vec<u8> = self_.get_host_func_details().try_into().map_err(|e| {
150-
// new_error!(
151-
// "Error serializing host function details to flatbuffer: {}",
152-
// e
153-
// )
154-
// })?;
155-
// mgr.write_buffer_host_function_details(&buffer)?;
156-
157146
Ok(())
158147
}
159148

src/hyperlight_host/src/sandbox/sandbox_builder.rs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -85,13 +85,6 @@ impl SandboxMemorySections {
8585
.map(|(_, section)| section.host_address.unwrap())
8686
}
8787

88-
pub(crate) fn get_hyperlight_peb_size(&self) -> Option<usize> {
89-
self.sections
90-
.iter()
91-
.find(|(_, section)| section.name == DEFAULT_HYPERLIGHT_PEB_SECTION_NAME)
92-
.map(|(_, section)| section.page_aligned_size)
93-
}
94-
9588
pub(crate) fn get_tmp_stack_section_offset(&self) -> Option<usize> {
9689
self.sections
9790
.iter()

src/hyperlight_host/src/sandbox/uninitialized.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,6 @@ impl UninitializedSandbox {
8484
config: SandboxConfiguration,
8585
#[cfg(gdb)] debug_info: Option<DebugInfo>,
8686
) -> Self {
87-
// TODO(danbugs:297): add registering writer function to SandboxBuilder w/ syscalls and whatnot
8887
Self {
8988
host_funcs: Arc::new(Mutex::new(HostFuncsWrapper::default())),
9089
mem_mgr,

0 commit comments

Comments
 (0)