seL4 入门
最近在学习微内核和虚拟化的知识,seL4是经过形式化验证的微内核,并且也是一个hypervisor,很值得学习一下~ 之前没有看过源码,现在没办法必须要看一下了。
sel4-tutorials 配置
下面是运行 sel4-tutorials 需要配置的内容。
环境
- ubuntu 22.04.03
- ARM QEMU
配置
基础依赖
sudo apt-get update
sudo apt-get install build-essential
sudo apt-get install cmake ccache ninja-build cmake-curses-gui
sudo apt-get install libxml2-utils ncurses-dev
sudo apt-get install curl git doxygen device-tree-compiler
sudo apt-get install u-boot-tools
sudo apt-get install python3-dev python3-pip python-is-python3
sudo apt-get install protobuf-compiler python3-protobuf
ARM Qemu
sudo apt-get install qemu-system-arm qemu-system-x86 qemu-system-misc
ARM交叉编译
sudo apt-get install gcc-arm-linux-gnueabi g++-arm-linux-gnueabi
sudo apt-get install gcc-aarch64-linux-gnu g++-aarch64-linux-gnu
Python依赖
pip3 install --user setuptools
pip3 install --user sel4-deps
pip install --user aenum
pip install --user pyelftools
获取tutorials代码。获取前要注意一下网络这些问题,记录在下面的备注里了。
apt install repo
mkdir sel4-tutorials-manifest
cd sel4-tutorials-manifest
# 下面这两个试了好几次才成功
repo init -u https://github.com/seL4/sel4-tutorials-manifest
repo sync
备注:
与网络相关的问题 (这地方卡了很久),还有 git 配置等。
- 修改repo源
sudo vim /usr/bin/repo
# 修改repo
# REPO_URL = 'https://gerrit.googlesource.com/git-repo'
REPO_URL = 'https://mirrors.tuna.tsinghua.edu.cn/git/git-repo/'
- 设置全局代理
找了很久,万幸这个可以。
# 设置为 https://kkgithub.com
git config --global url."https://kkgithub.com".insteadOf https://github.com
- 如果要修改 git 配置
git config --global --edit
- 下面这部分不知道是不是必须的,记录一下
export PATH=/usr/cmake-3.23.0-linux-x86_64/bin:$PATH
# 因为缺少模块,所以安装
pip install sortedcontainers
运行 Hello world!
./init --tut hello-world
cd hello-world_build
# 编译
ninja
# 在qemu上运行
./simulate
运行 ./simulate
后,最后会打印出如下内容。结束的话是按 CRTL-A
, X
。
Booting all finished, dropped to user space
Hello, World!
Caught cap fault in send phase at address 0
while trying to handle:
vm fault on data at address 0 with status 0x4
in thread 0xffffff801fe08400 "rootserver" at address 0
With stack:
0x41ce98: 0x40179a
0x41cea0: 0x41cf10
0x41cea8: 0x0
0x41ceb0: 0x41cef0
0x41ceb8: 0x40123a
0x41cec0: 0x0
0x41cec8: 0x41cf30
0x41ced0: 0x41cf20
0x41ced8: 0x41cf10
0x41cee0: 0x1
0x41cee8: 0x4010f6
0x41cef0: 0x41cff0
0x41cef8: 0x4013b7
0x41cf00: 0x0
0x41cf08: 0x525000
0x41cf10: 0x41201c
然后修改一下 sel4-tutorials-manifest/hello-world/src/main.c
里的内容测试一下。就可以尝试打印出不同的内容。修改后还是要先编译一下。
ninja
./simulate
备注:
- 记录一下如何修改文件权限
chown -R clara /home/clara/test/
chmod -R 700 /home/clara/test/
P.S. 啥时候我能看懂虚拟化的部分啊,还有好多要学习的啊,来得及嘛。