Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More memory for larger programs #30

Open
Syscoder1441 opened this issue Jan 27, 2016 · 3 comments
Open

More memory for larger programs #30

Syscoder1441 opened this issue Jan 27, 2016 · 3 comments

Comments

@Syscoder1441
Copy link

How can we run programs with greater memory requirements in opensgx? I changed the NUM_EPC and ENCLAVE_SIZE in qemu/target-i386/SGX.h and rebuilt qemu, but when I run the hello program, I see no changes in pre-allocated EPC SSA region and Heap region. I was able to compile my program using opensgx but I get a seg fault when running it. I suspect it is because of the limits in the size of the enclave.

@jaebaek
Copy link
Contributor

jaebaek commented Jan 28, 2016

You must modify three header files:

qemu/target-i386/sgx.h
libsgx/musl-libc/include/sgx-shared.h
user/share/include/sgx-shared.h

There is NUM_EPC in each header.
If you need more heap region, just increase the value of HEAP_PAGE_FRAMES too.

The size of EPC SSA region (and other memory sizes) is determined by sys_create_enclave() function in user/sgx-kern.c file.
Check out the variable named ssa_npages.

Since the following three lines (477~479 in user/sgx-kern.c file) can cause a side effect, you should be careful to change the size of each region:

int npages = sec_npages + tcs_npages + tls_npages \
+ code_pages + ssa_npages + stack_npages + heap_npages;
npages = rop2(npages);

rop2(A) gets the least integer larger than npages that is a power of 2.
If your setting makes rop2(npages) larger than NUM_EPC specified in qemu/target-i386/sgx.h (i.e., the number of EPC provided by the hardware), alloc_epc_pages() in line 483 cannot allocate the EPC.

@Syscoder1441
Copy link
Author

Thanks. I was able to increase the heap size but when I increase the ssa_npages variable it crashes.

I'm still getting a segmentation fault. Here are the last few lines. Can you tell what might be the problem.

TCS address : 4fffd000
Pre-allocated EPC SSA region : 0x2000
Pre-allocated EPC Heap region : 0x5dc000
Later-Augmented EPC Heap region : 0x0
Total EPC Heap region : 0x5dc000
CPU_SIGNAL_HANDLER 11
user-exec.c Called exception_action
Exception Action
Debug Raise Exception: RBP: 2 RSP: 501d0cf8 EIP: 50080d31
POE_PAGE
MAPERR
qemu: uncaught target signal 11 (Segmentation fault) - core dumped
./sgx: line 11: 39956 Segmentation fault (core dumped) $QEMU "$@"

@rainycheng
Copy link

@Syscoder1441
Have you address the above problem? I met the same problem when I run an application in the opensgx.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants