Vol. 3D 40-7
ENCLAVE EXITING EVENTS
(* Put the TCS LA into RBX for later use by ERESUME *)
RBX CR_TCS_LA;
(* Put the AEP into RCX for later use by ERESUME *)
RCX CR_TCS_PA.AEP;
(* Increment the SSA frame # *)
CR_TCS_PA.CSSA CR_TCS_PA.CSSA + 1;
(* Restore XCR0 if needed *)
IF (CR4.OSXSAVE = 1)
THEN XCR0 CR_SAVE_XCR0; FI;
Un-suppress all code breakpoints that are outside ELRANGE
(* Update the thread context to show not in enclave mode *)
CR_ENCLAVE_MODE 0;
(* Assure consistent translations. *)
Flush linear context including TLBs and paging-structure caches
IF (CR_DBGOPTIN = 0)
THEN
Un-suppress all breakpoints that overlap ELRANGE
(* Clear suppressed breakpoint matches *)
Restore suppressed breakpoint matches
(* Restore TF *)
RFLAGS.TF CR_SAVE_TF;
Un-suppress monitor trap flag;
Un-suppress branch recording facilities;
Un-suppress all suppressed performance monitoring activity;
Promote any sibling-thread counters that were demoted from AnyThread to MyThread during enclave
entry back to AnyThread;
FI;
IF the “monitor trap flag” VM-execution control is 1
THEN Pend MTF VM Exit at the end of exit; FI;
(* Clear low 12 bits of CR2 on #PF *)
IF (Exception code is #PF)
THEN CR2 CR2 & ~0xFFF; FI;
(* end_of_flow *)
(* Execution continues with normal event processing. *)