background image

41-82 Vol. 3D

SGX INSTRUCTION REFERENCES

Operation

Temp Variables in EEXIT Operational Flow

TMP_MODE64  ((IA32_EFER.LMA = 1) && (CS.L = 1));

IF (TMP_MODE64 = 1)

THEN 

IF (RBX is not canonical) THEN #GP(0); FI;

ELSE

IF (RBX > CS limit) THEN #GP(0); FI;

FI;

TMP_RIP  CRIP;
RIP  RBX;

(* Return current AEP in RCX *)
RCX  CR_TCS_PA.AEP;

(* Do the FS/GS swap *)
FS.selector  CR_SAVE_FS.selector;
FS.base  CR_SAVE_FS.base;
FS.limit  CR_SAVE_FS.limit;
FS.access_rights  CR_SAVE_FS.access_rights;
GS.selector  CR_SAVE_GS.selector;
GS.base  CR_SAVE_GS.base;
GS.limit  CR_SAVE_GS.limit;
GS.access_rights  CR_SAVE_GS.access_rights;

(* Restore XCR0 if needed *)
IF (CR4.OSXSAVE = 1) 

XCR0  CR_SAVE__XCR0;

FI;

Unsuppress_all_code_breakpoints_that_are_outside_ELRANGE;

IF (CR_DBGOPTIN = 0) 

THEN

UnSuppress_all_code_breakpoints_that_overlap_with_ELRANGE;
Restore suppressed breakpoint matches;
RFLAGS.TF  CR_SAVE_TF;
UnSuppress_montior_trap_flag;
UnSuppress_LBR_Generation;
UnSuppress_performance monitoring_activity;
Restore performance monitoring counter AnyThread demotion to MyThread in enclave back to AnyThread

FI;

IF RFLAGS.TF = 1

THEN Pend Single-Step #DB at the end of EEXIT;

FI;

Name

Type

Size (Bits)

Description

TMP_RIP

Effective Address

32/64

Saved copy of CRIP for use when creating LBR.