Riscv取消Host/Guest切换过程中对hstatus的保存恢复 #117
shilei-massclouds
started this conversation in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
在Riscv体系架构下,在VMEntry/VMExit过程中不必保存和恢复寄存器hstatus。
寄存器hstatus的作用
hstatus跟踪和控制面向VS的异常行为,例如第7位控制当sret时,是返回VS还是返回U。
具体内容见特权指令手册H扩展中,第18.2.1节的说明。
目前的实现和修改理由
在Host/Guest切换的过程中,即VMEntry/VMExit过程中,有一个保存/恢复hstatus状态的动作。
但是这个是不必要的,根据指令手册,Guest不会去修改hstatus的值。而且从原理分析,如果Guest能够改,那么就是个安全漏洞,riscv应该不会犯这种错误。目前也没有想到其他部分会在切换到Guest的期间去修改这个hstatus值。这个hstatus只能是在Host中修改,要么是在首次初始化过程中,要么是在每次VM-Exit之后和再次VM-Entry之前。
具体的修改
patch内容:
涉及多vCPU切换情况的补充说明
由于存在多vCPU共享同一个物理CPU的情况,所以仍然保留了HypervisorCpuState结构中的hstatus成员。
Beta Was this translation helpful? Give feedback.
All reactions