@@ -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 , InputData , OutputData , PageTables ,
26
- PanicContext , Peb , Stack ,
25
+ Code , GuardPage , GuestErrorData , Heap , InputData , OutputData , PageTables , PanicContext , Peb ,
26
+ Stack ,
27
27
} ;
28
28
use super :: memory_region:: { MemoryRegion , MemoryRegionFlags , MemoryRegionVecBuilder } ;
29
29
use super :: mgr:: AMOUNT_OF_MEMORY_PER_PT ;
@@ -47,8 +47,6 @@ use crate::{log_then_return, new_error, Result};
47
47
// +-------------------------------------------+
48
48
// | Guest Error Log |
49
49
// +-------------------------------------------+
50
- // | Host Exception Handlers |
51
- // +-------------------------------------------+
52
50
// | PEB Struct | (HyperlightPEB size)
53
51
// +-------------------------------------------+
54
52
// | Guest Code |
@@ -62,12 +60,6 @@ use crate::{log_then_return, new_error, Result};
62
60
// | PML4 |
63
61
// +-------------------------------------------+ 0x0_000
64
62
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
- ///
71
63
/// - `GuestError` - contains a buffer for any guest error that occurred.
72
64
/// the length of this field is `GuestErrorBufferSize` from `SandboxConfiguration`
73
65
///
@@ -103,7 +95,6 @@ pub(crate) struct SandboxMemoryLayout {
103
95
peb_offset : usize ,
104
96
peb_security_cookie_seed_offset : usize ,
105
97
peb_guest_dispatch_function_ptr_offset : usize , // set by guest in guest entrypoint
106
- pub ( crate ) peb_host_exception_offset : usize ,
107
98
peb_guest_error_offset : usize ,
108
99
peb_code_and_outb_pointer_offset : usize ,
109
100
peb_runmode_offset : usize ,
@@ -115,7 +106,6 @@ pub(crate) struct SandboxMemoryLayout {
115
106
116
107
// The following are the actual values
117
108
// that are written to the PEB struct
118
- pub ( crate ) host_exception_buffer_offset : usize ,
119
109
pub ( super ) guest_error_buffer_offset : usize ,
120
110
pub ( super ) input_data_buffer_offset : usize ,
121
111
pub ( super ) output_data_buffer_offset : usize ,
@@ -153,10 +143,6 @@ impl Debug for SandboxMemoryLayout {
153
143
"Guest Dispatch Function Pointer Offset" ,
154
144
& format_args ! ( "{:#x}" , self . peb_guest_dispatch_function_ptr_offset) ,
155
145
)
156
- . field (
157
- "Host Exception Offset" ,
158
- & format_args ! ( "{:#x}" , self . peb_host_exception_offset) ,
159
- )
160
146
. field (
161
147
"Guest Error Offset" ,
162
148
& format_args ! ( "{:#x}" , self . peb_guest_error_offset) ,
@@ -185,10 +171,6 @@ impl Debug for SandboxMemoryLayout {
185
171
"Guest Stack Offset" ,
186
172
& format_args ! ( "{:#x}" , self . peb_guest_stack_data_offset) ,
187
173
)
188
- . field (
189
- "Host Exception Buffer Offset" ,
190
- & format_args ! ( "{:#x}" , self . host_exception_buffer_offset) ,
191
- )
192
174
. field (
193
175
"Guest Error Buffer Offset" ,
194
176
& format_args ! ( "{:#x}" , self . guest_error_buffer_offset) ,
@@ -277,7 +259,6 @@ impl SandboxMemoryLayout {
277
259
peb_offset + offset_of ! ( HyperlightPEB , security_cookie_seed) ;
278
260
let peb_guest_dispatch_function_ptr_offset =
279
261
peb_offset + offset_of ! ( HyperlightPEB , guest_function_dispatch_ptr) ;
280
- let peb_host_exception_offset = peb_offset + offset_of ! ( HyperlightPEB , hostException) ;
281
262
let peb_guest_error_offset = peb_offset + offset_of ! ( HyperlightPEB , guestErrorData) ;
282
263
let peb_code_and_outb_pointer_offset = peb_offset + offset_of ! ( HyperlightPEB , pCode) ;
283
264
let peb_runmode_offset = peb_offset + offset_of ! ( HyperlightPEB , runMode) ;
@@ -291,13 +272,8 @@ impl SandboxMemoryLayout {
291
272
// The following offsets are the actual values that relate to memory layout,
292
273
// which are written to PEB struct
293
274
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
- ) ;
299
275
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 > ( ) ,
301
277
PAGE_SIZE_USIZE ,
302
278
) ;
303
279
let input_data_buffer_offset = round_up_to (
@@ -329,7 +305,6 @@ impl SandboxMemoryLayout {
329
305
heap_size,
330
306
peb_security_cookie_seed_offset,
331
307
peb_guest_dispatch_function_ptr_offset,
332
- peb_host_exception_offset,
333
308
peb_guest_error_offset,
334
309
peb_code_and_outb_pointer_offset,
335
310
peb_runmode_offset,
@@ -341,7 +316,6 @@ impl SandboxMemoryLayout {
341
316
guest_error_buffer_offset,
342
317
sandbox_memory_config : cfg,
343
318
code_size,
344
- host_exception_buffer_offset,
345
319
input_data_buffer_offset,
346
320
output_data_buffer_offset,
347
321
guest_heap_buffer_offset,
@@ -359,14 +333,6 @@ impl SandboxMemoryLayout {
359
333
self . peb_runmode_offset
360
334
}
361
335
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
-
370
336
/// Get the offset in guest memory to the max size of the guest error buffer
371
337
#[ instrument( skip_all, parent = Span :: current( ) , level= "Trace" ) ]
372
338
pub ( super ) fn get_guest_error_buffer_size_offset ( & self ) -> usize {
@@ -398,12 +364,6 @@ impl SandboxMemoryLayout {
398
364
self . stack_size
399
365
}
400
366
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
-
407
367
/// Get the offset in guest memory to the OutB pointer.
408
368
#[ instrument( skip_all, parent = Span :: current( ) , level= "Trace" ) ]
409
369
pub ( super ) fn get_outb_pointer_offset ( & self ) -> usize {
@@ -582,7 +542,6 @@ impl SandboxMemoryLayout {
582
542
let mut total_mapped_memory_size: usize = round_up_to ( code_size, PAGE_SIZE_USIZE ) ;
583
543
total_mapped_memory_size += round_up_to ( stack_size, PAGE_SIZE_USIZE ) ;
584
544
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 ) ;
586
545
total_mapped_memory_size += round_up_to ( cfg. get_guest_error_buffer_size ( ) , PAGE_SIZE_USIZE ) ;
587
546
total_mapped_memory_size += round_up_to ( cfg. get_input_data_size ( ) , PAGE_SIZE_USIZE ) ;
588
547
total_mapped_memory_size += round_up_to ( cfg. get_output_data_size ( ) , PAGE_SIZE_USIZE ) ;
@@ -667,36 +626,18 @@ impl SandboxMemoryLayout {
667
626
}
668
627
669
628
// PEB
670
- let host_exception_offset = builder. push_page_aligned (
629
+ let guest_error_offset = builder. push_page_aligned (
671
630
size_of :: < HyperlightPEB > ( ) ,
672
631
MemoryRegionFlags :: READ | MemoryRegionFlags :: WRITE ,
673
632
Peb ,
674
633
) ;
675
634
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
-
694
635
let expected_guest_error_offset =
695
636
TryInto :: < usize > :: try_into ( self . guest_error_buffer_offset ) ?;
696
637
697
638
if guest_error_offset != expected_guest_error_offset {
698
639
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: {}" ,
700
641
expected_guest_error_offset,
701
642
guest_error_offset
702
643
) ) ;
@@ -877,16 +818,6 @@ impl SandboxMemoryLayout {
877
818
878
819
// Skip guest_dispatch_function_ptr_offset because it is set by the guest
879
820
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
-
890
821
// Set up Guest Error Fields
891
822
let addr = get_address ! ( guest_error_buffer) ;
892
823
shared_mem. write_u64 ( self . get_guest_error_buffer_pointer_offset ( ) , addr) ?;
@@ -1027,8 +958,6 @@ mod tests {
1027
958
1028
959
expected_size += round_up_to ( size_of :: < HyperlightPEB > ( ) , PAGE_SIZE_USIZE ) ;
1029
960
1030
- expected_size += round_up_to ( cfg. get_host_exception_size ( ) , PAGE_SIZE_USIZE ) ;
1031
-
1032
961
expected_size += round_up_to ( cfg. get_guest_error_buffer_size ( ) , PAGE_SIZE_USIZE ) ;
1033
962
1034
963
expected_size += round_up_to ( cfg. get_input_data_size ( ) , PAGE_SIZE_USIZE ) ;
0 commit comments