|
@@ -362,7 +362,71 @@ static bool __hyp_text fixup_guest_exit(struct kvm_vcpu *vcpu, u64 *exit_code)
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
-int __hyp_text __kvm_vcpu_run(struct kvm_vcpu *vcpu)
|
|
|
+/* Switch to the guest for VHE systems running in EL2 */
|
|
|
+int kvm_vcpu_run_vhe(struct kvm_vcpu *vcpu)
|
|
|
+{
|
|
|
+ struct kvm_cpu_context *host_ctxt;
|
|
|
+ struct kvm_cpu_context *guest_ctxt;
|
|
|
+ bool fp_enabled;
|
|
|
+ u64 exit_code;
|
|
|
+
|
|
|
+ vcpu = kern_hyp_va(vcpu);
|
|
|
+
|
|
|
+ host_ctxt = kern_hyp_va(vcpu->arch.host_cpu_context);
|
|
|
+ host_ctxt->__hyp_running_vcpu = vcpu;
|
|
|
+ guest_ctxt = &vcpu->arch.ctxt;
|
|
|
+
|
|
|
+ __sysreg_save_host_state(host_ctxt);
|
|
|
+
|
|
|
+ __activate_traps(vcpu);
|
|
|
+ __activate_vm(vcpu);
|
|
|
+
|
|
|
+ __vgic_restore_state(vcpu);
|
|
|
+ __timer_enable_traps(vcpu);
|
|
|
+
|
|
|
+ /*
|
|
|
+ * We must restore the 32-bit state before the sysregs, thanks
|
|
|
+ * to erratum #852523 (Cortex-A57) or #853709 (Cortex-A72).
|
|
|
+ */
|
|
|
+ __sysreg32_restore_state(vcpu);
|
|
|
+ __sysreg_restore_guest_state(guest_ctxt);
|
|
|
+ __debug_switch_to_guest(vcpu);
|
|
|
+
|
|
|
+ do {
|
|
|
+ /* Jump in the fire! */
|
|
|
+ exit_code = __guest_enter(vcpu, host_ctxt);
|
|
|
+
|
|
|
+ /* And we're baaack! */
|
|
|
+ } while (fixup_guest_exit(vcpu, &exit_code));
|
|
|
+
|
|
|
+ fp_enabled = __fpsimd_enabled();
|
|
|
+
|
|
|
+ __sysreg_save_guest_state(guest_ctxt);
|
|
|
+ __sysreg32_save_state(vcpu);
|
|
|
+ __timer_disable_traps(vcpu);
|
|
|
+ __vgic_save_state(vcpu);
|
|
|
+
|
|
|
+ __deactivate_traps(vcpu);
|
|
|
+ __deactivate_vm(vcpu);
|
|
|
+
|
|
|
+ __sysreg_restore_host_state(host_ctxt);
|
|
|
+
|
|
|
+ if (fp_enabled) {
|
|
|
+ __fpsimd_save_state(&guest_ctxt->gp_regs.fp_regs);
|
|
|
+ __fpsimd_restore_state(&host_ctxt->gp_regs.fp_regs);
|
|
|
+ }
|
|
|
+
|
|
|
+ /*
|
|
|
+ * This must come after restoring the host sysregs, since a non-VHE
|
|
|
+ * system may enable SPE here and make use of the TTBRs.
|
|
|
+ */
|
|
|
+ __debug_switch_to_host(vcpu);
|
|
|
+
|
|
|
+ return exit_code;
|
|
|
+}
|
|
|
+
|
|
|
+/* Switch to the guest for legacy non-VHE systems */
|
|
|
+int __hyp_text __kvm_vcpu_run_nvhe(struct kvm_vcpu *vcpu)
|
|
|
{
|
|
|
struct kvm_cpu_context *host_ctxt;
|
|
|
struct kvm_cpu_context *guest_ctxt;
|