@@ -15,9 +15,9 @@ limitations under the License.
1515*/
1616
1717use core:: arch:: asm;
18- use core:: ffi:: { c_char, c_void , CStr } ;
18+ use core:: ffi:: { c_char, CStr } ;
1919
20- use hyperlight_common:: mem:: { HyperlightPEB , RunMode } ;
20+ use hyperlight_common:: mem:: HyperlightPEB ;
2121use hyperlight_common:: outb:: OutBAction ;
2222use log:: LevelFilter ;
2323use spin:: Once ;
@@ -27,18 +27,11 @@ use crate::guest_function_call::dispatch_function;
2727use crate :: guest_logger:: init_logger;
2828use crate :: host_function_call:: outb;
2929use crate :: idtr:: load_idt;
30- use crate :: {
31- __security_cookie, HEAP_ALLOCATOR , MIN_STACK_ADDRESS , OS_PAGE_SIZE , OUTB_PTR ,
32- OUTB_PTR_WITH_CONTEXT , P_PEB , RUNNING_MODE ,
33- } ;
30+ use crate :: { __security_cookie, HEAP_ALLOCATOR , MIN_STACK_ADDRESS , OS_PAGE_SIZE , P_PEB } ;
3431
3532#[ inline( never) ]
3633pub fn halt ( ) {
37- unsafe {
38- if RUNNING_MODE == RunMode :: Hypervisor {
39- asm ! ( "hlt" , options( nostack) )
40- }
41- }
34+ unsafe { asm ! ( "hlt" , options( nostack) ) }
4235}
4336
4437#[ no_mangle]
@@ -105,45 +98,14 @@ pub extern "win64" fn entrypoint(peb_address: u64, seed: u64, ops: u64, max_log_
10598 . expect ( "Invalid log level" ) ;
10699 init_logger ( max_log_level) ;
107100
108- match ( * peb_ptr) . runMode {
109- RunMode :: Hypervisor => {
110- RUNNING_MODE = RunMode :: Hypervisor ;
111- // This static is to make it easier to implement the __chkstk function in assembly.
112- // It also means that should we change the layout of the struct in the future, we
113- // don't have to change the assembly code.
114- MIN_STACK_ADDRESS = ( * peb_ptr) . gueststackData . minUserStackAddress ;
115-
116- // Setup GDT and IDT
117- load_gdt ( ) ;
118- load_idt ( ) ;
119- }
120- RunMode :: InProcessLinux | RunMode :: InProcessWindows => {
121- RUNNING_MODE = ( * peb_ptr) . runMode ;
122-
123- OUTB_PTR = {
124- let outb_ptr: extern "win64" fn ( u16 , * const u8 , u64 ) =
125- core:: mem:: transmute ( ( * peb_ptr) . pOutb ) ;
126- Some ( outb_ptr)
127- } ;
128-
129- if ( * peb_ptr) . pOutbContext . is_null ( ) {
130- panic ! ( "OutbContext is null" ) ;
131- }
132-
133- OUTB_PTR_WITH_CONTEXT = {
134- let outb_ptr_with_context: extern "win64" fn (
135- * mut c_void ,
136- u16 ,
137- * const u8 ,
138- u64 ,
139- ) = core:: mem:: transmute ( ( * peb_ptr) . pOutb ) ;
140- Some ( outb_ptr_with_context)
141- } ;
142- }
143- _ => {
144- panic ! ( "Invalid runmode in PEB" ) ;
145- }
146- }
101+ // This static is to make it easier to implement the __chkstk function in assembly.
102+ // It also means that should we change the layout of the struct in the future, we
103+ // don't have to change the assembly code.
104+ MIN_STACK_ADDRESS = ( * peb_ptr) . gueststackData . minUserStackAddress ;
105+
106+ // Setup GDT and IDT
107+ load_gdt ( ) ;
108+ load_idt ( ) ;
147109
148110 let heap_start = ( * peb_ptr) . guestheapData . guestHeapBuffer as usize ;
149111 let heap_size = ( * peb_ptr) . guestheapData . guestHeapSize as usize ;
0 commit comments