opensgx
opensgx copied to clipboard
More memory for larger programs
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.
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.
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 "$@"
@Syscoder1441 Have you address the above problem? I met the same problem when I run an application in the opensgx.