When enclave has a page in EPC, we need to have some data structures as metadata along with main data saved in EPC. For example SECS (SGX Enclave Control Structure). In some papers from Intel, I have read that for example for 128 MB, we need to have about 32MB metadata and just 96MB left for data. Am I right? and what is this metadata?
The page metadata is stored in a Page Information (PAGEINFO) structure which in turn has PCMD field,which contains the virtual address of a Page Crypto Metadata(PCMD) structure. The LINADDR field in the PAGEINFO structure is used to store the ADDRESS field in the EPCM entry, which indicates the virtual address intended for accessing the page. The PCMD structure embeds the Security Information (SECINFO) , which is used to store the page type (PT) and the access permission flags (R, W, X) in the EPCM entry. The PCMD structure also stores the enclave’s ID (EID). These fields are later used by ELDU or ELDB(SGX CPU Instructions) to populate the EPCMentry for the EPC page that is reloaded.