@@ -22,8 +22,8 @@ use rand::{rng, RngCore};
2222use tracing:: { instrument, Span } ;
2323
2424use super :: memory_region:: MemoryRegionType :: {
25- Code , GuardPage , GuestErrorData , Heap , HostExceptionData , InputData , OutputData , PageTables ,
26- PanicContext , Peb , Stack ,
25+ Code , GuardPage , GuestErrorData , Heap , InputData , OutputData , PageTables , PanicContext , Peb ,
26+ Stack ,
2727} ;
2828use super :: memory_region:: { MemoryRegion , MemoryRegionFlags , MemoryRegionVecBuilder } ;
2929use super :: mgr:: AMOUNT_OF_MEMORY_PER_PT ;
@@ -47,8 +47,6 @@ use crate::{log_then_return, new_error, Result};
4747// +-------------------------------------------+
4848// | Guest Error Log |
4949// +-------------------------------------------+
50- // | Host Exception Handlers |
51- // +-------------------------------------------+
5250// | PEB Struct | (HyperlightPEB size)
5351// +-------------------------------------------+
5452// | Guest Code |
@@ -62,12 +60,6 @@ use crate::{log_then_return, new_error, Result};
6260// | PML4 |
6361// +-------------------------------------------+ 0x0_000
6462
65- ///
66- /// - `HostExceptionData` - memory that contains details of any Host Exception that
67- /// occurred in outb function. it contains a 32 bit length following by a json
68- /// serialisation of any error that occurred. the length of this field is
69- /// `HostExceptionSize` from` `SandboxConfiguration`
70- ///
7163/// - `GuestError` - contains a buffer for any guest error that occurred.
7264/// the length of this field is `GuestErrorBufferSize` from `SandboxConfiguration`
7365///
@@ -103,7 +95,6 @@ pub(crate) struct SandboxMemoryLayout {
10395 peb_offset : usize ,
10496 peb_security_cookie_seed_offset : usize ,
10597 peb_guest_dispatch_function_ptr_offset : usize , // set by guest in guest entrypoint
106- pub ( crate ) peb_host_exception_offset : usize ,
10798 peb_guest_error_offset : usize ,
10899 peb_code_and_outb_pointer_offset : usize ,
109100 peb_runmode_offset : usize ,
@@ -115,7 +106,6 @@ pub(crate) struct SandboxMemoryLayout {
115106
116107 // The following are the actual values
117108 // that are written to the PEB struct
118- pub ( crate ) host_exception_buffer_offset : usize ,
119109 pub ( super ) guest_error_buffer_offset : usize ,
120110 pub ( super ) input_data_buffer_offset : usize ,
121111 pub ( super ) output_data_buffer_offset : usize ,
@@ -153,10 +143,6 @@ impl Debug for SandboxMemoryLayout {
153143 "Guest Dispatch Function Pointer Offset" ,
154144 & format_args ! ( "{:#x}" , self . peb_guest_dispatch_function_ptr_offset) ,
155145 )
156- . field (
157- "Host Exception Offset" ,
158- & format_args ! ( "{:#x}" , self . peb_host_exception_offset) ,
159- )
160146 . field (
161147 "Guest Error Offset" ,
162148 & format_args ! ( "{:#x}" , self . peb_guest_error_offset) ,
@@ -185,10 +171,6 @@ impl Debug for SandboxMemoryLayout {
185171 "Guest Stack Offset" ,
186172 & format_args ! ( "{:#x}" , self . peb_guest_stack_data_offset) ,
187173 )
188- . field (
189- "Host Exception Buffer Offset" ,
190- & format_args ! ( "{:#x}" , self . host_exception_buffer_offset) ,
191- )
192174 . field (
193175 "Guest Error Buffer Offset" ,
194176 & format_args ! ( "{:#x}" , self . guest_error_buffer_offset) ,
@@ -277,7 +259,6 @@ impl SandboxMemoryLayout {
277259 peb_offset + offset_of ! ( HyperlightPEB , security_cookie_seed) ;
278260 let peb_guest_dispatch_function_ptr_offset =
279261 peb_offset + offset_of ! ( HyperlightPEB , guest_function_dispatch_ptr) ;
280- let peb_host_exception_offset = peb_offset + offset_of ! ( HyperlightPEB , hostException) ;
281262 let peb_guest_error_offset = peb_offset + offset_of ! ( HyperlightPEB , guestErrorData) ;
282263 let peb_code_and_outb_pointer_offset = peb_offset + offset_of ! ( HyperlightPEB , pCode) ;
283264 let peb_runmode_offset = peb_offset + offset_of ! ( HyperlightPEB , runMode) ;
@@ -291,13 +272,8 @@ impl SandboxMemoryLayout {
291272 // The following offsets are the actual values that relate to memory layout,
292273 // which are written to PEB struct
293274 let peb_address = Self :: BASE_ADDRESS + peb_offset;
294- // make sure host exception buffer starts at 4K boundary
295- let host_exception_buffer_offset = round_up_to (
296- peb_guest_stack_data_offset + size_of :: < GuestStackData > ( ) ,
297- PAGE_SIZE_USIZE ,
298- ) ;
299275 let guest_error_buffer_offset = round_up_to (
300- host_exception_buffer_offset + cfg . get_host_exception_size ( ) ,
276+ peb_guest_stack_data_offset + size_of :: < GuestStackData > ( ) ,
301277 PAGE_SIZE_USIZE ,
302278 ) ;
303279 let input_data_buffer_offset = round_up_to (
@@ -329,7 +305,6 @@ impl SandboxMemoryLayout {
329305 heap_size,
330306 peb_security_cookie_seed_offset,
331307 peb_guest_dispatch_function_ptr_offset,
332- peb_host_exception_offset,
333308 peb_guest_error_offset,
334309 peb_code_and_outb_pointer_offset,
335310 peb_runmode_offset,
@@ -341,7 +316,6 @@ impl SandboxMemoryLayout {
341316 guest_error_buffer_offset,
342317 sandbox_memory_config : cfg,
343318 code_size,
344- host_exception_buffer_offset,
345319 input_data_buffer_offset,
346320 output_data_buffer_offset,
347321 guest_heap_buffer_offset,
@@ -359,14 +333,6 @@ impl SandboxMemoryLayout {
359333 self . peb_runmode_offset
360334 }
361335
362- /// Get the offset in guest memory to the size field in the
363- /// `HostExceptionData` structure.
364- #[ instrument( skip_all, parent = Span :: current( ) , level= "Trace" ) ]
365- pub ( super ) fn get_host_exception_size_offset ( & self ) -> usize {
366- // The size field is the first field in the `HostExceptionData` struct
367- self . peb_host_exception_offset
368- }
369-
370336 /// Get the offset in guest memory to the max size of the guest error buffer
371337 #[ instrument( skip_all, parent = Span :: current( ) , level= "Trace" ) ]
372338 pub ( super ) fn get_guest_error_buffer_size_offset ( & self ) -> usize {
@@ -398,12 +364,6 @@ impl SandboxMemoryLayout {
398364 self . stack_size
399365 }
400366
401- /// Get the offset in guest memory to the start of host errors
402- #[ instrument( skip_all, parent = Span :: current( ) , level= "Trace" ) ]
403- pub ( super ) fn get_host_exception_offset ( & self ) -> usize {
404- self . host_exception_buffer_offset
405- }
406-
407367 /// Get the offset in guest memory to the OutB pointer.
408368 #[ instrument( skip_all, parent = Span :: current( ) , level= "Trace" ) ]
409369 pub ( super ) fn get_outb_pointer_offset ( & self ) -> usize {
@@ -582,7 +542,6 @@ impl SandboxMemoryLayout {
582542 let mut total_mapped_memory_size: usize = round_up_to ( code_size, PAGE_SIZE_USIZE ) ;
583543 total_mapped_memory_size += round_up_to ( stack_size, PAGE_SIZE_USIZE ) ;
584544 total_mapped_memory_size += round_up_to ( heap_size, PAGE_SIZE_USIZE ) ;
585- total_mapped_memory_size += round_up_to ( cfg. get_host_exception_size ( ) , PAGE_SIZE_USIZE ) ;
586545 total_mapped_memory_size += round_up_to ( cfg. get_guest_error_buffer_size ( ) , PAGE_SIZE_USIZE ) ;
587546 total_mapped_memory_size += round_up_to ( cfg. get_input_data_size ( ) , PAGE_SIZE_USIZE ) ;
588547 total_mapped_memory_size += round_up_to ( cfg. get_output_data_size ( ) , PAGE_SIZE_USIZE ) ;
@@ -667,36 +626,18 @@ impl SandboxMemoryLayout {
667626 }
668627
669628 // PEB
670- let host_exception_offset = builder. push_page_aligned (
629+ let guest_error_offset = builder. push_page_aligned (
671630 size_of :: < HyperlightPEB > ( ) ,
672631 MemoryRegionFlags :: READ | MemoryRegionFlags :: WRITE ,
673632 Peb ,
674633 ) ;
675634
676- let expected_host_exception_offset =
677- TryInto :: < usize > :: try_into ( self . host_exception_buffer_offset ) ?;
678-
679- if host_exception_offset != expected_host_exception_offset {
680- return Err ( new_error ! (
681- "Host Exception offset does not match expected Host Exception offset expected: {}, actual: {}" ,
682- expected_host_exception_offset,
683- host_exception_offset
684- ) ) ;
685- }
686-
687- // host exception
688- let guest_error_offset = builder. push_page_aligned (
689- self . sandbox_memory_config . get_host_exception_size ( ) ,
690- MemoryRegionFlags :: READ | MemoryRegionFlags :: WRITE ,
691- HostExceptionData ,
692- ) ;
693-
694635 let expected_guest_error_offset =
695636 TryInto :: < usize > :: try_into ( self . guest_error_buffer_offset ) ?;
696637
697638 if guest_error_offset != expected_guest_error_offset {
698639 return Err ( new_error ! (
699- "Guest Error offset does not match expected Guest Error offset expected: {}, actual: {}" ,
640+ "Guest error offset does not match expected Guest error offset expected: {}, actual: {}" ,
700641 expected_guest_error_offset,
701642 guest_error_offset
702643 ) ) ;
@@ -877,16 +818,6 @@ impl SandboxMemoryLayout {
877818
878819 // Skip guest_dispatch_function_ptr_offset because it is set by the guest
879820
880- // Set up Host Exception Header
881- // The peb only needs to include the size, not the actual buffer
882- // since the the guest wouldn't want to read the buffer anyway
883- shared_mem. write_u64 (
884- self . get_host_exception_size_offset ( ) ,
885- self . sandbox_memory_config
886- . get_host_exception_size ( )
887- . try_into ( ) ?,
888- ) ?;
889-
890821 // Set up Guest Error Fields
891822 let addr = get_address ! ( guest_error_buffer) ;
892823 shared_mem. write_u64 ( self . get_guest_error_buffer_pointer_offset ( ) , addr) ?;
@@ -1027,8 +958,6 @@ mod tests {
1027958
1028959 expected_size += round_up_to ( size_of :: < HyperlightPEB > ( ) , PAGE_SIZE_USIZE ) ;
1029960
1030- expected_size += round_up_to ( cfg. get_host_exception_size ( ) , PAGE_SIZE_USIZE ) ;
1031-
1032961 expected_size += round_up_to ( cfg. get_guest_error_buffer_size ( ) , PAGE_SIZE_USIZE ) ;
1033962
1034963 expected_size += round_up_to ( cfg. get_input_data_size ( ) , PAGE_SIZE_USIZE ) ;
0 commit comments