@@ -26,6 +26,8 @@ use hyperlight_guest_bin::paging;
2626// we start at
2727// 0x100_0000_0000 and go up from there
2828static FIRST_VADDR : AtomicU64 = AtomicU64 :: new ( 0x100_0000_0000u64 ) ;
29+
30+ #[ hyperlight_guest_tracing:: trace_function]
2931fn page_fault_handler (
3032 _exception_number : u64 ,
3133 info : * mut handler:: ExceptionInfo ,
@@ -54,6 +56,8 @@ fn page_fault_handler(
5456 }
5557 false
5658}
59+
60+ #[ hyperlight_guest_tracing:: trace_function]
5761pub ( crate ) fn register_page_fault_handler ( ) {
5862 // On amd64, vector 14 is #PF
5963 // See AMD64 Architecture Programmer's Manual, Volume 2
@@ -70,6 +74,7 @@ pub(crate) fn register_page_fault_handler() {
7074 * page-fault handling to hardcoded check if memory is in this region
7175 * (see above) */
7276#[ no_mangle]
77+ #[ hyperlight_guest_tracing:: trace_function]
7378pub extern "C" fn wasmtime_mmap_new ( _size : usize , _prot_flags : u32 , ret : & mut * mut u8 ) -> i32 {
7479 if _size > 0x100_0000_0000 {
7580 panic ! ( "wasmtime_mmap_{:x} {:x}" , _size, _prot_flags) ;
@@ -83,6 +88,7 @@ pub extern "C" fn wasmtime_mmap_new(_size: usize, _prot_flags: u32, ret: &mut *m
8388 * the same), or possibly for changing permissions, which will be a no-op
8489 * as we don't properly implement permissions at the moment. */
8590#[ no_mangle]
91+ #[ hyperlight_guest_tracing:: trace_function]
8692pub extern "C" fn wasmtime_mmap_remap ( addr : * mut u8 , size : usize , prot_flags : u32 ) -> i32 {
8793 if size > 0x100_0000_0000 {
8894 panic ! (
@@ -94,12 +100,14 @@ pub extern "C" fn wasmtime_mmap_remap(addr: *mut u8, size: usize, prot_flags: u3
94100}
95101
96102#[ no_mangle]
103+ #[ hyperlight_guest_tracing:: trace_function]
97104pub extern "C" fn wasmtime_munmap ( _ptr : * mut u8 , _size : usize ) -> i32 {
98105 0
99106}
100107
101108/* TODO: implement permissions properly */
102109#[ no_mangle]
110+ #[ hyperlight_guest_tracing:: trace_function]
103111pub extern "C" fn wasmtime_mprotect ( _ptr : * mut u8 , _size : usize , prot_flags : u32 ) -> i32 {
104112 /* currently all memory is allocated RWX; we assume that
105113 * restricting to R or RX can be ignored */
@@ -110,6 +118,7 @@ pub extern "C" fn wasmtime_mprotect(_ptr: *mut u8, _size: usize, prot_flags: u32
110118}
111119
112120#[ no_mangle]
121+ #[ hyperlight_guest_tracing:: trace_function]
113122pub extern "C" fn wasmtime_page_size ( ) -> usize {
114123 unsafe { hyperlight_guest_bin:: OS_PAGE_SIZE as usize }
115124}
@@ -118,6 +127,8 @@ pub extern "C" fn wasmtime_page_size() -> usize {
118127type wasmtime_trap_handler_t =
119128 extern "C" fn ( ip : usize , fp : usize , has_faulting_addr : bool , faulting_addr : usize ) ;
120129static WASMTIME_REQUESTED_TRAP_HANDLER : AtomicU64 = AtomicU64 :: new ( 0 ) ;
130+
131+ #[ hyperlight_guest_tracing:: trace_function]
121132fn wasmtime_trap_handler (
122133 exception_number : u64 ,
123134 info : * mut handler:: ExceptionInfo ,
@@ -149,6 +160,7 @@ fn wasmtime_trap_handler(
149160}
150161
151162#[ no_mangle]
163+ #[ hyperlight_guest_tracing:: trace_function]
152164pub extern "C" fn wasmtime_init_traps ( handler : wasmtime_trap_handler_t ) -> i32 {
153165 WASMTIME_REQUESTED_TRAP_HANDLER . store ( handler as usize as u64 , Ordering :: Relaxed ) ;
154166 // On amd64, vector 6 is #UD
@@ -168,6 +180,7 @@ pub extern "C" fn wasmtime_init_traps(handler: wasmtime_trap_handler_t) -> i32 {
168180
169181// The wasmtime_memory_image APIs are not yet supported.
170182#[ no_mangle]
183+ #[ hyperlight_guest_tracing:: trace_function]
171184pub extern "C" fn wasmtime_memory_image_new (
172185 _ptr : * const u8 ,
173186 _len : usize ,
@@ -178,6 +191,7 @@ pub extern "C" fn wasmtime_memory_image_new(
178191}
179192
180193#[ no_mangle]
194+ #[ hyperlight_guest_tracing:: trace_function]
181195pub extern "C" fn wasmtime_memory_image_map_at (
182196 _image : * mut c_void ,
183197 _addr : * mut u8 ,
@@ -189,6 +203,7 @@ pub extern "C" fn wasmtime_memory_image_map_at(
189203}
190204
191205#[ no_mangle]
206+ #[ hyperlight_guest_tracing:: trace_function]
192207pub extern "C" fn wasmtime_memory_image_free ( _image : * mut c_void ) {
193208 /* This should never be called because wasmtime_memory_image_new
194209 * returns NULL */
@@ -198,11 +213,15 @@ pub extern "C" fn wasmtime_memory_image_free(_image: *mut c_void) {
198213/* Because we only have a single thread in the guest at the moment, we
199214 * don't need real thread-local storage. */
200215static FAKE_TLS : AtomicPtr < u8 > = AtomicPtr :: new ( core:: ptr:: null_mut ( ) ) ;
216+
201217#[ no_mangle]
218+ #[ hyperlight_guest_tracing:: trace_function]
202219pub extern "C" fn wasmtime_tls_get ( ) -> * mut u8 {
203220 FAKE_TLS . load ( Ordering :: Acquire )
204221}
222+
205223#[ no_mangle]
224+ #[ hyperlight_guest_tracing:: trace_function]
206225pub extern "C" fn wasmtime_tls_set ( ptr : * mut u8 ) {
207226 FAKE_TLS . store ( ptr, Ordering :: Release )
208227}
@@ -229,6 +248,7 @@ impl wasmtime::CustomCodeMemory for WasmtimeCodeMemory {
229248 }
230249}
231250
251+ #[ hyperlight_guest_tracing:: trace_function]
232252pub ( crate ) unsafe fn map_buffer ( phys : u64 , len : u64 ) -> NonNull < [ u8 ] > {
233253 // TODO: Use a VA allocator
234254 let virt = phys as * mut u8 ;
0 commit comments