background image

41-44 Vol. 3D

SGX INSTRUCTION REFERENCES

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

FI;

(* Check version before committing *)
IF (DS:RDX ≠ 0)

THEN #GP(0); 
ELSE

DS:RDX TMP_VER;

FI;

(* Commit EPCM changes *)
EPCM(DS:RCX).PT  TMP_HEADER.SECINFO.FLAGS.PT;
EPCM(DS:RCX).RWX  TMP_HEADER.SECINFO.FLAGS.RWX;
EPCM(DS:RCX).PENDING  TMP_HEADER.SECINFO.FLAGS.PENDING;
EPCM(DS:RCX).MODIFIED  TMP_HEADER.SECINFO.FLAGS.MODIFIED;
EPCM(DS:RCX).PR  TMP_HEADER.SECINFO.FLAGS.PR;
EPCM(DS:RCX).ENCLAVEADDRESS  TMP_HEADER.LINADDR;

IF ( (EAX = 07H) and (TMP_HEADER.SECINFO.FLAGS.PT is NOT PT_SECS or PT_VA))

THEN 

EPCM(DS:RCX).BLOCKED  1;

ELSE

EPCM(DS:RCX).BLOCKED  0;

FI;

EPCM(DS:RCX). VALID  1;

RAX 0;
RFLAGS.ZF  0;

ERROR_EXIT:
RFLAGS.CF,PF,AF,OF,SF  0;

Flags Affected

Sets ZF if unsuccessful, otherwise cleared and RAX returns error code. Clears CF, PF, AF, OF, SF.

Protected Mode Exceptions

#GP(0)

If a memory operand effective address is outside the DS segment limit.
If a memory operand is not properly aligned.
If the instruction’s EPC resource is in use by others.
If the instruction fails to verify MAC.
If the version-array slot is in use.
If the parameters fail consistency checks.

#PF(error code)

If a page fault occurs in accessing memory operands.
If a memory operand expected to be in EPC does not resolve to an EPC page.
If one of the EPC memory operands has incorrect page type.
If the destination EPC page is already valid.

64-Bit Mode Exceptions

#GP(0)

If a memory operand is non-canonical form.