Intel® Software Guard Extensions (Intel® SGX)
Discussion board focused on hardware-based isolation and memory encryption to provide extended code protection in solutions.

The number of allocated pages to the enclave

Meysam_t_
Beginner
945 Views

Hi,

I set HeapMaxSize equal to 0x80000 (512KB) for an enclave that needs 65KB of memory. However, SGX driver allocates 1030 EPC pages to this enclave. My question is that why the number of allocated pages is more than the enclave's requirement? and how is the size of allocated pages more than the max heap size? What I am missing here?

-M 

<HeapMaxSize>0x80000</HeapMaxSize>

0 Kudos
1 Solution
JesusG_Intel
Moderator
945 Views

Hello Meysam,

You should minimize the number of Trusted Threads via the TCSNum parameter in your enclave config file. This will impact your memory usage significantly as your total allocation for stack is TCSNum * StackMaxSize. There are no other memory optimization techniques you can do at the enclave config level.

Regards,

Jesus

View solution in original post

0 Kudos
6 Replies
JesusG_Intel
Moderator
945 Views

Hello Meysam,

Please see this document for more info on Enclave memory footprint: https://caslab.csl.yale.edu/workshops/hasp2016/HASP16-17.pdf. See Page 2-Figure 1 and page 4, section 5.1, Figure 4.

The Enclave's memory footprint includes the Thread Context, Enclave Heap, and Enclave Code.

Regards,

Jesus

0 Kudos
Meysam_t_
Beginner
946 Views

Hi Jesus,

thanks for your comment.

I have a sensitive block of data which is 256 pages. I set my heap address a little bit more than this and the stack part is also 60 pages. I want this enclave to occupy the smallest amount of memory in the EPC. For example, I want to keep the code out of EPC. Is it possible to do so? to this end, what change I should apply to my EDL file.

 

Thanks for your attention. 

 

0 Kudos
JesusG_Intel
Moderator
946 Views

Hello Meysam,

It is not possible to store enclave code outside of the EPC. Is there any code in your enclave that can be moved to to your app?

Regards,

Jesus

0 Kudos
Meysam_t_
Beginner
946 Views

I appreciate your time and comment, especially your very prompt reply.

In my EDL file, I defined 4 functions which are accessing the sensitive blocks of data. I don't think I can pull them out of the enclave right? I reduce the stack and heap size and it reduced the size of EPC efficiently. So according to what you said, I can't shrink the EPC part of my enclave more than that?

 

-M

 

0 Kudos
JesusG_Intel
Moderator
946 Views

Hello Meysam,

You should minimize the number of Trusted Threads via the TCSNum parameter in your enclave config file. This will impact your memory usage significantly as your total allocation for stack is TCSNum * StackMaxSize. There are no other memory optimization techniques you can do at the enclave config level.

Regards,

Jesus

0 Kudos
Meysam_t_
Beginner
946 Views

Thank you Jesus,

yes, it worked. It reduced the number of EPC pages for my enclave significantly. 

I appreciate your timely help. 

 

-Meysam

 

0 Kudos
Reply