History

KVM: x86: Return to userspace with internal error on unexpected exit reason

Receiving an unexpected exit reason from hardware should be considered as a severe bug in KVM. Therefore, instead of just injecting #UD to guest and ignore it, exit to userspace on internal error so that it could handle it properly (probably by terminating guest). In addition, prefer to use vcpu_unimpl() instead of WARN_ONCE() as handling unexpected exit reason should be a rare unexpected event (that was expected to never happen) and we prefer to print a message on it every time it occurs to guest. Furthermore, dump VMCS/VMCB to dmesg to assist diagnosing such cases.

Liran Alon committed 7 years ago

Commit 7396d331 parent 1edce0a3 files · +17 −5Browse files

Showing the changes to include/uapi/linux (1 of 3 files). Show all

Unified · Split

include/uapi/linux/kvm.h+2−0
@@ -243,6 +243,8 @@ struct kvm_hyperv_exit { · 242 unmodified lines
243#define KVM_INTERNAL_ERROR_SIMUL_EX 2243#define KVM_INTERNAL_ERROR_SIMUL_EX 2
244/* Encounter unexpected vm-exit due to delivery event. */244/* Encounter unexpected vm-exit due to delivery event. */
245#define KVM_INTERNAL_ERROR_DELIVERY_EV 3245#define KVM_INTERNAL_ERROR_DELIVERY_EV 3
246/* Encounter unexpected vm-exit reason */
247#define KVM_INTERNAL_ERROR_UNEXPECTED_EXIT_REASON 4
246 248
247/* for KVM_RUN, returned by mmap(vcpu_fd, offset=0) */249/* for KVM_RUN, returned by mmap(vcpu_fd, offset=0) */
248struct kvm_run {250struct kvm_run {