incubator-teaclave-sgx-sdk icon indicating copy to clipboard operation
incubator-teaclave-sgx-sdk copied to clipboard

Implement enclave memory management

Open ClawSeven opened this issue 1 year ago • 8 comments

ClawSeven avatar Jun 09 '23 11:06 ClawSeven

@ClawSeven Hi, I notice two issues with your PR:

  1. your emm sample code cannot be built with BUILD_STD=cargo
  2. I merged your commits in this PR into the current v2.0.0-preview branch to support the latest rust toolchain as this fork branch, however, I see problems with httpreq sample code, it will have pointer alignment issues while doing ocall "u_getaddrinfo_ocall", the pointer address of the argument and the return value is misaligned, which will cause panic in the repo. It seems that your implementation has some conflicts with the recent Rust toolchain. Please take a look, thank you!

yangfh2004 avatar Feb 16 '24 22:02 yangfh2004

@ClawSeven Hi, I notice two issues with your PR:

  1. your emm sample code cannot be built with BUILD_STD=cargo
  2. I merged your commits in this PR into the current v2.0.0-preview branch to support the latest rust toolchain as this fork branch, however, I see problems with httpreq sample code, it will have pointer alignment issues while doing ocall "u_getaddrinfo_ocall", the pointer address of the argument and the return value is misaligned, which will cause panic in the repo. It seems that your implementation has some conflicts with the recent Rust toolchain. Please take a look, thank you!

Is upgrading Intel SGX SDK to 2.21 to enable EDMM?

volcano0dr avatar Feb 18 '24 02:02 volcano0dr

@ClawSeven Hi, I notice two issues with your PR:

  1. your emm sample code cannot be built with BUILD_STD=cargo
  2. I merged your commits in this PR into the current v2.0.0-preview branch to support the latest rust toolchain as this fork branch, however, I see problems with httpreq sample code, it will have pointer alignment issues while doing ocall "u_getaddrinfo_ocall", the pointer address of the argument and the return value is misaligned, which will cause panic in the repo. It seems that your implementation has some conflicts with the recent Rust toolchain. Please take a look, thank you!

Is upgrading Intel SGX SDK to 2.21 to enable EDMM?

Thanks a lot for your reply, we are using SGX2 on 3rd Gen Xeon Scalable Processor with MKTME, and we will need large dynamic heap allocations. We are now using v1.1.6 with Intel SGX SDK 2.21. We are trying to upgrade to v2.0.0 with support to the later Rust toolchain.

yangfh2004 avatar Feb 18 '24 18:02 yangfh2004

@ClawSeven Hi, I notice two issues with your PR:

  1. your emm sample code cannot be built with BUILD_STD=cargo
  2. I merged your commits in this PR into the current v2.0.0-preview branch to support the latest rust toolchain as this fork branch, however, I see problems with httpreq sample code, it will have pointer alignment issues while doing ocall "u_getaddrinfo_ocall", the pointer address of the argument and the return value is misaligned, which will cause panic in the repo. It seems that your implementation has some conflicts with the recent Rust toolchain. Please take a look, thank you!

The second issue has an easy fix, essentially, all problems are due to the alignment checks in dereference of raw pointers. We just need to use read_unaligned or write_unaligned

I also fixed the first issue. Rust_STD_Features in the Makefile needs to include thread.

yangfh2004 avatar Feb 19 '24 16:02 yangfh2004

@yangfh2004 , Hi, thanks for your two issue.

  1. Regarding the first issue, I have managed to replicate it and have confirmed that the Makefile for the EMM sample code indeed requires thread feature activation. I will address and resolve this promptly.

  2. As for the second issue, I am unable to reproduce the scenario you've described. In my environment, the httpreq sample code works well without any panic. Could you please provide the version of your toolchain so that I can further investigate this matter?

ClawSeven avatar Feb 23 '24 09:02 ClawSeven

@yangfh2004 Btw, I have tested the httpreq with rustc 1.78.0-nightly (397937d81 2024-02-22). It also worked well.

ClawSeven avatar Feb 23 '24 09:02 ClawSeven

@ClawSeven Hi, our team is using your emm branch, which works OK. But we want to request some supports to the simulation mode (SW mode) so that we can build and run our enclave without sgx drivers. Do you have a chance to add SW supports to your branch? Thanks

yangfh2004 avatar Apr 24 '24 18:04 yangfh2004

@yangfh2004 Hello, I'm pleased to know that the EDMM feature has been integrated into your project. Unfortunately, the simulation mode (SW mode) for EDMM is not on our current roadmap, primarily because Intel does not offer support for EDMM in SW mode, and I am currently at full capacity, preventing me from undertaking the implementation of this feature.

However, conceptually speaking, I believe the SW mode could be relatively straightforward to implement using system calls like mmap and munmap.

ClawSeven avatar May 27 '24 09:05 ClawSeven