@@ -22,8 +22,8 @@ use rand::{rng, RngCore};
22
22
use tracing:: { instrument, Span } ;
23
23
24
24
use super :: memory_region:: MemoryRegionType :: {
25
- Code , GuardPage , GuestErrorData , Heap , HostExceptionData , HostFunctionDefinitions , InputData ,
26
- OutputData , PageTables , PanicContext , Peb , Stack ,
25
+ Code , GuardPage , GuestErrorData , Heap , HostExceptionData , InputData , OutputData , PageTables ,
26
+ PanicContext , Peb , Stack ,
27
27
} ;
28
28
use super :: memory_region:: { MemoryRegion , MemoryRegionFlags , MemoryRegionVecBuilder } ;
29
29
use super :: mgr:: AMOUNT_OF_MEMORY_PER_PT ;
@@ -49,9 +49,7 @@ use crate::{log_then_return, new_error, Result};
49
49
// +-------------------------------------------+
50
50
// | Host Exception Handlers |
51
51
// +-------------------------------------------+
52
- // | Host Function Definitions |
53
- // +-------------------------------------------+
54
- // | PEB Struct (0x98) |
52
+ // | PEB Struct | (HyperlightPEB size)
55
53
// +-------------------------------------------+
56
54
// | Guest Code |
57
55
// +-------------------------------------------+
@@ -64,9 +62,6 @@ use crate::{log_then_return, new_error, Result};
64
62
// | PML4 |
65
63
// +-------------------------------------------+ 0x0_000
66
64
67
- ///
68
- /// - `HostDefinitions` - the length of this is the `HostFunctionDefinitionSize`
69
- /// field from `SandboxConfiguration`
70
65
///
71
66
/// - `HostExceptionData` - memory that contains details of any Host Exception that
72
67
/// occurred in outb function. it contains a 32 bit length following by a json
@@ -108,7 +103,6 @@ pub(crate) struct SandboxMemoryLayout {
108
103
peb_offset : usize ,
109
104
peb_security_cookie_seed_offset : usize ,
110
105
peb_guest_dispatch_function_ptr_offset : usize , // set by guest in guest entrypoint
111
- pub ( super ) peb_host_function_definitions_offset : usize ,
112
106
pub ( crate ) peb_host_exception_offset : usize ,
113
107
peb_guest_error_offset : usize ,
114
108
peb_code_and_outb_pointer_offset : usize ,
@@ -121,7 +115,6 @@ pub(crate) struct SandboxMemoryLayout {
121
115
122
116
// The following are the actual values
123
117
// that are written to the PEB struct
124
- pub ( crate ) host_function_definitions_buffer_offset : usize ,
125
118
pub ( crate ) host_exception_buffer_offset : usize ,
126
119
pub ( super ) guest_error_buffer_offset : usize ,
127
120
pub ( super ) input_data_buffer_offset : usize ,
@@ -160,10 +153,6 @@ impl Debug for SandboxMemoryLayout {
160
153
"Guest Dispatch Function Pointer Offset" ,
161
154
& format_args ! ( "{:#x}" , self . peb_guest_dispatch_function_ptr_offset) ,
162
155
)
163
- . field (
164
- "Host Function Definitions Offset" ,
165
- & format_args ! ( "{:#x}" , self . peb_host_function_definitions_offset) ,
166
- )
167
156
. field (
168
157
"Host Exception Offset" ,
169
158
& format_args ! ( "{:#x}" , self . peb_host_exception_offset) ,
@@ -196,10 +185,6 @@ impl Debug for SandboxMemoryLayout {
196
185
"Guest Stack Offset" ,
197
186
& format_args ! ( "{:#x}" , self . peb_guest_stack_data_offset) ,
198
187
)
199
- . field (
200
- "Host Function Definitions Buffer Offset" ,
201
- & format_args ! ( "{:#x}" , self . host_function_definitions_buffer_offset) ,
202
- )
203
188
. field (
204
189
"Host Exception Buffer Offset" ,
205
190
& format_args ! ( "{:#x}" , self . host_exception_buffer_offset) ,
@@ -292,8 +277,6 @@ impl SandboxMemoryLayout {
292
277
peb_offset + offset_of ! ( HyperlightPEB , security_cookie_seed) ;
293
278
let peb_guest_dispatch_function_ptr_offset =
294
279
peb_offset + offset_of ! ( HyperlightPEB , guest_function_dispatch_ptr) ;
295
- let peb_host_function_definitions_offset =
296
- peb_offset + offset_of ! ( HyperlightPEB , hostFunctionDefinitions) ;
297
280
let peb_host_exception_offset = peb_offset + offset_of ! ( HyperlightPEB , hostException) ;
298
281
let peb_guest_error_offset = peb_offset + offset_of ! ( HyperlightPEB , guestErrorData) ;
299
282
let peb_code_and_outb_pointer_offset = peb_offset + offset_of ! ( HyperlightPEB , pCode) ;
@@ -308,14 +291,9 @@ impl SandboxMemoryLayout {
308
291
// The following offsets are the actual values that relate to memory layout,
309
292
// which are written to PEB struct
310
293
let peb_address = Self :: BASE_ADDRESS + peb_offset;
311
- // make sure host function definitions buffer starts at 4K boundary
312
- let host_function_definitions_buffer_offset = round_up_to (
313
- peb_guest_stack_data_offset + size_of :: < GuestStackData > ( ) ,
314
- PAGE_SIZE_USIZE ,
315
- ) ;
316
294
// make sure host exception buffer starts at 4K boundary
317
295
let host_exception_buffer_offset = round_up_to (
318
- host_function_definitions_buffer_offset + cfg . get_host_function_definition_size ( ) ,
296
+ peb_guest_stack_data_offset + size_of :: < GuestStackData > ( ) ,
319
297
PAGE_SIZE_USIZE ,
320
298
) ;
321
299
let guest_error_buffer_offset = round_up_to (
@@ -351,7 +329,6 @@ impl SandboxMemoryLayout {
351
329
heap_size,
352
330
peb_security_cookie_seed_offset,
353
331
peb_guest_dispatch_function_ptr_offset,
354
- peb_host_function_definitions_offset,
355
332
peb_host_exception_offset,
356
333
peb_guest_error_offset,
357
334
peb_code_and_outb_pointer_offset,
@@ -364,7 +341,6 @@ impl SandboxMemoryLayout {
364
341
guest_error_buffer_offset,
365
342
sandbox_memory_config : cfg,
366
343
code_size,
367
- host_function_definitions_buffer_offset,
368
344
host_exception_buffer_offset,
369
345
input_data_buffer_offset,
370
346
output_data_buffer_offset,
@@ -410,22 +386,6 @@ impl SandboxMemoryLayout {
410
386
self . peb_output_data_offset
411
387
}
412
388
413
- /// Get the offset in guest memory to the host function definitions
414
- /// size
415
- #[ instrument( skip_all, parent = Span :: current( ) , level= "Trace" ) ]
416
- pub ( super ) fn get_host_function_definitions_size_offset ( & self ) -> usize {
417
- // The size field is the first field in the `HostFunctions` struct
418
- self . peb_host_function_definitions_offset
419
- }
420
-
421
- /// Get the offset in guest memory to the host function definitions
422
- /// pointer.
423
- #[ instrument( skip_all, parent = Span :: current( ) , level= "Trace" ) ]
424
- fn get_host_function_definitions_pointer_offset ( & self ) -> usize {
425
- // The size field is the field after the size field in the `HostFunctions` struct which is a u64
426
- self . peb_host_function_definitions_offset + size_of :: < u64 > ( )
427
- }
428
-
429
389
/// Get the offset in guest memory to the minimum guest stack address.
430
390
#[ instrument( skip_all, parent = Span :: current( ) , level= "Trace" ) ]
431
391
fn get_min_guest_stack_address_offset ( & self ) -> usize {
@@ -623,8 +583,6 @@ impl SandboxMemoryLayout {
623
583
total_mapped_memory_size += round_up_to ( stack_size, PAGE_SIZE_USIZE ) ;
624
584
total_mapped_memory_size += round_up_to ( heap_size, PAGE_SIZE_USIZE ) ;
625
585
total_mapped_memory_size += round_up_to ( cfg. get_host_exception_size ( ) , PAGE_SIZE_USIZE ) ;
626
- total_mapped_memory_size +=
627
- round_up_to ( cfg. get_host_function_definition_size ( ) , PAGE_SIZE_USIZE ) ;
628
586
total_mapped_memory_size += round_up_to ( cfg. get_guest_error_buffer_size ( ) , PAGE_SIZE_USIZE ) ;
629
587
total_mapped_memory_size += round_up_to ( cfg. get_input_data_size ( ) , PAGE_SIZE_USIZE ) ;
630
588
total_mapped_memory_size += round_up_to ( cfg. get_output_data_size ( ) , PAGE_SIZE_USIZE ) ;
@@ -709,31 +667,12 @@ impl SandboxMemoryLayout {
709
667
}
710
668
711
669
// PEB
712
- let host_functions_definitions_offset = builder. push_page_aligned (
670
+ let host_exception_offset = builder. push_page_aligned (
713
671
size_of :: < HyperlightPEB > ( ) ,
714
672
MemoryRegionFlags :: READ | MemoryRegionFlags :: WRITE ,
715
673
Peb ,
716
674
) ;
717
675
718
- let expected_host_functions_definitions_offset =
719
- TryInto :: < usize > :: try_into ( self . host_function_definitions_buffer_offset ) ?;
720
-
721
- if host_functions_definitions_offset != expected_host_functions_definitions_offset {
722
- return Err ( new_error ! (
723
- "Host Function Definitions offset does not match expected Host Function Definitions offset expected: {}, actual: {}" ,
724
- expected_host_functions_definitions_offset,
725
- host_functions_definitions_offset
726
- ) ) ;
727
- }
728
-
729
- // host function definitions
730
- let host_exception_offset = builder. push_page_aligned (
731
- self . sandbox_memory_config
732
- . get_host_function_definition_size ( ) ,
733
- MemoryRegionFlags :: READ ,
734
- HostFunctionDefinitions ,
735
- ) ;
736
-
737
676
let expected_host_exception_offset =
738
677
TryInto :: < usize > :: try_into ( self . host_exception_buffer_offset ) ?;
739
678
@@ -938,16 +877,6 @@ impl SandboxMemoryLayout {
938
877
939
878
// Skip guest_dispatch_function_ptr_offset because it is set by the guest
940
879
941
- // Set up Host Function Definition
942
- shared_mem. write_u64 (
943
- self . get_host_function_definitions_size_offset ( ) ,
944
- self . sandbox_memory_config
945
- . get_host_function_definition_size ( )
946
- . try_into ( ) ?,
947
- ) ?;
948
- let addr = get_address ! ( host_function_definitions_buffer) ;
949
- shared_mem. write_u64 ( self . get_host_function_definitions_pointer_offset ( ) , addr) ?;
950
-
951
880
// Set up Host Exception Header
952
881
// The peb only needs to include the size, not the actual buffer
953
882
// since the the guest wouldn't want to read the buffer anyway
@@ -1098,8 +1027,6 @@ mod tests {
1098
1027
1099
1028
expected_size += round_up_to ( size_of :: < HyperlightPEB > ( ) , PAGE_SIZE_USIZE ) ;
1100
1029
1101
- expected_size += round_up_to ( cfg. get_host_function_definition_size ( ) , PAGE_SIZE_USIZE ) ;
1102
-
1103
1030
expected_size += round_up_to ( cfg. get_host_exception_size ( ) , PAGE_SIZE_USIZE ) ;
1104
1031
1105
1032
expected_size += round_up_to ( cfg. get_guest_error_buffer_size ( ) , PAGE_SIZE_USIZE ) ;
0 commit comments