@@ -15,9 +15,9 @@ limitations under the License.
15
15
*/
16
16
17
17
use core:: arch:: asm;
18
- use core:: ffi:: { c_char, c_void , CStr } ;
18
+ use core:: ffi:: { c_char, CStr } ;
19
19
20
- use hyperlight_common:: mem:: { HyperlightPEB , RunMode } ;
20
+ use hyperlight_common:: mem:: HyperlightPEB ;
21
21
use hyperlight_common:: outb:: OutBAction ;
22
22
use log:: LevelFilter ;
23
23
use spin:: Once ;
@@ -27,18 +27,11 @@ use crate::guest_function_call::dispatch_function;
27
27
use crate :: guest_logger:: init_logger;
28
28
use crate :: host_function_call:: outb;
29
29
use 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 } ;
34
31
35
32
#[ inline( never) ]
36
33
pub fn halt ( ) {
37
- unsafe {
38
- if RUNNING_MODE == RunMode :: Hypervisor {
39
- asm ! ( "hlt" , options( nostack) )
40
- }
41
- }
34
+ unsafe { asm ! ( "hlt" , options( nostack) ) }
42
35
}
43
36
44
37
#[ no_mangle]
@@ -105,45 +98,14 @@ pub extern "win64" fn entrypoint(peb_address: u64, seed: u64, ops: u64, max_log_
105
98
. expect ( "Invalid log level" ) ;
106
99
init_logger ( max_log_level) ;
107
100
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 ( ) ;
147
109
148
110
let heap_start = ( * peb_ptr) . guestheapData . guestHeapBuffer as usize ;
149
111
let heap_size = ( * peb_ptr) . guestheapData . guestHeapSize as usize ;
0 commit comments