@@ -5103,6 +5103,10 @@ int kvm_emulate_hypercall(struct kvm_vcpu *vcpu)
case KVM_HC_MMU_OP:
r = kvm_pv_mmu_op(vcpu, a0, hc_gpa(vcpu, a1, a2), &ret);
break;
+ case KVM_HC_PANIC:
+ set_bit(KVM_REQ_PANIC, &vcpu->requests);
+ ret = 0;
+ break;
default:
ret = -KVM_ENOSYS;
break;
@@ -5431,6 +5435,11 @@ static int vcpu_enter_guest(struct kvm_vcpu *vcpu)
r = 1;
goto out;
}
+ if (kvm_check_request(KVM_REQ_PANIC, vcpu)) {
+ vcpu->run->exit_reason = KVM_EXIT_PANIC;
+ r = 0;
+ goto out;
+ }
}
r = kvm_mmu_reload(vcpu);
@@ -161,6 +161,7 @@ struct kvm_pit_config {
#define KVM_EXIT_NMI 16
#define KVM_EXIT_INTERNAL_ERROR 17
#define KVM_EXIT_OSI 18
+#define KVM_EXIT_PANIC 19
/* For KVM_EXIT_INTERNAL_ERROR */
#define KVM_INTERNAL_ERROR_EMULATION 1
@@ -47,6 +47,7 @@
#define KVM_REQ_DEACTIVATE_FPU 10
#define KVM_REQ_EVENT 11
#define KVM_REQ_APF_HALT 12
+#define KVM_REQ_PANIC 13
#define KVM_USERSPACE_IRQ_SOURCE_ID 0
@@ -19,6 +19,7 @@
#define KVM_HC_MMU_OP 2
#define KVM_HC_FEATURES 3
#define KVM_HC_PPC_MAP_MAGIC_PAGE 4
+#define KVM_HC_PANIC 5
/*
* hypercalls use architecture specific
Introduce panic hypercall (KVM_HC_PANIC) on host-end to signal that the guest crashed/paniced. This gets signal to userspace with KVM API and ioctl KVM_RUN with exit_reason: KVM_EXIT_PANIC Signed-off-by: Daniel Gollub <gollub@b1-systems.de> --- arch/x86/kvm/x86.c | 9 +++++++++ include/linux/kvm.h | 1 + include/linux/kvm_host.h | 1 + include/linux/kvm_para.h | 1 + 4 files changed, 12 insertions(+), 0 deletions(-)