Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Meysam_t_
Beginner
205 Views

The number of allocated pages to the enclave

Jump to solution

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
205 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

6 Replies
JesusG_Intel
Moderator
205 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

Meysam_t_
Beginner
205 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. 

 

JesusG_Intel
Moderator
205 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

Meysam_t_
Beginner
205 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

 

JesusG_Intel
Moderator
206 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

Meysam_t_
Beginner
205 Views

Thank you Jesus,

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

I appreciate your timely help. 

 

-Meysam

 

Reply