mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2026-05-04 17:58:48 +00:00
Unlike x86 which explicitly distinguishes guest traps and host traps (VM exits vs. IDT trap gates), risc-v unifies them to a single trap gate with bits in multiple CSRs representing the privilege mode before the trap. This commit follows this design. Due to this change the arch_vcpu_thread in risc-v was basically abandoned, and used only as a first-time entry point to guest, with the rest of the original x86 arch_vcpu_thread being re-implemented following above single-entry design. Save/restore routine is also being re-implemented to account for both hs-mode traps and v-mode traps. sscratch is used to mark the place where the context is being saved to/restored from. When sscratch is zero at the time of the trap, the context is saved into host stack. When sscratch is non-zero, the context is saved to vcpu->arch.regs (similar for restore). Tracked-On: #8841 Signed-off-by: Yifan Liu <yifan1.liu@intel.com> Signed-off-by: Haicheng Li <haicheng.li@intel.com> Acked-by: Wang Yu1 <yu1.wang@intel.com>