Merge tag 'cris-for-4.9' of git://git.kernel.org/pub/scm/linux/kernel/git/jesper...
[cascardo/linux.git] / arch / arm64 / kvm / inject_fault.c
index e9e0e6d..da6a8cf 100644 (file)
@@ -132,16 +132,14 @@ static u64 get_except_vector(struct kvm_vcpu *vcpu, enum exception_type type)
 static void inject_abt64(struct kvm_vcpu *vcpu, bool is_iabt, unsigned long addr)
 {
        unsigned long cpsr = *vcpu_cpsr(vcpu);
-       bool is_aarch32;
+       bool is_aarch32 = vcpu_mode_is_32bit(vcpu);
        u32 esr = 0;
 
-       is_aarch32 = vcpu_mode_is_32bit(vcpu);
-
-       *vcpu_spsr(vcpu) = cpsr;
        *vcpu_elr_el1(vcpu) = *vcpu_pc(vcpu);
-
        *vcpu_pc(vcpu) = get_except_vector(vcpu, except_type_sync);
+
        *vcpu_cpsr(vcpu) = PSTATE_FAULT_BITS_64;
+       *vcpu_spsr(vcpu) = cpsr;
 
        vcpu_sys_reg(vcpu, FAR_EL1) = addr;
 
@@ -172,11 +170,11 @@ static void inject_undef64(struct kvm_vcpu *vcpu)
        unsigned long cpsr = *vcpu_cpsr(vcpu);
        u32 esr = (ESR_ELx_EC_UNKNOWN << ESR_ELx_EC_SHIFT);
 
-       *vcpu_spsr(vcpu) = cpsr;
        *vcpu_elr_el1(vcpu) = *vcpu_pc(vcpu);
-
        *vcpu_pc(vcpu) = get_except_vector(vcpu, except_type_sync);
+
        *vcpu_cpsr(vcpu) = PSTATE_FAULT_BITS_64;
+       *vcpu_spsr(vcpu) = cpsr;
 
        /*
         * Build an unknown exception, depending on the instruction
@@ -233,3 +231,15 @@ void kvm_inject_undefined(struct kvm_vcpu *vcpu)
        else
                inject_undef64(vcpu);
 }
+
+/**
+ * kvm_inject_vabt - inject an async abort / SError into the guest
+ * @vcpu: The VCPU to receive the exception
+ *
+ * It is assumed that this code is called from the VCPU thread and that the
+ * VCPU therefore is not currently executing guest code.
+ */
+void kvm_inject_vabt(struct kvm_vcpu *vcpu)
+{
+       vcpu_set_hcr(vcpu, vcpu_get_hcr(vcpu) | HCR_VSE);
+}