background image

41-14 Vol. 3D

SGX INSTRUCTION REFERENCES

TMP_ENCLAVEOFFSET  TMP_LINADDR - DS:TMP_SECS.BASEADDR;
TMPUPDATEFIELD[63:0]  0000000044444145H; // “EADD”
TMPUPDATEFIELD[127:64]  TMP_ENCLAVEOFFSET;
TMPUPDATEFIELD[511:128]  SCRATCH_SECINFO[375:0]; // 48 bytes
DS:TMP_SECS.MRENCLAVE  SHA256UPDATE(DS:TMP_SECS.MRENCLAVE, TMPUPDATEFIELD)
INC enclave’s MRENCLAVE update counter;

(* Add enclave offset and security attributes to MRENCLAVE *)
EPCM(DS:RCX).R  SCRATCH_SECINFO.FLAGS.R;
EPCM(DS:RCX).W  SCRATCH_SECINFO.FLAGS.W;
EPCM(DS:RCX).X  SCRATCH_SECINFO.FLAGS.X;
EPCM(DS:RCX).PT  SCRATCH_SECINFO.FLAGS.PT;
EPCM(DS:RCX).ENCLAVEADDRESS  TMP_LINADDR;

(* associate the EPCPAGE with the SECS by storing the SECS identifier of DS:TMP_SECS *)
Update EPCM(DS:RCX) SECS identifier to reference DS:TMP_SECS identifier;

(* Set EPCM entry fields *)
EPCM(DS:RCX).BLOCKED  0;
EPCM(DS:RCX).PENDING  0;
EPCM(DS:RCX).MODIFIED  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 an enclave memory operand is outside of the EPC.
If an enclave memory operand is the wrong type.
If a memory operand is locked.
If the enclave is initialized.
If the enclave's MRENCLAVE is locked.
If the TCS page reserved bits are set.

#PF(error code)

If a page fault occurs in accessing memory operands.
If the EPC page is valid.

64-Bit Mode Exceptions

#GP(0)

If a memory operand is non-canonical form.
If a memory operand is not properly aligned.
If an enclave memory operand is outside of the EPC.
If an enclave memory operand is the wrong type.
If a memory operand is locked.
If the enclave is initialized.
If the enclave's MRENCLAVE is locked.
If the TCS page reserved bits are set.

#PF(error code)

If a page fault occurs in accessing memory operands.
If the EPC page is valid.