rivosinc / salus

Risc-V hypervisor for TEE development
92 stars 25 forks source link

vm_cpu: Eliminate hgatp and vsatp mismatch #324

Closed dgreid closed 1 year ago

dgreid commented 1 year ago

Recently the isa manual added a clarification[1] related to avoiding invalid caching of page translation stemming from vsatp being set for one VM and hgatp configured for another transiently while running in the hypervisor.

That guidance is to use the following sequence:

To ensure that sequence in salus, set vsatp to zero when saving VM registers. Additionally, on VM restore, restore vm_pages first, setting hgatp in the process if needed, and then restore the vs csrs including vsatp.

[1] https://github.com/riscv/riscv-isa-manual/pull/1111/files#diff-519b8bf20dee5e4eba1d389aea0a9c430c3e508a4f7518125582c055cccdc6ebR1680