Skip to content

Commit dac884e

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 0a4d104 commit dac884e

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
@@ -456,7 +456,6 @@ impl Hypervisor for HypervLinuxDriver {
456456
fn initialise(
457457
&mut self,
458458
hyperlight_peb_guest_memory_region_address: u64,
459-
hyperlight_peb_guest_memory_region_size: u64,
460459
seed: u64,
461460
outb_hdl: OutBHandlerWrapper,
462461
mem_access_hdl: MemAccessHandlerWrapper,
@@ -476,9 +475,8 @@ impl Hypervisor for HypervLinuxDriver {
476475

477476
// function args
478477
rcx: hyperlight_peb_guest_memory_region_address,
479-
rdx: hyperlight_peb_guest_memory_region_size,
480-
r8: seed,
481-
r9: max_guest_log_level,
478+
rdx: seed,
479+
r8: max_guest_log_level,
482480

483481
..Default::default()
484482
};

src/hyperlight_host/src/hypervisor/hypervisor_handler.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,6 @@ struct HvHandlerCommChannels {
178178
#[derive(Clone)]
179179
pub(crate) struct HvHandlerConfig {
180180
pub(crate) hyperlight_peb_guest_memory_region_address: u64,
181-
pub(crate) hyperlight_peb_guest_memory_region_size: u64,
182181
pub(crate) seed: u64,
183182
pub(crate) max_init_time: Duration,
184183
pub(crate) max_exec_time: Duration,
@@ -349,7 +348,6 @@ impl HypervisorHandler {
349348

350349
let res = hv.initialise(
351350
configuration.hyperlight_peb_guest_memory_region_address,
352-
configuration.hyperlight_peb_guest_memory_region_size,
353351
configuration.seed,
354352
configuration.outb_handler.clone(),
355353
configuration.mem_access_handler.clone(),
@@ -824,9 +822,10 @@ fn set_up_hypervisor_partition(
824822

825823
let rsp_ptr = GuestPtr::try_from(RawPtr::from(mgr.init_rsp))?;
826824

827-
// TODO(danbugs:297): change unwrap to proper error handling informing paging isn't set up.
828825
let pml4_ptr = GuestPtr::try_from(Offset::from(
829-
mgr.memory_sections.get_paging_structures_offset().unwrap() as u64,
826+
mgr.memory_sections
827+
.get_paging_structures_offset()
828+
.ok_or("PML4 offset not found")? as u64,
830829
))?;
831830
let entrypoint_ptr = {
832831
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
@@ -125,7 +125,6 @@ pub(crate) trait Hypervisor: Debug + Sync + Send {
125125
fn initialise(
126126
&mut self,
127127
hyperlight_peb_guest_memory_region_address: u64,
128-
hyperlight_peb_guest_memory_region_size: u64,
129128
seed: u64,
130129
outb_hdl: OutBHandlerWrapper,
131130
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)