Re: [PATCH] KVM: x86: use positive error values for msr emulation that causes #GP

From: Paolo Bonzini
Date: Wed Nov 04 2020 - 11:40:44 EST


On 04/11/20 17:31, Qian Cai wrote:
On Sun, 2020-11-01 at 13:55 +0200, Maxim Levitsky wrote:
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@xxxxxxxxxx>
Signed-off-by: Maxim Levitsky <mlevitsk@xxxxxxxxxx>
Apparently, it does not apply cleanly on today's linux-next. Paolo, is it
possible to toss this into -next soon, so our CI won't be blocked because of
this bug?


Yep, I plan to send it to Linus later this week.

Paolo