hyperlight_guest/exceptions/
handlers.rs1use alloc::format;
18use core::ffi::c_char;
19
20use hyperlight_common::flatbuffer_wrappers::guest_error::ErrorCode;
21use hyperlight_common::outb::Exception;
22
23use crate::entrypoint::abort_with_code_and_message;
24
25#[no_mangle]
27pub extern "C" fn hl_exception_handler(
28 stack_pointer: u64,
29 exception_number: u64,
30 page_fault_address: u64,
31) {
32 let exception = Exception::try_from(exception_number as u8).expect("Invalid exception number");
33 let msg = format!(
34 "Page Fault Address: {:#x}\n\
35 Stack Pointer: {:#x}",
36 page_fault_address, stack_pointer
37 );
38
39 unsafe {
40 abort_with_code_and_message(
41 &[ErrorCode::GuestError as u8, exception as u8],
42 msg.as_ptr() as *const c_char,
43 );
44 }
45}