Re: [PATCH 5.10 049/101] KVM: selftests: Fix kvm_check_cap() assertion

From: Paolo Bonzini
Date: Mon Jul 05 2021 - 08:00:41 EST


On 05/07/21 09:10, Fuad Tabba wrote:

ret = ioctl(kvm_fd, KVM_CHECK_EXTENSION, cap);
- TEST_ASSERT(ret != -1, "KVM_CHECK_EXTENSION IOCTL failed,\n"
+ TEST_ASSERT(ret >= 0, "KVM_CHECK_EXTENSION IOCTL failed,\n"
" rc: %i errno: %i", ret, errno);
There's at least one case that I am aware of that potentially would
return a value other than -1 on error, which is a check for
KVM_CAP_MSI_DEVID (-EINVAL, -22):

https://elixir.bootlin.com/linux/latest/source/arch/arm64/kvm/arm.c#L229

In userspace that becomes -1, errno == EINVAL. I probably just misread the "ret != -1" as "ret == 0" when applying this patch; it doesn't hurt but it is certainly not needed for stable.

Paolo