background image

Vol. 3D 41-17

SGX INSTRUCTION REFERENCES

IF (EPCM(DS:TMP_SECS).VALID = 0 or EPCM(DS:TMP_SECS).PT ≠ PT_SECS) 

THEN #PF(DS:TMP_SECS); FI;

(* Check if the enclave to which the page will be added is in the Initialized state *)
IF (DS:TMP_SECS is not initialized) 

THEN #GP(0); FI;

(* Check the enclave offset is within the enclave linear address space *)
IF ( (TMP_LINADDR < DS:TMP_SECS.BASEADDR) or (TMP_LINADDR 

 DS:TMP_SECS.BASEADDR + DS:TMP_SECS.SIZE) )

THEN #GP(0); FI;

(* Clear the content of EPC page*)
DS:RCX[32767:0]  0;

(* Set EPCM security attributes *)
EPCM(DS:RCX).R  1;
EPCM(DS:RCX).W  1;
EPCM(DS:RCX).X  0;
EPCM(DS:RCX).PT  PT_REG;
EPCM(DS:RCX).ENCLAVEADDRESS  TMP_LINADDR;
EPCM(DS:RCX).BLOCKED  0;
EPCM(DS:RCX).PENDING  1;
EPCM(DS:RCX).MODIFIED  0;
EPCM(DS:RCX).PR  0;

(* 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 valid fields *)
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 a memory operand is locked.
If the enclave is not initialized.

#PF(error code)

If a page fault occurs in accessing memory operands.

64-Bit Mode Exceptions

#GP(0)

If a memory operand is non-canonical form.
If a memory operand is not properly aligned.
If a memory operand is locked.
If the enclave is not initialized.

#PF(error code)

If a page fault occurs in accessing memory operands.