项目标题:RISC-V虚拟化技术调研与分析
项目描述:RISC-V虚拟化技术的调研和实现分析
项目难度:进阶
项目社区导师:@walimis
导师联系方式:walimis@walimis.org
合作导师联系方式:
项目产出要求:
学习运行RISC-V KVM:
通过阅读规范,产出如下文档:
通过阅读kvm/qemu/kvmtool/spike代码,产出如下文档:
通过学习代码,可以提交一些patch到riscv kvm upstream
项目技术要求:
实习计划:
参考书籍:
参考资料:
相关的开源软件仓库列表:
考核任务,写一份中文指南:
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。
参照wiki boot Host/Guest Linux
make lkvm-static
出现问题Makefile:357: *** No libfdt found. Please install libfdt-dev package. Stop.
, 但不论是通过手动编译还是apt下载安装都无法使之检测到libfdt。尝试找出昨天出错的问题,在运行Ubuntu操作系统的机器上进行昨日的步骤。
No libfdt found.
错误或因此导致。
$ egrep -c '(vmx|svm)' /proc/cpuinfo
0
rmmod kvm
指令卸载kvm module
apt install gcc-riscv64-linux-gnu
解决了libfdt
无法用于kvmtool
编译的问题(后续qemu x-h=true
问题解决,应该可以正常运行,还未尝试)apt install gcc-riscv64-linux-gnu
安装工具链的可用性。推测或许因为桌面环境以及已有配置较为复杂,apt
安装和本地编译并不能完全支持后续步骤:
apt install gcc-riscv64-linux-gnu
安装的工具链缺乏ld
,无法链接程序riscv64-unknown-linux-gnu-gcc
足够齐全,但是头文件配置出现问题(busybox build rootFS step)Linux Lab 中已经完整支持所有的工具链的,也是一种候选的方式,一开始就是推荐搭建统一使用这个环境,对齐后续实验的环境。Ubuntu 20.04 + Qemu v6.2.0 + RISC-V toolchains + Linux Kernel 源码 + riscv64/virt 虚拟开发板,全部是一应俱全的。Linux Lab Disk 则连安装都不需要,直接可用。
如下是我ubuntu上安装的riscv相关的编译软件:
binutils-riscv64-linux-gnu
cpp-9-riscv64-linux-gnu
cpp-riscv64-linux-gnu
gcc-9-riscv64-linux-gnu
gcc-9-riscv64-linux-gnu-base:amd64
gcc-riscv64-linux-gnu
libatomic1-riscv64-cross
libc6-dev-riscv64-cross
libc6-riscv64-cross
libgcc-9-dev-riscv64-cross
libgcc-s1-riscv64-cross
libgomp1-riscv64-cross
linux-libc-dev-riscv64-cross
riscv-privileged
8.1-8.2.1mstatus, hstatus, sstatus
),产出原始文档
提交分析文章 20220723-virt-mode.md Pull Request.
提交 20220729-kvm-hello-world.md
Upload an introduction about Risc-V virtualization plans
@XiakaiPan @walimis @trueptolemy 类似这样的新特性也可以撰写文章分析一下:https://lwn.net/ml/linux-kernel/20220722230241.1944655-1-avagin@google.com/
[PATCH 0/5] KVM/x86: add a new hypercall to execute host system
There is a class of applications that use KVM to manage multiple address
spaces rather than use it as an isolation boundary. In all other terms,
they are normal processes that execute system calls, handle signals,
etc. Currently, each time when such a process needs to interact with the
operation system, it has to switch to host and back to guest. Such
entire switches are expensive and significantly increase the overhead of
system calls. The new hypercall reduces this overhead by more than two
times.
The new hypercall runs system calls on the host. As for native system
calls, seccomp filters are executed before system calls. It takes one
argument that is a pointer to a pt_regs structure in the host address
space. It provides registers to execute a system call according to the
calling convention. Arguments are passed in %rdi, %rsi, %rdx, %r10, %r8
and %r9 and a return code is stored in %rax.
The hypercall returns 0 if a system call has been executed. Otherwise,
it returns an error code.
This series introduces a new capability that has to be set to enable the
hypercall. The new hypercall is a backdoor for regular virtual machines,
so it is disabled by default. There is another standard way to allow
hypercalls via cpuid. It has not been used because one of the common
ways to manage them is to request all available features and let them
all together. In this case, it is a hard requirement that the new
hypercall can be enabled only intentionally.
Update 20220729-kvm-user-app.md with kvmtool and QEMU analysis.
Commit PR.
DONE:
SFENCE
, HFENCE
指令解析mstatus
, hstatus
, sstatus
, vsstatus
对应关系解析HALF DONE:
status
CSR 比较(field 划分及其在两级地址转换中的功能)atp
CSR 比较(satp
与 hgatp
, vsatp
对应关系)S | Status | H | Status | INVAL | Status | CSRs | Status |
---|---|---|---|---|---|---|---|
SFENCE | DONE | HFENCE | DONE | INVAL... | TODO | status | Ongoing |
Basic Page-Based Address Translation | TODO | 2-Stage | Ongoing | atp | Ongoing | ||
Simulator Implementation | TODO | Simulator Implementation | TODO | Simulator Implementation | TODO | trap | TODO |
interrupt | TODO | ||||||
exception | TODO | ||||||
time | TODO | ||||||
config/performance/security | TODO |
Half Done:Basic Page-Based Address Translation in S-Mode
DONE:CSR xstatus
Ongoing: Basic Page-Based Address Translation, 2-Stage AT
Reviewed 20220802-kvm-user-app.md.
PR of 20220812-mem-virt-rv-1.md.
Half done 20220812-mem-virt-rv-2.md
Status | Address Translation | 2-Stage AT |
---|---|---|
Done | Mechanism Flowchart | |
Ongoing | Spike implementation analysis | G-Stage |
Update 20220802-kvm-user-app.md and 20220812-mem-virt-rv-1.md.
Verify the method of inserting URL.
Optimize the commit log of PR.
Ongoing: Implementation of PTW in Spike.
Done: Sinval extension.
这个虚拟化的专栏可以关注一下:https://zhuanlan.zhihu.com/p/565787442
Modify last article about memory management.
Finish part of h-extension trap mechanism analysis (basic CSR, instructions).
TODO:
Figure out the function of MIP/MIE, SIP/SIE, HVIP/HIP/HIE and HGEIP/HGEIE.
Analyse how H-Ext. CSR HIP/HIE work with SIP/SIE to finish S-level trap handling.
TODO:
The hardware difference between machines that have H-Support and not. (QEMU)
Simulator implementation of extra hypervisor related trap. (Spike)
Figure out the function of hardware, OS (including KVM module), kvmtool and guest OS in the process of 2-stage address translation.
Figure out the function of hardware, OS (including KVM module), kvmtool and guest OS in the process of trap handling.
Modification of last article about Memory Management of H-Mode. Submit PR.
Finish an analysis article of trap handling. Submit PR.
Try tinycorrect to auto review articles, find out several shortcuts:
tinycorrect.sh
, but failed because of:
cd path/to/tico && . tinycorrect.sh
: to be solvedimages/riscv-kvm/mem-virt-2/mermaid-riscv-kvm-mem-virt-2-1.png
for article named riscv-kvm-mem-virt-2.md
. I think it's necessary to validate the specific partition mechanism: to be solved.Future work plan: KVM Implementation of
Today update:
Go through the inner function calling situation in KVM.
Refer to memory allocation implementation of Linux Buddy memory manager.
kvmtool/riscv/
Week Update
@XiakaiPan 第一阶段看看什么时候收尾,收尾后记得改为 “已完成” 状态。
登录 后才可以发表评论