background image

41-24 Vol. 3D

SGX INSTRUCTION REFERENCES

(* Add “ECREATE” string and SECS fields to MRENCLAVE *)
TMPUPDATEFIELD[63:0]  0045544145524345H; // “ECREATE”
TMPUPDATEFIELD[95:64]  DS:TMP_SECS.SSAFRAMESIZE;
TMPUPDATEFIELD[159:96]  DS:TMP_SECS.SIZE;
TMPUPDATEFIELD[511:160]  0; 
SHA256UPDATE(DS:TMP_SECS.MRENCLAVE, TMPUPDATEFIELD)
INC enclave’s MRENCLAVE update counter;

(* Set EID *)
DS:TMP_SECS.EID  LockedXAdd(CR_NEXT_EID, 1);

(* Set the EPCM entry, first create SECS identifier and store the identifier in EPCM *)
EPCM(DS:TMP_SECS).PT  PT_SECS;
EPCM(DS:TMP_SECS).ENCLAVEADDRESS  0;
EPCM(DS:TMP_SECS).R  0;
EPCM(DS:TMP_SECS).W  0;
EPCM(DS:TMP_SECS).X  0;

(* Set EPCM entry fields *)
EPCM(DS:RCX).BLOCKED  0;
EPCM(DS:RCX).PENDING  0;
EPCM(DS:RCX).MODIFIED  0;
EPCM(DS:RCX).PR  0;
EPCM(DS:RCX).VALID  1;

Flags Affected

None

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 reserved fields are not zero.
If PAGEINFO.SECS is not zero.
If PAGEINFO.LINADDR is not zero.
If the SECS destination is locked.
If SECS.SSAFRAMESIZE is insufficient.

#PF(error code)

If a page fault occurs in accessing memory operands.
If the SECS destination is outside the EPC.

64-Bit Mode Exceptions

#GP(0)

If a memory address is non-canonical form.
If a memory operand is not properly aligned.
If the reserved fields are not zero.
If PAGEINFO.SECS is not zero.
If PAGEINFO.LINADDR is not zero.
If the SECS destination is locked.
If SECS.SSAFRAMESIZE is insufficient.

#PF(error code)

If a page fault occurs in accessing memory operands.
If the SECS destination is outside the EPC.