Merge tag 'pci-v4.9-changes' of git://git.kernel.org/pub/scm/linux/kernel/git/helgaas/pci
[sfrench/cifs-2.6.git] / arch / arm64 / kvm / handle_exit.c
index fa96fe2bd46969130e2af69c02a8baa33f35a107..a204adf29f0a6dedd1c47485564086ef9682f82b 100644 (file)
@@ -170,9 +170,32 @@ int handle_exit(struct kvm_vcpu *vcpu, struct kvm_run *run,
 {
        exit_handle_fn exit_handler;
 
+       if (ARM_SERROR_PENDING(exception_index)) {
+               u8 hsr_ec = ESR_ELx_EC(kvm_vcpu_get_hsr(vcpu));
+
+               /*
+                * HVC/SMC already have an adjusted PC, which we need
+                * to correct in order to return to after having
+                * injected the SError.
+                */
+               if (hsr_ec == ESR_ELx_EC_HVC32 || hsr_ec == ESR_ELx_EC_HVC64 ||
+                   hsr_ec == ESR_ELx_EC_SMC32 || hsr_ec == ESR_ELx_EC_SMC64) {
+                       u32 adj =  kvm_vcpu_trap_il_is32bit(vcpu) ? 4 : 2;
+                       *vcpu_pc(vcpu) -= adj;
+               }
+
+               kvm_inject_vabt(vcpu);
+               return 1;
+       }
+
+       exception_index = ARM_EXCEPTION_CODE(exception_index);
+
        switch (exception_index) {
        case ARM_EXCEPTION_IRQ:
                return 1;
+       case ARM_EXCEPTION_EL1_SERROR:
+               kvm_inject_vabt(vcpu);
+               return 1;
        case ARM_EXCEPTION_TRAP:
                /*
                 * See ARM ARM B1.14.1: "Hyp traps on instructions