]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
ARM: KVM: Gracefully handle hyp-stubs being restored from under our feet
authorMarc Zyngier <marc.zyngier@arm.com>
Mon, 3 Apr 2017 18:37:58 +0000 (19:37 +0100)
committerChristoffer Dall <cdall@linaro.org>
Sun, 9 Apr 2017 14:49:31 +0000 (07:49 -0700)
Should kvm_reboot() be invoked while guest is running, an IPI
wil be issued, forcing the guest to exit and HYP being reset to
the stubs. We will then try to reenter the guest, only to get
an error (HVC_STUB_ERR).

This patch allows this case to be gracefully handled by exiting
the run loop.

Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
Signed-off-by: Christoffer Dall <cdall@linaro.org>
arch/arm/include/asm/kvm_asm.h
arch/arm/kvm/handle_exit.c

index eae11b3e98fc7068687b809d3ee2a78e233c6e31..14d68a4d826f6388af790b91bc3c2ae7fa80de13 100644 (file)
@@ -33,7 +33,7 @@
 #define ARM_EXCEPTION_IRQ        5
 #define ARM_EXCEPTION_FIQ        6
 #define ARM_EXCEPTION_HVC        7
-
+#define ARM_EXCEPTION_HYP_GONE   HVC_STUB_ERR
 /*
  * The rr_lo_hi macro swaps a pair of registers depending on
  * current endianness. It is used in conjunction with ldrd and strd
index 96af65a30d78b1e09182d8e41f8b8e3ff4aae81e..5fd7968cdae9efb4f68968eca13afebffb8c0be4 100644 (file)
@@ -160,6 +160,14 @@ int handle_exit(struct kvm_vcpu *vcpu, struct kvm_run *run,
        case ARM_EXCEPTION_DATA_ABORT:
                kvm_inject_vabt(vcpu);
                return 1;
+       case ARM_EXCEPTION_HYP_GONE:
+               /*
+                * HYP has been reset to the hyp-stub. This happens
+                * when a guest is pre-empted by kvm_reboot()'s
+                * shutdown call.
+                */
+               run->exit_reason = KVM_EXIT_FAIL_ENTRY;
+               return 0;
        default:
                kvm_pr_unimpl("Unsupported exception type: %d",
                              exception_index);