apache / incubator-teaclave-sgx-sdk

Apache Teaclave (incubating) SGX SDK helps developers to write Intel SGX applications in the Rust programming language, and also known as Rust SGX SDK.
https://teaclave.apache.org
Apache License 2.0
1.17k stars 263 forks source link

Use simulation mode on MacOS #318

Open blmalone opened 3 years ago

blmalone commented 3 years ago

Specs: MacBook Pro (16-inch, 2019), 2.3 GHz 8-Core Intel Core i9

When following the instructions outlined here.

I get the following error:

./lib/libenclave.a(sgx_trts-e1de7fe3db2688ea.sgx_trts.c1x8g4sc-cgu.2.rcgu.o): In function `sgx_trts::enclave::SgxGlobalData::new::hd171d7330c2c7ee0':
sgx_trts.c1x8g4sc-cgu.2:(.text._ZN8sgx_trts7enclave13SgxGlobalData3new17hd171d7330c2c7ee0E+0xa5): undefined reference to `get_rsrv_base'
sgx_trts.c1x8g4sc-cgu.2:(.text._ZN8sgx_trts7enclave13SgxGlobalData3new17hd171d7330c2c7ee0E+0xb2): undefined reference to `get_rsrv_size'
collect2: error: ld returned 1 exit status
Makefile:155: recipe for target 'enclave/enclave.so' failed
make: *** [enclave/enclave.so] Error 1

Steps to reproduce:

1. docker pull baiduxlab/sgx-rust-stable
2. docker run -v /Users/<user.name>/code/incubator-teaclave-sgx-sdk:/root/sgx -ti baiduxlab/sgx-rust-stable
3. cd sgx/samplecode/helloworld/
4. Edited the Makefile to run in SW mode 
5. make && cd bin
6. ./app

I've seen some closed issues in this repo that report similar errors, but none fix this exact issue.

Side Notes:

Astewart1510 commented 3 years ago

Can this be escalated? I am also wanting to know if this is possible in simulation mode.

glassonion1 commented 3 years ago

I created some sample programs that runs Rust SGX SDK here. https://github.com/glassonion1/rust-101/tree/main/sgx-sdk

Astewart1510 commented 3 years ago

I created some sample programs that runs Rust SGX SDK here. https://github.com/glassonion1/rust-101/tree/main/sgx-sdk

Thanks @glassonion1 !! and this was all done in simulation mode running on a Macbook Pro with a 2.3 GHz 8-Core Intel Core i9 ? Do you by any chance know if we can run Intel SGX in simulation mode on an M1 chip?

glassonion1 commented 3 years ago

My sample programs run on Intel Mac except remote attestation and mutual-ra. But I don't know if it works on M1 Mac.

Astewart1510 commented 3 years ago

@glassonion1 thanks so much. Would be very interested to know if it works in Simulation mode on Apples M1 Chip. Reason being is i am looking for a new Mac. Thanks again.

Astewart1510 commented 2 years ago

Just asking this again - anyone managed to run the intel sgx rust sdk sample code on M1 chip even in simulation mode using docker?

h4n0 commented 2 years ago

I am using sgx sdk on my MacBook Pro M1, and it failed with simulation mode with the following error:

Unknown host CPU architecture arm64

From here it can be easily found that only x86 arch is supported. https://github.com/apache/incubator-teaclave-sgx-sdk/blob/master/buildenv.mk#L104

Are there any plans for arm64 support?

Astewart1510 commented 2 years ago

I am using sgx sdk on my MacBook Pro M1, and it failed with simulation mode with the following error:

Unknown host CPU architecture arm64

From here it can be easily found that only x86 arch is supported. https://github.com/apache/incubator-teaclave-sgx-sdk/blob/master/buildenv.mk#L104

Are there any plans for arm64 support?

This would be much needed …. Or some kind of workaround at least

dingelish commented 2 years ago

hi @Astewart1510 this is almost impossible. teaclave sgx sdk is built on top of intel sgx sdk which is x86 only. we can make rust part compile but i'm afraid we can't make intel sgx sdk compile on arm64.

Astewart1510 commented 2 years ago

hi @dingelish Thanks for the clarity. I suppose I would have to start using the TrustZone SDK? Would that be compatible with a Macbook Pro M1 chip?

dingelish commented 2 years ago

@Astewart1510 here you go https://github.com/apache/incubator-teaclave-trustzone-sdk

Astewart1510 commented 2 years ago

@dingelish , sorry wanted to ask if it's possible to change the docker image in such a way that the architecture of the container is x86 ? Therefore the Intel SGX would be able to run on simulation mode on a M1 Mac using a x86 docker image.

n34l3h commented 2 years ago

Is it possible to use SGX simulation mode on a 2015 mbp with a 2.2 i7-4770HQ? The main purpose would be for playing/ripping UHD4k Blu-ray Discs as this requires SGX.

If this could work, any advice on installation etc would be very welcome. Thanks Neale