@@ -35,8 +35,6 @@ limitations under the License.
3535//! +-------------------------------------------+
3636//! | Input Data |
3737//! +-------------------------------------------+
38- //! | Host Function Definitions |
39- //! +-------------------------------------------+
4038//! | PEB Struct | (HyperlightPEB size)
4139//! +-------------------------------------------+
4240//! | Guest Code |
@@ -73,14 +71,14 @@ limitations under the License.
7371use std:: fmt:: Debug ;
7472use std:: mem:: { offset_of, size_of} ;
7573
76- use hyperlight_common:: mem:: { GuestMemoryRegion , HyperlightPEB , PAGE_SIZE_USIZE } ;
74+ use hyperlight_common:: mem:: { GuestStack , HyperlightPEB , PAGE_SIZE_USIZE } ;
7775use rand:: { RngCore , rng} ;
7876use tracing:: { Span , instrument} ;
7977
8078#[ cfg( feature = "init-paging" ) ]
8179use super :: memory_region:: MemoryRegionType :: PageTables ;
8280use super :: memory_region:: MemoryRegionType :: {
83- Code , GuardPage , Heap , HostFunctionDefinitions , InitData , InputData , OutputData , Peb , Stack ,
81+ Code , GuardPage , Heap , InitData , InputData , OutputData , Peb , Stack ,
8482} ;
8583use super :: memory_region:: {
8684 DEFAULT_GUEST_BLOB_MEM_FLAGS , MemoryRegion , MemoryRegion_ , MemoryRegionFlags , MemoryRegionKind ,
@@ -105,7 +103,6 @@ pub(crate) struct SandboxMemoryLayout {
105103 peb_offset : usize ,
106104 peb_security_cookie_seed_offset : usize ,
107105 peb_guest_dispatch_function_ptr_offset : usize , // set by guest in guest entrypoint
108- pub ( super ) peb_host_function_definitions_offset : usize ,
109106 peb_input_data_offset : usize ,
110107 peb_output_data_offset : usize ,
111108 peb_init_data_offset : usize ,
@@ -114,7 +111,6 @@ pub(crate) struct SandboxMemoryLayout {
114111
115112 // The following are the actual values
116113 // that are written to the PEB struct
117- pub ( crate ) host_function_definitions_buffer_offset : usize ,
118114 pub ( super ) input_data_buffer_offset : usize ,
119115 pub ( super ) output_data_buffer_offset : usize ,
120116 guest_heap_buffer_offset : usize ,
@@ -156,10 +152,6 @@ impl Debug for SandboxMemoryLayout {
156152 "Guest Dispatch Function Pointer Offset" ,
157153 & format_args ! ( "{:#x}" , self . peb_guest_dispatch_function_ptr_offset) ,
158154 )
159- . field (
160- "Host Function Definitions Offset" ,
161- & format_args ! ( "{:#x}" , self . peb_host_function_definitions_offset) ,
162- )
163155 . field (
164156 "Input Data Offset" ,
165157 & format_args ! ( "{:#x}" , self . peb_input_data_offset) ,
@@ -180,10 +172,6 @@ impl Debug for SandboxMemoryLayout {
180172 "Guest Stack Offset" ,
181173 & format_args ! ( "{:#x}" , self . peb_guest_stack_data_offset) ,
182174 )
183- . field (
184- "Host Function Definitions Buffer Offset" ,
185- & format_args ! ( "{:#x}" , self . host_function_definitions_buffer_offset) ,
186- )
187175 . field (
188176 "Input Data Buffer Offset" ,
189177 & format_args ! ( "{:#x}" , self . input_data_buffer_offset) ,
@@ -256,19 +244,13 @@ impl SandboxMemoryLayout {
256244 let peb_init_data_offset = peb_offset + offset_of ! ( HyperlightPEB , init_data) ;
257245 let peb_heap_data_offset = peb_offset + offset_of ! ( HyperlightPEB , guest_heap) ;
258246 let peb_guest_stack_data_offset = peb_offset + offset_of ! ( HyperlightPEB , guest_stack) ;
259- let peb_host_function_definitions_offset =
260- peb_offset + offset_of ! ( HyperlightPEB , host_function_definitions) ;
261247
262248 // The following offsets are the actual values that relate to memory layout,
263249 // which are written to PEB struct
264250 let peb_address = Self :: BASE_ADDRESS + peb_offset;
265- // make sure host function definitions buffer starts at 4K boundary
266- let host_function_definitions_buffer_offset = round_up_to (
267- peb_host_function_definitions_offset + size_of :: < GuestMemoryRegion > ( ) ,
268- PAGE_SIZE_USIZE ,
269- ) ;
251+ // make sure input data buffer starts at 4K boundary
270252 let input_data_buffer_offset = round_up_to (
271- host_function_definitions_buffer_offset + cfg . get_host_function_definition_size ( ) ,
253+ peb_guest_stack_data_offset + size_of :: < GuestStack > ( ) ,
272254 PAGE_SIZE_USIZE ,
273255 ) ;
274256 let output_data_buffer_offset = round_up_to (
@@ -294,15 +276,13 @@ impl SandboxMemoryLayout {
294276 heap_size,
295277 peb_security_cookie_seed_offset,
296278 peb_guest_dispatch_function_ptr_offset,
297- peb_host_function_definitions_offset,
298279 peb_input_data_offset,
299280 peb_output_data_offset,
300281 peb_init_data_offset,
301282 peb_heap_data_offset,
302283 peb_guest_stack_data_offset,
303284 sandbox_memory_config : cfg,
304285 code_size,
305- host_function_definitions_buffer_offset,
306286 input_data_buffer_offset,
307287 output_data_buffer_offset,
308288 guest_heap_buffer_offset,
@@ -325,22 +305,6 @@ impl SandboxMemoryLayout {
325305 self . peb_output_data_offset
326306 }
327307
328- /// Get the offset in guest memory to the host function definitions
329- /// size
330- #[ instrument( skip_all, parent = Span :: current( ) , level= "Trace" ) ]
331- pub ( super ) fn get_host_function_definitions_size_offset ( & self ) -> usize {
332- // The size field is the first field in the `HostFunctions` struct
333- self . peb_host_function_definitions_offset
334- }
335-
336- /// Get the offset in guest memory to the host function definitions
337- /// pointer.
338- #[ instrument( skip_all, parent = Span :: current( ) , level= "Trace" ) ]
339- fn get_host_function_definitions_pointer_offset ( & self ) -> usize {
340- // The size field is the field after the size field in the `HostFunctions` struct which is a u64
341- self . peb_host_function_definitions_offset + size_of :: < u64 > ( )
342- }
343-
344308 /// Get the offset in guest memory to the init data size
345309 #[ instrument( skip_all, parent = Span :: current( ) , level= "Trace" ) ]
346310 pub ( super ) fn get_init_data_size_offset ( & self ) -> usize {
@@ -526,31 +490,12 @@ impl SandboxMemoryLayout {
526490 }
527491
528492 // PEB
529- let host_functions_definitions_offset = builder. push_page_aligned (
493+ let input_data_offset = builder. push_page_aligned (
530494 size_of :: < HyperlightPEB > ( ) ,
531495 MemoryRegionFlags :: READ | MemoryRegionFlags :: WRITE ,
532496 Peb ,
533497 ) ;
534498
535- let expected_host_functions_definitions_offset =
536- TryInto :: < usize > :: try_into ( self . host_function_definitions_buffer_offset ) ?;
537-
538- if host_functions_definitions_offset != expected_host_functions_definitions_offset {
539- return Err ( new_error ! (
540- "Host Function Definitions offset does not match expected Host Function Definitions offset expected: {}, actual: {}" ,
541- expected_host_functions_definitions_offset,
542- host_functions_definitions_offset
543- ) ) ;
544- }
545-
546- // host function definitions
547- let input_data_offset = builder. push_page_aligned (
548- self . sandbox_memory_config
549- . get_host_function_definition_size ( ) ,
550- MemoryRegionFlags :: READ ,
551- HostFunctionDefinitions ,
552- ) ;
553-
554499 let expected_input_data_offset = TryInto :: < usize > :: try_into ( self . input_data_buffer_offset ) ?;
555500
556501 if input_data_offset != expected_input_data_offset {
@@ -744,16 +689,6 @@ impl SandboxMemoryLayout {
744689
745690 // Skip guest_dispatch_function_ptr_offset because it is set by the guest
746691
747- // Set up Host Function Definition
748- shared_mem. write_u64 (
749- self . get_host_function_definitions_size_offset ( ) ,
750- self . sandbox_memory_config
751- . get_host_function_definition_size ( )
752- . try_into ( ) ?,
753- ) ?;
754- let addr = get_address ! ( host_function_definitions_buffer_offset) ;
755- shared_mem. write_u64 ( self . get_host_function_definitions_pointer_offset ( ) , addr) ?;
756-
757692 // Skip code, is set when loading binary
758693 // skip outb and outb context, is set when running in_proc
759694
@@ -861,8 +796,6 @@ mod tests {
861796
862797 expected_size += round_up_to ( size_of :: < HyperlightPEB > ( ) , PAGE_SIZE_USIZE ) ;
863798
864- expected_size += round_up_to ( cfg. get_host_function_definition_size ( ) , PAGE_SIZE_USIZE ) ;
865-
866799 expected_size += round_up_to ( cfg. get_input_data_size ( ) , PAGE_SIZE_USIZE ) ;
867800
868801 expected_size += round_up_to ( cfg. get_output_data_size ( ) , PAGE_SIZE_USIZE ) ;
0 commit comments