Open Enclave  0.18.0
exception.h
Go to the documentation of this file.
1 // Copyright (c) Open Enclave SDK contributors.
2 // Licensed under the MIT License.
3 
11 #ifndef _OE_BITS_EXCEPTION_H
12 #define _OE_BITS_EXCEPTION_H
13 
14 #include <openenclave/bits/defs.h>
15 #include <openenclave/bits/types.h>
16 
17 OE_EXTERNC_BEGIN
18 
21 #define OE_EXCEPTION_CONTINUE_SEARCH 0x0
22 
25 #define OE_EXCEPTION_CONTINUE_EXECUTION 0xFFFFFFFF
26 
29 #define OE_EXCEPTION_ABORT_EXECUTION 0xFFFFFFF0
30 
34 #define OE_EXCEPTION_DIVIDE_BY_ZERO 0x0
35 
38 #define OE_EXCEPTION_BREAKPOINT 0x1
39 
42 #define OE_EXCEPTION_BOUND_OUT_OF_RANGE 0x2
43 
46 #define OE_EXCEPTION_ILLEGAL_INSTRUCTION 0x3
47 
50 #define OE_EXCEPTION_ACCESS_VIOLATION 0x4
51 
54 #define OE_EXCEPTION_PAGE_FAULT 0x5
55 
58 #define OE_EXCEPTION_X87_FLOAT_POINT 0x6
59 
62 #define OE_EXCEPTION_MISALIGNMENT 0x7
63 
66 #define OE_EXCEPTION_SIMD_FLOAT_POINT 0x8
67 
70 #define OE_EXCEPTION_UNKNOWN 0xFFFFFFFF
71 
76 #define OE_EXCEPTION_FLAGS_HARDWARE 0x1
77 
81 #define OE_EXCEPTION_FLAGS_SOFTWARE 0x2
82 
95 #define OE_SGX_PAGE_FAULT_P_FLAG 0x1
96 
101 #define OE_SGX_PAGE_FAULT_WR_FLAG 0x2
102 
107 #define OE_SGX_PAGE_FAULT_US_FLAG 0x4
108 
113 #define OE_SGX_PAGE_FAULT_RSVD 0x8
114 
119 #define OE_SGX_PAGE_FAULT_ID_FLAG 0x10
120 
125 #define OE_SGX_PAGE_FAULT_PK_FLAG 0x20
126 
131 #define OE_SGX_PAGE_FAULT_SGX_FLAG 0x8000
132 
136 typedef struct _oe_basic_xstate
137 {
138  uint8_t blob[512];
139 } OE_ALIGNED(16) oe_basic_xstate_t;
146 typedef struct _oe_context
147 {
152  uint64_t flags;
153 
154  uint64_t rax;
156  uint64_t rbx;
158  uint64_t rcx;
160  uint64_t rdx;
162  uint64_t rbp;
164  uint64_t rsp;
166  uint64_t rdi;
168  uint64_t rsi;
170  uint64_t r8;
172  uint64_t r9;
174  uint64_t r10;
176  uint64_t r11;
178  uint64_t r12;
180  uint64_t r13;
182  uint64_t r14;
184  uint64_t r15;
186  uint64_t rip;
188  // Don't need to manipulate the segment registers directly.
189  // Ignore them: CS, DS, ES, SS, GS, and FS.
190 
191  uint32_t mxcsr;
195  // Don't need to manipulate other XSTATE (AVX etc.).
196 } oe_context_t;
203 typedef struct _oe_exception_record
204 {
205  uint32_t code;
207  uint32_t flags;
209  uint64_t address;
211  /* Information for PF/GP exceptions, which are only available
212  * for SGX2 and requires application opt-in (set CapturePFGPExceptions=1).
213  */
214  uint64_t faulting_address;
215  uint32_t error_code;
216 
217  /* The signal number passed by the host. Some applications might
218  * want to implement special exception handling logic based
219  * on this information. However, please use with caution as the
220  * host-passed information is untrusted in the SGX threat model. */
221  uint16_t host_signal_number;
222 
236  oe_exception_record_t* exception_context);
237 
238 OE_EXTERNC_END
239 
240 #endif /* _OE_BITS_EXCEPTION_H */
_oe_exception_record::address
uint64_t address
Exception address.
Definition: exception.h:209
_oe_context::r14
uint64_t r14
Integer register r14.
Definition: exception.h:182
_oe_context::rdx
uint64_t rdx
Integer register rdx.
Definition: exception.h:160
_oe_exception_record
Exception context structure with the exception code, flags, address and calling context of the except...
Definition: exception.h:203
types.h
_oe_context::r11
uint64_t r11
Integer register r11.
Definition: exception.h:176
_oe_context::flags
uint64_t flags
Exception flags.
Definition: exception.h:152
_oe_context::basic_xstate
oe_basic_xstate_t basic_xstate
Basic XSTATE.
Definition: exception.h:193
_oe_context::rbp
uint64_t rbp
Integer register rbp.
Definition: exception.h:162
_oe_context::r15
uint64_t r15
Integer register r15.
Definition: exception.h:184
_oe_context::r13
uint64_t r13
Integer register r13.
Definition: exception.h:180
_oe_context::rcx
uint64_t rcx
Integer register rcx.
Definition: exception.h:158
_oe_context::rip
uint64_t rip
Integer register rip.
Definition: exception.h:186
_oe_context::r8
uint64_t r8
Integer register r8.
Definition: exception.h:170
_oe_context::r10
uint64_t r10
Integer register r10.
Definition: exception.h:174
_oe_context::r12
uint64_t r12
Integer register r12.
Definition: exception.h:178
_oe_context::rax
uint64_t rax
Integer register rax.
Definition: exception.h:154
_oe_context::rdi
uint64_t rdi
Integer register rdi.
Definition: exception.h:166
_oe_context
Register state to be saved before an exception and restored after the exception has been handled in t...
Definition: exception.h:146
_oe_context::rsi
uint64_t rsi
Integer register rsi.
Definition: exception.h:168
_oe_basic_xstate::blob
uint8_t blob[512]
Holds XState i.e.
Definition: exception.h:138
_oe_context::rbx
uint64_t rbx
Integer register rbx.
Definition: exception.h:156
oe_vectored_exception_handler_t
uint64_t(* oe_vectored_exception_handler_t)(oe_exception_record_t *exception_context)
oe_vectored_exception_handler_t - Function pointer for a vectored exception handler in an enclave.
Definition: exception.h:235
_oe_exception_record::code
uint32_t code
Exception code.
Definition: exception.h:205
_oe_basic_xstate
Blob that contains X87 and SSE data.
Definition: exception.h:136
_oe_context::mxcsr
uint32_t mxcsr
SSE control flags.
Definition: exception.h:191
_oe_exception_record::context
oe_context_t * context
Exception context.
Definition: exception.h:223
_oe_context::r9
uint64_t r9
Integer register r9.
Definition: exception.h:172
oe_exception_record_t
struct _oe_exception_record oe_exception_record_t
Exception context structure with the exception code, flags, address and calling context of the except...
_oe_exception_record::flags
uint32_t flags
Exception flags.
Definition: exception.h:207
oe_context_t
struct _oe_context oe_context_t
Register state to be saved before an exception and restored after the exception has been handled in t...
_oe_context::rsp
uint64_t rsp
Integer register rsp.
Definition: exception.h:164