安装Intel SGX
-
SGX Driver:cpu不支持DCAP,根据官方github安装
-
SGX PSW:根据安装手册添加源,再直接使用apt安装:
1
2
3
4
5echo 'deb [arch=amd64] https://download.01.org/intel-sgx/sgx_repo/ubuntu focal main' | sudo tee /etc/apt/sources.list.d/intel-sgx.list
wget -qO - https://download.01.org/intel-sgx/sgx_repo/ubuntu/intel-sgx-deb.key | sudo apt-key add
sudo apt-get update
sudo apt-get install libsgx-launch libsgx-urts libsgx-epid libsgx-quote-ex libsgx-dcap-ql libsgx-uae-service
sudo apt-get install libsgx-urts-dbgsym libsgx-enclave-common-dbgsym libsgx-dcap-ql-dbgsym libsgx-dcap-default-qpl-dbgsym -
SGX SDK:下载bin文件,移动到
/opt/intel/
下,添加权限后直接运行
下载Rust-SGX-SDK
1 | git clone -b v1.1.4 https://github.com/apache/incubator-teaclave-sgx-sdk.git |
添加环境变量
在~/.bashrc文件最后添加:
1 | export SGX_SDK_RUST=$HOME/sgx/incubator-teaclave-sgx-sdk |
再在终端执行 source ~/.bashrc
解决:Enclave代码运行出错(Invalid SGX Driver)
不清楚什么原因,反正重装一遍SGX Driver就好了
卸载:
1 | sudo /sbin/modprobe -r isgx |
重装:
1 | cd /opt/intel/linux-sgx-driver |
解决:./app: error while loading shared libraries: libsgx_uae_service.so: cannot open shared object file: No such file or directory
错误方案:当使用find命令查询文件之后发现在 /opt/intel/sgxsdk/lib64
中包含 libsgx_uae_service.so
,从而添加该路径到LD_LIBRARY_PATH。这样会导致新的error “Please use the correct uRTS library from PSW package.”,因为sgxsdk下的lib是用作开发环境的,而在 /lib/x86_64-linux-gnu
下的lib是用于生产环境的,相互不兼容
**正确方案:**出现该问题的原因是psw安装不齐全,即libsgx-uae-service未安装,只要使用命令 sudo apt-get install libsgx-uae-service
就能成功将对应的库安装到 /lib/x86_64-linux-gnu
下
关于最新的Linux内核支持in-kernel driver
不需要再进行额外的driver安装,若有之前版本的driver,应当先卸载,然后将所有psw的组件卸载重装