gramine icon indicating copy to clipboard operation
gramine copied to clipboard

[Pal] Consolidate db_*.c for Pal/Linux and Pal/Linux-SGX

Open kailun-qin opened this issue 3 years ago • 7 comments

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_*.c in 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?


This change is Reviewable

kailun-qin avatar Feb 28 '22 06:02 kailun-qin

Based on the discussions in the 2.28 community meeting, the general idea/plan is to:

  1. Similar to this PR proposal, still move the common/generic parts of db_*.c into Pal/Linux-common;
  2. Instead of using macros, leverage call_xxx on link-time for backend-specific code;
  3. Implement back-end specific code (incl. syscall or ocall) in Pal/Linux and Pal/Linux-SGX separately;
  4. 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!

kailun-qin avatar Feb 28 '22 16:02 kailun-qin

  1. Instead of using macros, leverage call_xxx on link-time for backend-specific code;

I vote for hostcall_xxx prefix.

dimakuv avatar Mar 01 '22 07:03 dimakuv

  1. Instead of using macros, leverage call_xxx on link-time for backend-specific code;

I vote for hostcall_xxx prefix.

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.

kailun-qin avatar Mar 01 '22 08:03 kailun-qin