Skip to content

Penglai Enclave User Documentation

DongDu edited this page Dec 31, 2019 · 1 revision

Writing a helloworld enclave app

An enclave application is separated into two parts:eapp and host, we have provided some simple demos in /sdk/demo. You can run your own applications in the penglai enclave with the slight modification.

1. Writing an eapp

We have already provided an user librarylibpenglai-enclave-eapp.a and hdr fileeapp.h, make sure you have linked the library and included the hdr file. If you want to run your own eapp, you need to modify two parts in your native code: entry point and exit point.

Entry ponit: The first instruction after jumping into main function is to reserve the general registers in stack, var args points to the stack address holding the general registers(you can learn more details in eapp.h, such as register memory layout). We have provided an marco EAPP_RESERVE_REG to help you finish it. After restoring all general registers, you can invoke your own function using the parameter args

  unsigned long * args;
  EAPP_RESERVE_REG;
  your_own_function(args);

Exit point: We have provided a specific return instruction to replace the normal ret instruction, you can invoke EAPP_RETURN to reclaim you eapp and return to host.