[Pal] Consolidate db_*.c for Pal/Linux and Pal/Linux-SGX
Note that this is just a proposal/WIP. I'd like to have some feedbacks before updating all the related files.
db_*.c of Pal/Linux and Pal/Linux_SGX are mostly following the same logic to implement narrow Drawbridge-like ABI interfaces where the only difference is host syscall or ocall. Maintaining them separately may lead to inconsistent behaviors when bugs are fixed in one place but not in the other and may consequently raise the maintenance cost.
This patch proposes to:
- share code of
db_*.cin Pal/Linux and Pal/Linux_SGX - have the common code maintained in Pal/Linux-common
- determine the hostcall type thru conditional compilation
- leverage the unified hostcall for syscall or ocall
Partially addresses https://github.com/gramineproject/gramine/issues/14
Related to https://github.com/gramineproject/graphene/issues/443
How to test this PR?
Based on the discussions in the 2.28 community meeting, the general idea/plan is to:
- Similar to this PR proposal, still move the common/generic parts of
db_*.cinto Pal/Linux-common; - Instead of using macros, leverage
call_xxxon link-time for backend-specific code; - Implement back-end specific code (incl. syscall or ocall) in Pal/Linux and Pal/Linux-SGX separately;
- Hold and to follow up on this one after the trusted/protected fs rewrite completes.
Pls kindly correct me and/or extend if I understand anything wrong. Thanks!
- Instead of using macros, leverage
call_xxxon link-time for backend-specific code;
I vote for hostcall_xxx prefix.
- Instead of using macros, leverage
call_xxxon link-time for backend-specific code;I vote for
hostcall_xxxprefix.
Thanks @dimakuv! I used a dummy name to simply illustrate the idea (also to differ from ocall_xxx). Personally I also vote for hostcall_xxx prefix.