intel / linux-sgx

Intel SGX for Linux*
https://www.intel.com/content/www/us/en/developer/tools/software-guard-extensions/linux-overview.html
Other
1.32k stars 539 forks source link

EDMM support #829

Open ScottLiao920 opened 2 years ago

ScottLiao920 commented 2 years ago

hi, I am using Alicloud g7t server (Intel(R) Xeon(R) Platinum 8369B), which should be SGX2-ready with EDMM support. But it seems EDMM is not available. SGX SDK & driver: SGX 2.16_reproducible from this repo & driver from linux-sgx-driver (master branch) Test case: using config.02.xml from SampleEnclave folder, it initialized HeapInitSize memory for heap instead of HeapMinSize, malloc after using all HeapInitSize failed.

Any Ideas?

lzha101 commented 2 years ago

Please use cpuid | grep SGX2 command to double confirm whether your platform supports EDMM. You can also debug into urts to confirm this - EDMM feature is enabled only if both the platform and the driver have EDMM support.

ScottLiao920 commented 2 years ago

Yes cpuid | grep SGX2 says my system supports SGX2. I tried to create enclaves with different HeapMinSize but it seems this setting doesn't affect the enclave creation time. Is this desirable for an enclave with EDMM? As for "debug into urts", which specific function or argument should I observe?

xxu36 commented 2 years ago

@ScottLiao920 In debugging session, you can set a breakpoint here, https://github.com/intel/linux-sgx/blob/508b5ee37c3b51a8330d36048adf2d273b238630/psw/urts/enclave_creator_hw_com.cpp#L71 to check whether your cpu/driver combination support EDMM or not. You can also set a breakpoint here https://github.com/intel/linux-sgx/blob/508b5ee37c3b51a8330d36048adf2d273b238630/sdk/trts/init_enclave.cpp#L160 and follow several lines of code there to check the EDMM inside the tRTS

ScottLiao920 commented 2 years ago

Tks a lot for your help. I've looked into those variables in sgx-gdb and my cpu&driver can support EDMM for sure. Also, I investigated this part: https://github.com/intel/linux-sgx/blob/508b5ee37c3b51a8330d36048adf2d273b238630/sdk/trts/init_enclave.cpp#L255 and it goes to https://github.com/intel/linux-sgx/blob/508b5ee37c3b51a8330d36048adf2d273b238630/sdk/trts/init_enclave.cpp#L261 with heap_min_size equal to HeapMinSize in my Enclave.config.xml file. I do believe all these verify the fact that my system support EDMM. However, I tried to set much different HeapMinSize (from 4kB to 3GB), and the enclave initialization time is roughly the same. Can I draw the conclusion that EDMM does not affect enclave initialization time?

tomoyasuzuki commented 1 year ago

@ScottLiao920 Were you able to use the edmm feature of SGX2 ?

For example, were you able to confirm that you can adde enclave page dynamically ? I am interested if it is possible to develop applications with sgx2 edmm on alibaba cloud.

Thank you.

blossomin commented 1 year ago

@ScottLiao920 Were you able to use the edmm feature of SGX2 ?

For example, were you able to confirm that you can adde enclave page dynamically ? I am interested if it is possible to develop applications with sgx2 edmm on alibaba cloud.

Thank you.

Currently, in-kernel driver supports edmm since linux 6.0