background image

Vol. 3D 41-61

SGX INSTRUCTION REFERENCES

THEN #GP(0); FI;

(*Check if the VA Page is being removed or changed*)
IF (VA Page is being modified)

THEN #GP(0); FI;

(* Verify that EPCPAGE and VASLOT page are valid EPC pages and DS:RDX is VA *)
IF (EPCM(DS:RCX).VALID = 0) 

THEN #PF(DS:RCX); FI;

IF ( (EPCM(DS:RDX & ~0FFFH).VALID = 0) or (EPCM(DS:RDX & ~FFFH).PT is not PT_VA) )

THEN #PF(DS:RDX); FI;

(* Perform page-type-specific exception checks *)
IF ( (EPCM(DS:RCX).PT is PT_REG) or (EPCM(DS:RCX).PT is PT_TCS) or (EPCM(DS:RCX).PT is PT_TRIM ) )

THEN

TMP_SECS = Obtain SECS through EPCM(DS:RCX)

(* Check that EBLOCK has occurred correctly *)
IF (EBLOCK is not correct)

THEN #GP(0); FI;

FI;

RFLAGS.ZF,CF,PF,AF,OF,SF  0;
RAX  0;

(* Perform page-type-specific checks *)
IF ( (EPCM(DS:RCX).PT is PT_REG) or (EPCM(DS:RCX).PT is PT_TCS) or (EPCM(DS:RCX).PT is PT_TRIM ))

THEN

(* check to see if the page is evictable *)
IF (EPCM(DS:RCX).BLOCKED = 0) 

THEN

RAX  SGX_PAGE NOT_BLOCKED;
RFLAGS.ZF  1;
GOTO ERROR_EXIT;

FI;
(* Check if tracking done correctly *)
IF (Tracking not correct)

THEN

RAX  SGX_NOT_TRACKED;
RFLAGS.ZF  1;
GOTO ERROR_EXIT;

FI;

(* Obtain EID to establish cryptographic binding between the paged-out page and the enclave *)
TMP_HEADER.EID  TMP_SECS.EID;

(* Obtain EID as an enclave handle for software *)
TMP_PCMD_ENCLAVEID  TMP_SECS.EID;

ELSE IF (EPCM(DS:RCX).PT is PT_SECS)

(*check that there are no child pages inside the enclave *)
IF (DS:RCX has an EPC page associated with it)

THEN

RAX  SGX_CHILD_PRESENT;
RFLAGS.ZF  1;