KVM: x86: use positive error values for msr emulation that causes #GP
authorMaxim Levitsky <mlevitsk@redhat.com>
Sun, 1 Nov 2020 11:55:23 +0000 (13:55 +0200)
committerPaolo Bonzini <pbonzini@redhat.com>
Sun, 8 Nov 2020 09:41:28 +0000 (04:41 -0500)
commitcc4cb017678aa66d3fb4501b2f7424ed28fc7f4d
tree180be18d38d5d1c69701a518afa7d1c65e3c053d
parent177158e5b1a558a28b9ce6b27a14bea588a6f2fb
KVM: x86: use positive error values for msr emulation that causes #GP

Recent introduction of the userspace msr filtering added code that uses
negative error codes for cases that result in either #GP delivery to
the guest, or handled by the userspace msr filtering.

This breaks an assumption that a negative error code returned from the
msr emulation code is a semi-fatal error which should be returned
to userspace via KVM_RUN ioctl and usually kill the guest.

Fix this by reusing the already existing KVM_MSR_RET_INVALID error code,
and by adding a new KVM_MSR_RET_FILTERED error code for the
userspace filtered msrs.

Fixes: 291f35fb2c1d1 ("KVM: x86: report negative values from wrmsr emulation to userspace")
Reported-by: Qian Cai <cai@redhat.com>
Signed-off-by: Maxim Levitsky <mlevitsk@redhat.com>
Message-Id: <20201101115523.115780-1-mlevitsk@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
arch/x86/kvm/x86.c
arch/x86/kvm/x86.h