Merge tag 'for-linus' of git://git.kernel.org/pub/scm/virt/kvm/kvm
[sfrench/cifs-2.6.git] / arch / arm64 / kvm / hyp / include / hyp / switch.h
index d0f07e8cc3ffad66be72a3306797a78c9dc442f7..313a8fa3c721d66eb22867b2d2eb8d0359b5e988 100644 (file)
@@ -126,11 +126,6 @@ static inline void ___deactivate_traps(struct kvm_vcpu *vcpu)
        }
 }
 
        }
 }
 
-static inline void __activate_vm(struct kvm_s2_mmu *mmu)
-{
-       __load_guest_stage2(mmu);
-}
-
 static inline bool __translate_far_to_hpfar(u64 far, u64 *hpfar)
 {
        u64 par, tmp;
 static inline bool __translate_far_to_hpfar(u64 far, u64 *hpfar)
 {
        u64 par, tmp;
@@ -377,6 +372,8 @@ static inline bool esr_is_ptrauth_trap(u32 esr)
        ctxt_sys_reg(ctxt, key ## KEYHI_EL1) = __val;                   \
 } while(0)
 
        ctxt_sys_reg(ctxt, key ## KEYHI_EL1) = __val;                   \
 } while(0)
 
+DECLARE_PER_CPU(struct kvm_cpu_context, kvm_hyp_ctxt);
+
 static inline bool __hyp_handle_ptrauth(struct kvm_vcpu *vcpu)
 {
        struct kvm_cpu_context *ctxt;
 static inline bool __hyp_handle_ptrauth(struct kvm_vcpu *vcpu)
 {
        struct kvm_cpu_context *ctxt;
@@ -386,7 +383,7 @@ static inline bool __hyp_handle_ptrauth(struct kvm_vcpu *vcpu)
            !esr_is_ptrauth_trap(kvm_vcpu_get_esr(vcpu)))
                return false;
 
            !esr_is_ptrauth_trap(kvm_vcpu_get_esr(vcpu)))
                return false;
 
-       ctxt = &__hyp_this_cpu_ptr(kvm_host_data)->host_ctxt;
+       ctxt = this_cpu_ptr(&kvm_hyp_ctxt);
        __ptrauth_save_key(ctxt, APIA);
        __ptrauth_save_key(ctxt, APIB);
        __ptrauth_save_key(ctxt, APDA);
        __ptrauth_save_key(ctxt, APIA);
        __ptrauth_save_key(ctxt, APIB);
        __ptrauth_save_key(ctxt, APDA);
@@ -481,14 +478,13 @@ exit:
 
 static inline void __kvm_unexpected_el2_exception(void)
 {
 
 static inline void __kvm_unexpected_el2_exception(void)
 {
+       extern char __guest_exit_panic[];
        unsigned long addr, fixup;
        unsigned long addr, fixup;
-       struct kvm_cpu_context *host_ctxt;
        struct exception_table_entry *entry, *end;
        unsigned long elr_el2 = read_sysreg(elr_el2);
 
        entry = hyp_symbol_addr(__start___kvm_ex_table);
        end = hyp_symbol_addr(__stop___kvm_ex_table);
        struct exception_table_entry *entry, *end;
        unsigned long elr_el2 = read_sysreg(elr_el2);
 
        entry = hyp_symbol_addr(__start___kvm_ex_table);
        end = hyp_symbol_addr(__stop___kvm_ex_table);
-       host_ctxt = &__hyp_this_cpu_ptr(kvm_host_data)->host_ctxt;
 
        while (entry < end) {
                addr = (unsigned long)&entry->insn + entry->insn;
 
        while (entry < end) {
                addr = (unsigned long)&entry->insn + entry->insn;
@@ -503,7 +499,8 @@ static inline void __kvm_unexpected_el2_exception(void)
                return;
        }
 
                return;
        }
 
-       hyp_panic(host_ctxt);
+       /* Trigger a panic after restoring the hyp context. */
+       write_sysreg(__guest_exit_panic, elr_el2);
 }
 
 #endif /* __ARM64_KVM_HYP_SWITCH_H__ */
 }
 
 #endif /* __ARM64_KVM_HYP_SWITCH_H__ */