KVM: x86: Return to userspace with internal error on unexpected exit reason
authorLiran Alon <liran.alon@oracle.com>
Mon, 26 Aug 2019 10:16:43 +0000 (13:16 +0300)
committerPaolo Bonzini <pbonzini@redhat.com>
Wed, 11 Sep 2019 13:42:45 +0000 (15:42 +0200)
commit7396d337cfadc7c0b32dfd46581e9daff6666e84
tree79f70514a7041169673b60e9a35688fdbc06e47d
parent1edce0a9eb239b7a2768d10cf7d21dd83e269d5b
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.

Reviewed-by: Mihai Carabas <mihai.carabas@oracle.com>
Reviewed-by: Nikita Leshenko <nikita.leshchenko@oracle.com>
Reviewed-by: Joao Martins <joao.m.martins@oracle.com>
Signed-off-by: Liran Alon <liran.alon@oracle.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
arch/x86/kvm/svm.c
arch/x86/kvm/vmx/vmx.c
include/uapi/linux/kvm.h