Ubunt20.04 安装 Gramine

参考资料

Gramine Quick start

Gramine安装

Gramine安装要求:

安装过程如下:

sudo curl -fsSLo /usr/share/keyrings/gramine-keyring.gpg https://packages.gramineproject.io/gramine-keyring.gpg
echo "deb [arch=amd64 signed-by=/usr/share/keyrings/gramine-keyring.gpg] https://packages.gramineproject.io/ $(lsb_release -sc) main" \
| sudo tee /etc/apt/sources.list.d/gramine.list

sudo curl -fsSLo /usr/share/keyrings/intel-sgx-deb.asc https://download.01.org/intel-sgx/sgx_repo/ubuntu/intel-sgx-deb.key
echo "deb [arch=amd64 signed-by=/usr/share/keyrings/intel-sgx-deb.asc] https://download.01.org/intel-sgx/sgx_repo/ubuntu $(lsb_release -sc) main" \
| sudo tee /etc/apt/sources.list.d/intel-sgx.list

sudo apt-get update
sudo apt-get install gramine

Encalve 签名密钥生成

gramine-sgx-gen-private-key

生成 RSA 3072 key,该密钥用于签名enclave,存储在 HOME/.config/gramine/enclave-key.pem该密钥需要保护好,不能泄露给任何人。

运行helloworld

sudo apt-get install gcc make  # for Ubuntu distribution
git clone --depth 1 --branch v1.4 https://github.com/gramineproject/gramine.git
cd gramine/CI-Examples/helloworld

不使用SGX编译

make
gramine-direct helloworld

使用SGX

make SGX=1
gramine-sgx helloworld

问题:error: Gramine with Linux-SGX backend requires support for FSGSBASE CPU instructions in the host kernel. Please update your system. private@baas-node4:~/codes/tee/gramine/CI-Examples/helloworld$

解决方法:

升级kernel到5.15

因为使用的Gramine要求kernel在5.11以上。慎用该方法,会导致其他许多问题。因为我的是空服务器,所以采用该方法。

// 更新 repo 列表
sudo apt update
// 升级系统和软件(可选)
sudo apt upgrade -y
// 重启
sudo reboot

// 列出可用的 5.15 内核版本
apt list linux-headers-5.15.*-*-generic linux-image-5.15.*-*-generic

// 其中:
// Install kernel-generic:通用内核,一般 PC 及 Server
// Install low-latency kernel:低延迟内核,适用于工业嵌入式系统(Industrial embedded systems)

// 指定版本即可,比如当前为 5.15.0-46
sudo apt install linux-headers-5.15.0-46-generic linux-image-5.15.0-46-generic

// 重启后生效
sudo reboot

uname -a

升级完kernel之后原来使用dkms安装的sdk可以卸载了。因为从kernel 5.11开始已经默认安装了SGX驱动。

参考文档:

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值